Evanescent Thoughts

Evanescent Thoughts

Archive for the ‘Bugs’ Category

The Indian Scenario

with 11 comments

The following is a random premature thought of what in my opinion is going wrong in India, which I am sure a lot of people think about.  Well I am  not gonna put on the Raja Ram Mohan Roy costume and lecture  about changing the society and  stuff ,  but I do  feel  that filling up a few bytes on the internet about this isn’t  a very bad idea either.

So, Whats wrong with India ??? I mean we are a body of 1.2 billion people constituting 20% of the world population. Which means out of every 10 guys on this planet, 2 of them are from India and  2 are from China and the rest 193 nations of the world constitute the remaining 6. Yet we just have nine Noble Laureates, and three of them are of foreign Origin. When we are 1/5 th of world population,  no matter how screwed up you were with  your 10th grade probability calculations, its not a tough job to figure out that Indians must be in top of everything.. not just population. But why is it that, when u take any field, its tough to find an Indian doing better at it ?? I am not talking just about Academia or Research for which every Indian’s instant response is the two worded phenomenon – “Brain Drain”.  Lets talk about sports.. How tough is to find a runner who can at least fetch a bronze medal in Olympics. Why is it that when we have Hockey as our national game, a majority of Indian kids don’t even know the names of the players(not like I know any of them). But every one does know that Sachin Tendulkar did start playing cricket at the age of 16 and has blah blah runs in his pocket and runs a restaurant in Mumbai. If we are so obsessed with cricket, why don’t we bloody change our national sport to Cricket !!!. Whats stopping us from doing that. Oh wait !! we are a democratic nation run by a bunch of corrupt politicians who roam around like zombies in wheel chair.

Population :

Population IS THE biggest feature of India. As a strength, it gives us diversity. You can go all around the US and  you will pretty much get bored of the same burger and pizza and the food varieties and culture it throws at you. Now back in India, you walk a few kilometers out of your district, you might actually end up in a totally different culture.. A different sect of people who talk a different language,  who listen to a different music, eat different food, have a whole array of local cinemas and cine-stars.

I sometimes get curious as to how India ended up with such a big population. I mean how ?? May be the so called Gods had such a plan you know, to stuff maximum number of people into this country and  to top it , they had to make the whole country  HOT and TROPICAL that when Mr Software-Engineer returns from work in the evening, he has to deal with both the HUGE traffic and import supernatural powers to tackle the hot weather outside. At the end of the day, all that is on top of anyone’s mind is  how to survive in this place. At times we even manage to have entertainment amidst all this and that’s why people all over the world respect Indians. They can almost survive any bullshit thrown at them. They are cheap labor who don’t mind sweating it out because compared to what they were doing back at home, anything that you throw at them sounds like luxury.

If India has a 1 billion population, it also has  an equal  number of  divine supernatural entities aka God. At times, you even wonder if they count the  number of Gods into the population stats. And Sachin Tendulkar does contribute under both the human and  divine category to the population stats.  How are you even supposed to survive in  a country with so much population??.  On one side, having a diverse population is a positive thing. But what actually happens in India is a different story.  Lets do a simple math. Say X guys were supposed to live under a km-square of area and it takes Y units of money to provide all necessary amenities to that area. Doesn’t it make sense that with the X very high in India, it would actually be easier to develop infrastructure and facilities ?? No .. that doesn’t happen because, One – we don’t pay our taxes properly. We just love painting our money black. And two – we cause more damage to infrastructure than the amount we contribute to build that.  And the moment we step into a foreign nation, we don’t spit,  we don’t urinate in public. We suddenly get a public sense of responsibility. We enforce that because every one else around you does so. In India, if you don’t cause any public nuisance, you get a nice portrait of yourself   in the “Hall of Clowns who follow rules”.  And nobody wants to change. We just continue living our lives putting up with all of the crap happening around us and contribute to it.

The Indian Rat Race at Schools  :

