Monday, December 31, 2007

Finding friends of friends with more no.of mutual friends in orkut

I have been waiting for a long time for finding my friends of friends in orkut, who have more no.of mutual friends with me. If a person has more than 5 common friends, I may know that person. Of course, there are many cases, in which this does not apply. But, instead of browsing all the friends of friends, and finding my friend, this would be easier. I posted in orkut groups, and requested my ex-colleague Jude Britto to add this feature. By the way, Jude Britto is working for google, and he added the feature find your gmail contacts in orkut.

In the last 3 days, I tried to find out the probable friends, and it was not as difficult as I thought.

I have around 340 friends, and if I can get all the friends list pages of all my friends, then it would be easy to get the probable friends. wget is a very nice utility to download anything. For authenticating the session, we need to pass the username, password, and some other information to orkut as post data. It would be time consuming to findout all the form information. I used Live http headers extension in firefox. With that, if you do any operation in any website, it will store all the http information. For example, if you start Live http headers, and login to orkut, it will store all the requests that it had sent for logging in. It would take around 4-5 requests before displaying the home page. We can use that http headers to build wget request. There are few options --load-cookies, --save-cookies, --keep-session-cookies in wget. With that, we can have a proper session with wget.

Once the authentication is done, rest all can be automated. I have done in the following way.

  1. The script takes my id, and downloads my profile page by wget.
  2. VIM parses that file, and finds out no.of friends, and a C program generates the URLs for all the friends. (It is possible to generate URLs also with VIM. I did not remember how to do it at that time)
  3. wget gets all friends list pages of all my friends.
  4. VIM parses all the files, and stores all the friends of friends in plain text format.
  5. A program written in Java takes all the friends of friends, and finds out probable friends.

I have around 50,000 friends of friends. Around 1000 friends of friends have more than 5 mutual friends. It was much more than what I expected.

After getting all this data, I was wondering, if orkut adds this feature, would I use it or not? Except for the feature, find your gmail contacts in orkut, In all other features, orkut uses paging, and shows 10-20 items in a page. If I have to see all the 1000 friends of friends, I may have to open 50 pages, and it would be tedious. But, with my script, I could get all the details in a single plain text file, with one line for one friend of friend. So, it was very easy for me to find out my friends. If orkut had implemented this feature a week back, I would not have tried to use this feature, and would have browsed all the 50 pages, and would not have learned about logging into a website programmatically. So, I should be thankful to orkut for delaying this feature. ;)

I would like to thank Deepak Manohar for teaching me few VIM commands for parsing the html files.

Sunday, December 30, 2007

Cartoon of the year



The text inside the cartoon is, "Monarchy in Nepal is abolished, and all the powers are transferred to the Prime Minister".

The text outside the cartoon is, "It would be good, if we also abolish monarchy, and transfer all the powers to the Prime Minister".

Thursday, December 27, 2007

Love poem

its a love story
of two strange people
who never knew they could
fall for each other
when they first met
they only ended up fighting
but slowy it became clear to them
that they sure shared something

a small problem happened
when pride overtook him
he thought she was
less smarter than him
she would solve a puzzle
and he would solve it again
he would tell her
that she was simply
an idea away from him...
he said that he always gets this idea
and then he does all that she can
and probably much more...

one day she decided
his behaviour had to be checked
she thought for a while and
then she said...
fine, then you sure
can do everything
but if you are strictly more smart
you have to do the following
think of some puzzle
that you can easily do
and then give it to me
to solve and lets see if
i can't do....

all the king's men and
all the king's horses
could not come up
with a puzzle like this
the duo got closer and
the world around more curious

today as it stands
the puzzle is still not found
and hence the duo
lives happily close bound
they two are well known
as simply, inseparable
P is the queen and
NP the king of our fable...


Shamelessly copied from http://nutan.blogspot.com/2007/02/valentines-special.html.

If you cannot understand this, or thinking of why did I write love poems here, this poem describes the well-known computer science problem "P=NP or not"? If you have the solution for this, you would get minimum million dollars, and turing award (equivalent to Nobel prize in Mathematics), and many more.

Thursday, December 20, 2007

Sharing in google reader

Google added another good feature to google reader. You can now share items in google reader with everyone. If you just open http://www.google.com/reader/shared/04007765351263823119, you would see all the items that I shared. The feed for my shared items is http://www.google.com/reader/public/atom/user/04007765351263823119/state/com.google/broadcast.

Many times, I copied and pasted interesting articles into my blog from some other place, so that readers of my blog would read that. With this shared items, I don't need to do that. But, users of my blog have to subscribe to my shared items as well.

Eventhough I have more than 800 contacts in my contact list, only 18 people are using google reader, and only one person (XP) is sharing his google reader items. Even then, I got so much information from his shared items. So, all of you please start sharing your items, and either give me the link, or accept me as a friend in google.

Do not use plastic bags

Do you use plastic bags to store food in your refrigerator? Do you have plastic bin-liners in your home to collect and throw garbage? Have you ever asked for "one more plastic bag" in your local supermarket while shopping? If you run out of gift wrapper, do you conveniently carry the gift in a plastic bag and present it?

If you answered "yes" to the above questions, then you are plastic-dependent. In fact, most of the world is! Every year, around 500 billion (500,000,000,000) plastic bags are used worldwide. So many that over one million bags are being used every minute and they're damaging our environment. Here's how:

