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 !