Lets get back to where all the talented people in India go to ??. The first thing that you notice is, every body in India wants a shortcut to success. By success we mean making more black money. How many of us actually think about living the life on our own ??. Half the Indian kids grow up listening to their parents. The parents mold  their kids into who they wanted to be when they were once in their childhood. Its  a sort of a pipeline where your dad wants you  live his dream and you want your kids to live your dream. You just throw your dreams onto your kids.  “Here kiddo, take all this books and digest them and become a doctor., Because, I once wanted to be a doctor and I didn’t have  facilities back in my childhood to achieve that.  And this will also make you rich and powerful in the society”.  I agree on the fact that parents have the responsibility to teach their kids of how to  become successful. But going a step further and choosing how they do it and in what field they do it is an over kill. And hence every kid gets lectured to be an engineer or a doctor. No one advices their kids or even talks to them about other areas like sports, literature, science, history,  economics, politics, art etc. Those fields are for kids who missed writing their 12th std board exams or those who forgot to bring a pencil to exam hall and lost out on  marks because they didn’t manage to underline the important points in their answers.

I feel like kids of this age are stereotyped into doing things. Each mom compares her kid with the other kids in the neighborhood and lectures him/her about how they need to take them as role models and score better marks in the next exam. And thus the rat race of engineers  begins with a big fat salary cheque on the other end. So most  of  the kids never get to  explore the opportunities in the other fields. A lot of talent actually comes  out in this Rat Race. Thats why when you go abroad and see a graduate student struggling with calculus, you just realize how great the Indian Schooling was. But most of these kids who could do calculus by just hand waving, don’t actually end up as successful engineers compared to what  US produces as undergrads and graduates. Thats just because once the Rat Race is over, we all take a well deserved rest during our undergraduate period. In the contrary, students abroad have a steep learning curve during Undergrad and graduate courses. Which just doesnt happen in India. Thats why even though we have a very successful schooling system, we have a very bad undergraduate experience ( IITs in my opinion can be exempt). There are several perspectives to this but lets rest on this.

Why Brain Drain??

So we only manufacture engineers in our country and what happens next ??  All these bright engineers run away to better places in the world because, those  not-so-talented kids who chose  the other important fields that constitute a society, do a bad job in their field and make the place a hell to live. To become a developed nation, India doesn’t need top notch computer scientists, but it needs talented people in the other fields who make India a better place to live. You need a good politician, a good economist a good city planner,  so on. But no one wants to choose these because they are poorly paid or have no clear shot at success in Indian terms and scenarios. So why not give these guys who do the less interesting but important jobs a better future. Lets lure the talented people into these fields.  One of my  batch mates  who graduated with an Instrumentation  & Control Engg degree, decided that Politics was the field he wants to be after he joined a company for work.  He even went on to enroll for some correspondence courses in politics as he works. Now if some one had put a thought in him when he was a kid that a politician was some one whom the society respects and needs,  he wouldn’t have wasted 4 years in NIT Trichy attending crappy engineering classes.  We would have had a  good politician who could have run the CWG without any corruption or not cause $36 Billion  loss to Indian government over the spectrum allocation. What India needs is not eradicating brain drain and stopping the talent from going outside the country. But  what India  needs is to make sure that  a fair share of the young talent pool goes on to contribute and develop the  other  fields that contribute  to the society. And of course yeah better politicians.

PS : All of the above are  random thoughts feel free to smirk them off if you are not in the mood to listen.


Written by Sathya Narayanan

November 18, 2010 at 12:55 am

Finding Invisible Friends and Dynamically Updating Your Status in Google Chat using XMPP Scripts #linux #python #ubuntu

with 24 comments

Read on, only if you Wanna do any of the following :

  1. Update your  google Chat status with info dynamically or fetch score from a website and display it every minute in your status msg.
  2. Find invisible friends in your chat list.
  3. Wanna change your status message as soon as some one signs on ?? aka make your own Buddy Pounce.
  4. Wish all your contacts by running a simple prog on important days. Like say, I wrote a script that wished  my  friends “Happy Friendship Day” when they appeared online 🙂 .
  5. Get a step closer to writing  your own back end for an IM client.
  6. Wanna remind someone about something over chat at a particular time or period when you might not  be online.
  7. And lots more that your imagination can limit.

Warning : I dont promise that everything in this is right. There might be  hell lot of mistakes. Feel free to point them out in the comments 🙂

Being someone who does a lot of IM and chatting, I was more curious about how a web chat works. How is it that you are instantly notified of your friend’s online presence and know when he is about to type something on your chat window. A little more digging and reading a couple of sites on XMPP  helped me figure out what I have been wanting to do a long time back in College. What basically you need for having a chat with your friend miles away is an XMPP Server (eXtensible Messaging and Presence Protocol) and an authenticated connection established to it. And of course an IM client (like google talk or pidgin or empathy) unless you wanna write your own command line scripts using some Python API for XMPP.

