A bookmarklet to extract photos from facebook album

Few days back I wanted to download all photos of a facebook album. Unfortunately that album was a personal public album can’t easily use facebook’s graph api to extract image links. In web when all else fails you still can do some magic with javascript. 🙂

I used the following bookmarklet to extract image links of thumbnails. It opens a separate window where it prints all the links, next use wget or any other downloading software to download images.

javascript:x=document.getElementsByClassName('uiMediaThumbImg');w=window.open('','','width=1024,height=768');for(i=0;i<x.length;i++){w.document.write(x.item(i).getAttribute('style').replace(');','').replace('background-image: url(', '').replace('p206x206/',''));w.document.write("<br/>");}w.focus();

wget command to download images

wget --no-check-certificate -i files.txt

Be aware: Quite a few assumptions are made!

Double Brace Initialization in Java

It is a subtle use of two basic java conceptions. First, we can create an anonymous inner class in time of class instantiation, syntax for which is usual

new Person(){};

Remember we are not exactly creating an object of Person rather we are creating an object of anonyms subclass.

Then we can define any number of initializer block in a class [Official Doc]. Syntax for that is

class Person {
    {
        System.out.println("In an initializer block");
    }
}

Bingo! Lets combine them both we get the double brace initialization

new Person(){{
    //do anything with this subclass of person
}};

Continue reading