* Plastic bags often take up to 1000 years to degrade! When they are thrown away, they cause potentially eternal havoc clogging drains, creating backflow in sewage pipes, spreading disease through pond-like accumulation of sewage, breeding mosquitoes by storing stagnant water. Do you know that they are responsible for the Mumbai floods every year? It is such a big problem that Bangladesh has a national ban on its use, blaming plastic bags for the floods during monsoons that claim so many lives every year!

* The effect of the poly-bags is deadly in the waters too. Being light they are carried far and wide and eventually into the sea, causing immeasurable harm to marine life. The river Yamuna, for example, receives hundred of poly-bags everyday, with flowers in them as offering to God.

* The mountainous regions are not spared either. Plastic bags get buried in the ground, destroy the local eco-system, and retard the soil's carrying capacity. Due to their non-porous nature they seal off air, thus affecting plant life. This in turn reduces the vegetation and hence soil binding, and increases the risk of landslides.

* Poly-bags have harmful effects on animals. Jaipur reported a case of 40kg of plastic bags recovered from the stomach of a dead cow! All over the world, millions of birds, fish and other animals meet their death by mistaking plastic bags for food (or trying to eat the food we throw away in such bags).

* Plastic bags contain toxic dyes that can pass into foodstuffs, endangering human health.

* Burning plastic bags releases toxic gases into the air, creating climate change.

* STOP using plastic! Use recyclable paper bags, reusable cloth bags, jute bags, etc as alternatives.

Let us all collectively work to save our beautiful planet and make it a better place for our children !

Tuesday, December 18, 2007

Default feed for blogspot

The default feed for all the posts in blogspot is
http://<blogname>.blogspot.com/feeds/posts/default

and the default feed for all the comments in blogspot is
http://<blogname>.blogspot.com/feeds/comments/default

Sunday, December 16, 2007

Tab Menu in VIM

There is a nice plugin for tab management in VIM. If you add that script to plugins directory in VIM, then a new menu would come for Tabs. That menu would list all the files that are there in different tabs. If you click on any file name, it would take you to the tab of that file. This will work similar to tabs in crimson editor, or editplus. VIM 7.0 already has all the features that are required for beginners. With this feature, one can easily manage many tabs. You can get the script from

http://www.vim.org/scripts/script.php?script_id=2096

Few Tips on opening files in VIM:

If you want to open a file in the existing VIM in a different tab, use
gvim --remote-tab-silent < fileName >

If you want to have a right click option which always opens the file in a new tab in existing VIM (Opens a new VIM if there is no existing session), then do the following.
Open Registry Editor (regedit)
In My Computer -> HKEY_CLASSES_ROOT -> *
Add a new key "shell". In that add another new key "gvim", and in that
create a key "command". Change the default value of "command" to
C:\software\Vim\vim70\gvim.exe --remote-tab-silent "%1"

(Remove " in shell, gvim, and command. For gvim.exe, use the path of your installation)

With this, you will get a right click menu item gvim, and if you click on that, it will open the file in a new tab in the existing VIM.

With VIM 7.0, editing multiple files became as easy as any other editor. So, start using VIM.

By the way, this is my first ever contribution to open source. I never expected that, my first contribution would be in the most matured product. If you like it, or want to give feedback, please send me a mail. My mail id is this blog name at gmail.com.

Friday, December 14, 2007

New and good feature in Orkut

Orkut has added a new feature, "find gmail contacts on orkut". This is really a nice feature, and I have been waiting for this kind of feature for a long time. At last, they are adding good features because of the competition from facebook and others. I hope they will continue to add good features like this.

The feature name is obvious, and I don't need to explain anything in that. One thing they missed in this is, It will show all the people who are in orkut, but not your friends. But, it does not show the email id for the corresponding profile. If the person does not use their name in the orkut profile, then it becomes very difficult to find out who is that person. If they give mapping of mail id to the orkut profile, it would be really good.

By the way, I added 23 friends by this feature (even though I had 323 friends in orkut). :)

Wednesday, December 12, 2007

Stock Market (again)

It was autumn, and the Red Indians on the remote reservation asked their New Chief if the winter was going to be cold or mild. Since he was a Red Indian chief in a modern society, he couldn’t tell what the weather was going to be. Nevertheless, to be on the safe side, he replied to his Tribe that the winter was indeed going to be cold and that the members of the village should collect wood to be prepared. But also being a practical leader, after several days he got an idea. He went to the phone booth, called the National Weather Service and asked ‘Is the coming winter going to be cold?’
‘It looks like this winter is Going to be quite cold indeed,’ the meteorologist at the weather service Responded.

So the Chief went back to his people and told them to collect even more Wood. A week later, he called the National Weather Service again. ‘Is it going to be a very cold winter?’
‘Yes,’ the man at National Weather Service again replied, ‘it’s definitely going to be a very cold winter.’

The Chief again went back to his people and ordered them to collect every scrap of wood they could find. Two weeks later, he called the National Weather Service again. ‘Are you absolutely sure that the winter is going to be very cold?’
‘Absolutely,’ The Man replied. ‘It’s going to be one of the coldest winters ever.’

‘How can you be so sure?’ the Chief asked. The weatherman replied, ‘The Red Indians are collecting wood like Crazy.’

This is how stock markets work!!!