Firstly, I m not a big fan of gtalk, just cos it doesnt exist for Linux platform and who the hell uses an IM client just for google. An IM client is something that maintains all your chat accounts across various domains that u have a authentication on. An XMPP server listens to your xmpp requests on port 5222 and 5223. To give an idea about how the whole thing happens, imagine an XMPP server with which Alice and Bob have established their authentication. Unlike VOIP, chatting is done  with a man in the middle which happens to be the XMPP server. When Alice wants to send a IM(Instant Message) to Bob, Alice sends it to the server and the server sends it to  Bob. This sending and receiving is done in the form of XML packets. An XML stream runs between the Server  and Alice. A similar stream runs with Server and Bob. Whatever Alice puts on the XML stream is received by the server and the server reads the XML packet and looks at to whom the message is intended for and the server puts an XML packet to Bob’s XML stream and hence Bob receives the message Alice sent :). All this happens each time  u type something on ur IM client or change your status. Now this is  all about messaging. What about the status notifications and stuff ?? Thats where the presence part of XMPP comes to play. Basically a stanza in the XMPP stream between the server and the client can be etiher a Roster/Message/IQ/Presence. A Roster is used to notify the client about who all are online and registered with the server. A Message as I said above is a stanza that is used to communicate from one client to another through the server. A IQ is Info/Query where in u get specific info about a user. And finally a Presence is used to notify your type of availability to the other users (like busy , dnd  , away and put a status). This is the view of the XMPP  like how say you might see earth flying from an airplane . Each of these have their own specifications and finer details. For more, if you are interested, google it up .

When google opened a subdomain aka talk.google.com, users (the geeky ones) were able to authenticate and start chatting even before google officially announced that it has actually started an IM service :).  This happened back in 2004 when google first started the talk.google.com subdomain. Since then it kept on adding features to it chat client and led to group chat and stuff. But as I see, gtalk is not even close to an IM client. Its specific to google and has very limited capabilities when compared to pidgin or empathy. I am not talking about just using multiple accounts but about stuff that you can do with just your google accout like say control the presence notifications, add a  buddy pounce n stuff :). Well I can throw in more info with all my current enthu  about xmpp but I ll stop here and break straight to the part of writing cool scripts to do stuff with your google Chat that you cant do with your gtalk 🙂

Stuff that you might need : Python interpretor, xmpppy library for python. If you are in Linux , install python-xmpp and python-dnspython packages and you should be clear to go. If you are on windows, Keep breaking your head 😀

The first script I am gonna show here is how to send a message to a friend. This is how I started it. You might wanna cross check with the documentation here.

import xmpp
import getpass

passwd = getpass.getpass("Enter Password: ")

client= xmpp.Client('gmail.com',debug=[])
message = xmpp.Message(to,msg)

A quick look should tell you that Lines  1 and 2 import the necessary modules. The getpass module helps you to enter the password like the way you would enter it on a computer. Otherwise, you would have to put it somewhere and expose it (even better ways to do this are welcome in comments). I am declaring the variables in Lines 4,5,6,7. Line 9 , I create a xmpp Client with the parameters. When u specify the debug=[] option, the debug messages dont get thrown at you in the terminal. You connect to the server on port 5223 in Line 10 and authenticate in  11. Line 12 sends a Roster request and Initial Presence notification. You construct a message packet in the Line 12 and set its attributes in Line 13 and send it to server in Line 15 🙂 .

The next one I worked on was a script to dynamically update my status message with something like a clock or a cricket score. I am gonna leave to US on Aug 19th and thought how cool would it be to put a countdown on my status that updates how much time is left every minute(First I set it up every second, but it gets irritating to chat on the other end unless you have a very patient friend 😛 ).

import xmpp
import time
import datetime
import getpass

passwd = getpass.getpass("Enter Password: ")

