Sunday, June 15, 2014

Google Youtube suggestions for player - settings for quality and annotations in profile

To google support
1. in full screen goes to HD even if i made it go to 480 or 360p in earlier videos. can you add a setting in profile for your player not to do this? Why? Live in India, pay INR 1300/- per month to a "fibre" optic broad band provider (ACT) but still get slow connections, except for their sponsored speedtest site! duh. If your player does not go to HD i can watch without pauces and bad breaks.

2. similarly with annotations - a setting in profile to turn off by default

Note this was shared via the feedback tab too but re sharing so others who agree can send to them as well

Thursday, June 12, 2014

Java: rename file : file_0001.dat, file_0002 to file_0004, file_0008.dat

Issue: bunch of files name file_0001.dat, file_0002.dat......file_1000.dat.
 I want to change the file names such as the number after file_ will be a
 multiple of 4 in comparison to previous file name. So i want to change 

file_0001.dat to file_0004.dat
file_0002.dat to file_0008.dat 
 
Start from the highest and go to lowest. As 
if u go from lowest - there will be conflicts. example u cant rename 001
 to 004 if there is a 004 from before ...what if it at first you have 
file_0001.dat, file_0001.dat, ... file_0004.dat. 
  
 import java.util.*;
import java.io.*;

public class RenameFiles{
    private Properties props = new Properties();
    private String args[];
    private TreeMap<Integer, FileRen> ffs = new TreeMap<Integer, FileRen>();

    RenameFiles(String args[]){
        this.args = args;
        start();
    }
    public static void main(String args[]){
        new RenameFiles(args);
    }

    void start(){
        defaults();
        load();
        scanDir();
        renameDo();

    }

    void renameDo(){
        final int ll = ffs.size();
        if(ll < 1){
            System.err.println( "Nothing to do ffs size " + ll );
            return;
        }
        ArrayList<FileRen>  frs = new ArrayList<FileRen>();
        frs.addAll(ffs.values());
        for(int i  = ll - 1;i >= 0; i--){
            FileRen fr = frs.get(i);
            boolean t = fr.orig.renameTo(fr.renamed);
            System.err.println(i + " Result " + t + " " + fr.orig + " to " +  fr.renamed);
        }
    }

    void load(){
    if(args.length > 1){
        }
    }

    void defaults(){
        props.setProperty("dir", ".");
    }

    void scanDir(){
        File f = new File(props.getProperty("dir"));
        FFilter ffilter = new FFilter();
        String []l = f.list(ffilter);
        for(String nn : l){
            FileRen fr = FileRen.check(f, nn);
            if(fr != null){
                ffs.put(fr.idx, fr);
            }
        }
    }
}

    class FFilter implements java.io.FilenameFilter
    {
    public boolean accept(File dir,
             String name){
        System.err.println(dir + " " + name + " check ");
        File f = new File(dir, name);
        if(!f.exists() || !f.isFile())return false;
        final int i = name.lastIndexOf(".");
        final int i2 = name.lastIndexOf("_");
        if(i2 < 0 || i < i2)return false;
        return true;
        }
    }

class FileRen{
    File orig;
    File renamed;
    int idx;
        FileRen(){

        }

        static FileRen check(File parent, String s){
            final int i = s.lastIndexOf(".");
            final int i2 = s.lastIndexOf("_");
            //file_0001.dat to file_0004.dat
            if(i2 < 0 || i < i2)return null;
            String p = s.substring(i2+1, i);
            try{
                int idx = Integer.parseInt(p);
                if(idx > 0){
                    FileRen f = new FileRen();
                    f.orig = new File(parent, s);
                    f.idx = idx;
                    int nxt = idx * 4;
                    String pad = pad(nxt, 4);
                    f.renamed = new File(parent, s.substring(0, i2 + 1) + pad +s.substring(i) );
                    return f;
                }
            }catch(Exception e){
                System.err.println(e + " " + parent + " " + s);
            }
            return null;
        }

        static String pad(int i, int k){
            StringBuilder sb = new StringBuilder().append(i);
            int ll = sb.length();
            for(int c = ll; c <= k; c++){
                sb.insert(0, '0');
            }
            return sb.toString();
        }
    }
 
 
Utility script to make a few files, test helper
touch file_0001.dat touch file_0002.dat touch file_0004.dat touch file_0005.dat touch file_0007.dat This version just start the program in the same dir as the files, after compiling and changing the classpath
javac /prog/j/apps/sel2in/ioFiles/RenameFiles.java
java -cp /prog/j/apps/sel2in/ioFiles/ RenameFiles
 

Friday, April 18, 2014

SSL, Bank domains, heart beat


To Times of India Editor:
Saw an article in the technology section of the TOI physical news paper on 17th April, 2014 about HeartBeat and SSL, it has lists of banks and other websites and the results from some tool.

Would be  good if they update the website with note on banks, instead of just pulling the article.
The main domain of the banks like hdfcbank.com or icicibank.com when anyone who has used netbanking and looked a the address bar should know that the domain changes. and with that the certificate so for example icici is https://infinity.icicibank.co.in and HDFC is https://netbanking.hdfcbank.com/ why the difference - i dont know just the way it was implemented - maybe can change the link without affecting the main site. someone did it years back and just continued. with a sub domain can even have a different IP/ web server, more clustering options. And a sub domain needs a different certificate;  so they put the grand security on this and the main site that is just links, marketing & help content.

  Is incorrect to say icici has no ssl, please add this note that the sub domains where net banking happens does have (after testing it). I don't work for a bank nor a share holder but know something about server tech.

Really makes you think how much of what you report is true and how much is just ignorant, under researched or a way of getting back to people who are not advertising enough?
Maybe vet these articles by paying tech savvy people to proof read first?

Followers