client= xmpp.Client('gmail.com')

	diff = datetime.datetime(2010, 8, 19,4,40,00) - datetime.datetime.today()
	minutes=str(diff.seconds/60 - (diff.seconds/60/60 * 60))
	seconds= str(-seconds1+(diff.seconds))
	timeleft=days+" Days, "+hrs+" Hours, "+minutes+" Minutes more !!"
	pres=xmpp.Presence(priority=5, show='chat',status= timeleft )

Lines  upto 12 are self explanatory . I then start a while loop and calculate the difference in time from the current time to the time when I ll be boarding my flight. The diff gives back a structured variable with diff in days and seconds. The seconds difference is done mod 86400 (ie no of seconds in a day). So make appropriate calculations to count the days, minutes and hours and seconds left in lines 15-20 and I construct a XML Presence stanza by calling the xmpp.Presence() and send it on to the XMPP server. After this, I pause the loop for 60 seconds in Line 24 to send the next update packet after a minute. You could do something like put up Live cricket scores  and stuff here to keep your friends informed or put a horizontally scrolling status msg or whatever that comes to your mind !! 🙂 .

The next script that I have is a script to find invisible friends in gtalk 🙂 .  This I find pretty much useful. I used to do the other way around (that is to make myself invisible from pidgin by sending an XMPP req)  cos Pidgin’s Inivisible status doesnt work well. I found the info here when I was googling it back in my coll. Basically I put the following XML snippet in my Pidgin’s XMPP console to make myself go invisible.

<presence type="unavailable">

So I try to do the reverse of this from the Roster I get from the server and that should pretty much give the list of people who are invisible on gTalk :). Which I do in the following python code.

import xmpp
import getpass

user = "sathya.phoenix"
passwd = getpass.getpass("Enter Password: ")
server = "gmail.com"


def check(connec, event):
   if event.getType() == 'unavailable':
     print event.getFrom()

client.RegisterHandler('presence', check)

while client.Process(1):

Lines 1-10 again do the same authenticating and stuff while in Line 11 , instead of just sending the initPresence , we request for a Roster which gives us the status info of all my friends who have registered with the XMPP server. Now here is the magic. Even though you are invisible , your client registers with the XMPP server and sets the status as unavailable which the other Clients detect that and put you under the offline category(those who havent registered).  So all we got to do is to check for which of the registered users in the Roster are having a status “unavailable”. Pretty simple thing to break someone’s privacy huh 😉 .  So we have a handler to handle the presence notifications in the Roster and display the gmail ids that have status as “unavailable” and have registered with the server.  Now only disadvantage is that, if your friend is invi , he sure ends up on this list, but not vice versa. There are a couple more to check for that as well :).

So you could write handlers that can do a lot of stuff for you. Like you can send wishes to all online contacts by calling the client.send() in Line 15 and remove the if statement on Line 14. Or when some buddy of yours comes online , you can change your status message to soemthing else . Guess you can figure all that out by looking at the scripts above and combining them and making suitable modifications. Its all exciting !

PS : Any more cool ideas to do, put them on comments. Will try out 🙂 Also check this out if you wanna insert code snippets in your blog the easy way 🙂

Written by Sathya Narayanan

August 3, 2010 at 11:25 am

Do IM Clients (Pidgin,Skype et al) Detect Subnets and Avoid wastage of Internet Bandwidth ?? #linux

with 5 comments

I Post this  hoping someone  would explain to me How stuff works when you make a Video call across Internet. Also, Please correct me wrong if I am wrong anywhere.   Now, What I have been thinking in mind is that, When Alice and Bob, sitting in different locations( not in the same subnet)  try to have a conversation through  some IM protocol, the server acts as a mediator. That is, the server gets the message or data from Alice and sends it to Bob and vice versa.  So I   assumed the same to be the working scenario in case Alice and Bob happen to be in same Subnet but say try to call each other on skype. I am now beginning to doubt this as I noticed something peculiar as I tried to make some video calls. My  observation is that in the case where Alice and Bob are in the same subnet and connected to Internet through a common gateway or  one of them acting as gateways.

My setup is as follows : All computers run on Ubuntu Lucid Lynx

BSNL Modem :    IP: with a bandwidth of 512 Kbps

Vostro Laptop :    Connected to the BSNL Modem  via eth0 and running a Wifi network on wlan0( 54Mbps) both of which share the same internet connection( refer this ) eth0: and wlan0:

Studio Laptop:    Connected to the Wifi connection set up on the Vostro Laptop and has the IP address as wlan0: . So any http request from this goes to the BSNL modem via my Vostro Laptop (

With this setup, My Vostro and Studio laptops are in a Subnet and they are connected to the Internet via my Vostro Laptop. Now when I start  any  file download from Internet or torrents, I get some 80KBps on my eth0 on Vostro and some 60KBps goes to the Studio Laptop via the wireless lan 🙂 .. Now I install skype on both the machines and and create 2 different accounts and make a video call from one account to another . Now I thought the connection on was supposed to handle the traffic for both the comps and forward the packets from internet for from the internet server that hosts the video call. But what actually happens is that there is no traffic  to outside the subnet. That is my internet traffic is 0 kbps both incoming and outgoing whereas the communication required for the video calls happen directly between and without a single packet being sent to the outside network (

So this is something like when a video call is established on a subnet, it works P2P and not through the server on the internet. CORRECT me if this is wrong.  To clearly see .. check the following screen shot.

Now the one on the Left is my on eth0 and on wlan0 . The yellow circled one is the traffic on 10.42.43.X subnet . Notice that while the call is in progress, The connection on which is connected to internet is not even 1KBps . Its in Bytes per sec .  This is exactly what I am talking about. The video call works Peer-to-Peer as if it is happening locally and not through some Internet Service. Calls to my friends outside, create traffic on as expected. Only when the calls are within the subnet, everything seems to be and inside business :). Quite interesting is it 🙂 . That means, I dont have to pay for the ISP bandwidth  that will be used in all this video calls within a subnet. This is why when I called my friends, the audio and video were poor quality and when I called within the subnet, the clarity was awesome :).

This was the case with video calls on Skype and Pidgin on Ubuntu Lucid Lynx.

Now the following questions :

  1. Is this how its supposed  to happen?? So the server hosting the video call doesnt have to receive and deliver data during the call if both Alice and Bob are within same subnet connected to internet ??
  2. Is this the case with only video and audio calls or for anyother protocols ???
  3. What is this thing exactly that makes the pidgin or skype detect that it doesnt have to pass the packets to the internet and just pass  it directly to the computer on the subnet . It works as though a direct P2P connection is set up.
  4. Does it happen only with Linux or Windows and Mac too ??

Applications :

Imagine you are in an organization and  you have say 10 computers connected in a subnet  which is connected to an Internet gateway. Now every one within the subnet can do a video chat using the skype and gmail accounts without even passing a single packet to the outside network . This means the company doesnt waste the internet badnwidth when the calls are made within the subnet .. Some thing like calling from reliance to reliance is free :P.

People who have some ideas about this , please post as comments or let us discuss on IM 🙂

PS : wrote it in a hurry 😛 .. so bear with the formatting 😛

Written by Sathya Narayanan

June 29, 2010 at 9:33 am

gstreamer bug in Ubuntu and a temporary fix

with 5 comments

Off late I found that some of the movies that I downloaded from the internet played really wierd . The quality of the movie was good but the colors seem to be distorted and there used to be a green band . Look at the pics below . The one in the left is how the actual movie is supposed to be and the one in the right is how it appears.


Few things I tried out to fix this :

1. I thought it was the problem with the video i downloaded because not all videos had this prolem . So I tried using mencoder to convert to other formats and fix the video . Didn’t work 😦

2. Tried re-downloading and changing my torrent managers . Miserably failed 😦

3. Tried playing in all sorts of different player . All of them had the same problem . Now I was sure it was not a problem with the codecs used nor the player.

4. Booted in windows and tried playing . Worked perfectly fine. So I was sure the problem was still with Linux .

In the mean time I had deleted a couple of movies because I really got irritated because of the problem .

This is when  googling struck me and I found out about the gstreamer bug .  GStreamer is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.

Tried meddling with the properties of gstreamer from the command line . No effect 😦

Finally did the following

sudo apt-get remove totem-gstreamer

sudo apt-get install totem-xine gxine

Yippe !!! All videos worked fine with the new players using the xine engine 🙂 . I hope they get to the bug fix soon . Mean while you can log your complaints at http://bugzilla.gnome.org/show_bug.cgi?id=357741  and please mention any fixes you get to know . One of them involving changing gstreamer properties seems to work for some .

Written by Sathya Narayanan

March 11, 2009 at 1:44 am