31 Jan 2011

Mind what you expect

I am learning GWT because the new project I am going to be working on uses GWT.  Like with every other technology, tutorials only cover the surface, and for real life tasks you either have to read the big manuals or ask for help.  I had a few questions about my work, so I sent a mail asking for help.  I thought that I would get a response only tomorrow, so started reading a really long email that's been pending in my inbox for more than a week.

Surprisingly, another person in my team responded to my mail within a few minutes with answers, but now I find myself demotivated to continue on the work.  I never thought expecting "worse than ideal" can have such an impact on productivity!

29 Jan 2011

Mordacs FTW

I hate incompetence.  Interacting with incompetent people pisses me off.  United Health Care provides medical insurance for my company, and the expense incurred on the lenses of my spectacles is covered.  This year I got a new pair of glasses with a 50% discount on the frame.  The bill clearly says the lenses were sold at the actual price and the frame at a discounted price.  Either UHC reads bills like reading post-modern literature, or they have limited comprehension ability.  They applied the 50% discount on the lens price and said they'd reimburse only half of the incurred expense.

I went ahead and filed a dispute.  I was pleasantly surprised when they called me the very next day.  The person on the phone listened to me patiently and she said she'd do what she can.  Later, I got a mail saying they will investigate and pay me after 2 months!  (I'm amazed at this efficient process!)  In a few days I forgot the whole thing.

A couple days back the same person called me again and said they looked into my case and they would pay me a little more than the original offer, but not the actual expense incurred.  I had forgotten the whole thing, and I wasn't interested in asking her why.  Today, I get a mail saying they will pay me about a 1000 rupees lesser than the original offer.  WTF?!  I again filled up their feedback form, but this time with a more liberal choice of words.

Even more pissing off was their feedback form.  You cannot use hyphens, exclamation marks, or quotes in the feedback text.  It means you cannot write "don't", instead you write "do not".  (Slightly better than these people, but still they are Mordacs.)

I have an ask for you, the reader.  If you do come across a Mordac in real life, please ask them to learn how to prevent SQL injection without spoiling the user experience.  Please do that, you're not doing me a favour, you're doing a favour to the entire web!

22 Jan 2011

127 Hours

Just finished watching 127 Hours.  I don't know what I feel.  I have broken my bones and I know how much it hurts.  That night, after I fell off my bike I tried to get up, but I couldn't.  So I lay back on the road expecting someone would come to help me.  A very generous person stopped his car and asked "Are you okay?"  I didn't think for a split second before shouting back "No!"  He literally carried me to the side of the road where we made a couple phone calls to my friends.  He carried me again to his car and I was almost fainting in pain because I couldn't rest my broken leg on the car seat.  We went to a nearby hospital.  I had to climb up to the first floor via staircases and I simply refused.  He was annoyed a bit, but he nevertheless carried me to the hospital climbing the stairs.  I held my pants to support the broken leg, but every single jerk felt like electric shock all over my body.  I know what a fracture and pain can do to you.  Such a pain can easily stop your brain from thinking.  I know I should have asked the guy to send me to a good hospital.  I must not have stressed my leg so much.  But I just couldn't think anything.  Heck, I didn't even know what was happening to my leg.

In the movie, Aaron starts by breaking his bone!  When I saw him do it I could feel the pain and I almost screamed.  I guess cutting your own body is one of the worst tortures you can do to yourself.  I don't know what I think about it right now, but I have a feeling that this movie is going to be disturbing me for some time.

I thought of trying out the book too, but they don't have a Kindle version :(

19 Jan 2011

Demystifying Android power usage

I have been using Android phones for more than 2 years now.  One of the biggest issue some people have with Android is battery life.  Today I did some mini troubleshooting of battery usage on my phone, and thought I'd write about it.

I woke up in the middle of my sleep early this morning and I disconnected the phone from its charger because it had already charged to 100%.  Went back to sleep and woke up after an hour or so.  Guess what, the battery was at 92%!  While the phone wasn't doing anything at all, it had lost 8% battery.  That definitely doesn't sound good so I opened the battery usage monitor (Settings > About phone > Battery use) and found that "Android System" was the component that had been using most of the battery.

Android System is the component responsible for syncing email, calendar, photos, etc.  I work at a company where I get 200+ emails a day on a normal day.  I had enabled syncing of my work email two days back, and it looks like that's consuming a lot of power.  Apparently my phone had been kept awake by Android System for 12 minutes and 38 seconds in the 1 hour period it had been on battery power (see screenshot).  That's actually a lot.  If I stop syncing my work email, my battery life would improve considerably.

Not all components we see in the Battery Use screen may be obvious, so let me try to explain some of them.

Display is obvious: power spent to keep the screen on.  Android System does things like data syncing and VPN connectivity.  Wi-Fi is the power used to be on wi-fi networks, including the energy spent to search for wi-fi network availability.  If I know I am going to be in a place with no wi-fi networks around for an extended period of time, I turn off wi-fi on the phone.

Android OS is the energy taken by Android OS itself for its housekeeping.  Phone idle is the power used by the phone to keep it running while it's sleeping.  Usually Android OS and Phone idle are at the bottom of the list, i.e. they use very less power.  If they show up in the top (and you have been using the phone for some time), something is probably wrong.  On the other hand, if your phone has been sleeping most of the time, these components would be in the top because there wasn't anything else happening.  When that happens you would have a lot of juice left in the battery too.

Cell standby is the time taken to keep your cellphone connectivity on.  (This does not include the energy spent on voice calls because voice calls are tracked separately.)  If I am traveling by road I'd be often going through places where there is no cellphone network.  My phone would keep searching for network and connect to any available network only to get disconnected a few minutes later.  When that happens, I have seen a good amount of energy being spent on Cell standby.  In those cases I turn off data connectivity (Settings > Wireless & networks > Mobile networks > Data enabled), and that really helps.

18 Jan 2011

Running a filter on text in clipboard

The power (or beauty, if you want to call it that way) of Unix command-line interface is not only because of the available commands, but also because of the way we can combine simple commands to do complex things.  Filters are a great example.  In the Unix world we can find many powerful commands that expose functionality that is available only to programs via APIs.  xsel is a great example.  With xsel command, we can inspect and manipulate the contents of clipboard from the command line.

I often have some text -- maybe in a simple text editor (like Kate or GEdit) or in the browser.  I want to use that text in a different program, but with some modifications applied to it.  For example I might want to convert all tab characters in that text to 2 spaces.  Today I wrote a one-line shell script (called run-on-clipboard) that would let me run any filter on the text in clipboard.  Here's the script:
# Runs a "filter" on clipboard contents.  Can be used to make arbitrary changes
# to the text in clipboard.  For example, to convert all tabs in the clipboard
# text to two spaces, you can run:
#    run-on-clipboard sed 's/\t/  /g'

xsel -b | "$@" | xsel -bi
To convert tabs to spaces, I would copy the original text into clipboard and run the following command from a terminal:
  run-on-clipboard sed 's/\t/  /g'
This would change the clipboard contents, so pressing Ctrl+V in any program now will paste the text with tabs replaced with spaces.

16 Jan 2011


I spent a few hours in Singapore yesterday, and this post is my first impressions.  Since this is my first visit to Singapore and it was really really short, many observations might be inaccurate.
  • The traffic is a lot more disciplined than India, but a little harsher than places like the USA or Australia.
  • My cab driver didn't ask me if I am going to domestic terminal or international.  Every passenger in the airport goes through immigration.  Phone calls to local numbers are free. Being a small country means you have to do it all different :)
  • The immigration officer was kinda rude.  He puts his finger on my passport and says "Indian passport holders are not allowed without a visa."  Well, another officer working for the same country told me that I can enter without a visa, and that's why I even stood in the queue.  This immigration officer said "This is doable only once, and you cannot enter like this anymore.  Do I make myself clear?"  He stamps my passport as if he's doing me a favour.  Just do what's written in your rules book, officer... you don't have to be rude to people.  Nor do you have to do favours.
  • Singapore airport is probably the largest shopping mall in Singapore.  Sadly though terminal 2 didn't have a lot of electronic gadgets shops.  But then, there was Starbucks so I cannot complain much :)
  • Because they encourage shopping so much, finding space for cabin baggage is almost always difficult in flights going to India from Singapore.
  • After being in Sydney for two weeks, Singapore did feel hot.  I didn't say anything when Nags The Cook said that the weather was unusually cooler that day :)
  • There are free internet counters everywhere in Singapore airport.  It was disheartening to see people access their email and Facebook accounts from these machines.  (Well, to be fair, I know I was comfortable opening my Gmail account on the same machines 4 years ago.)
  • Singapore airport has the best toilets I have seen in any airport.  They are super clean and designed with travelers in mind (very "usable" would be the jargon).
5 minutes before my flight's departure time, they announced that our flight had an engine problem and asked us to board from a different gate.  It would have been more interesting if they had found it after the flight had taken off.  Maybe I would have seen how emergency landing is done and all :)

10 Jan 2011

How to conspire using Twitter

Let's say you are a group of people super concerned about your anonymity and privacy.  But you are working towards a common goal (like WikiLeaks, for example) so you have to communicate among yourselves.  Of course you don't want anyone to know that you are communicating.  If one person in the group gets caught, finding others should be almost impossible.  How'd you do that?

One naive way is to use Twitter.  Come up with an algorithm for determining a hash-tag for each day.  I.e., hash tag for Jan 11, 2011 will be different from the hash tag for Jan 12, 2011.  Everyone in the group knows this algorithm.  When one person has to send a message to others, they will tweet it with any Twitter account, but they will include the hash-tag of the day.  If I am part of the group, I can find the tweet.  It doesn't matter which account the tweet is coming from, so anyone in the group can change their Twitter handle whenever they want.  People can come and go, and nobody would know.

You know what I really like about this?  (i) You don't have to log into Twitter to search.  You can do a Twitter search in an incognito window in the morning and leave it open all day: you get all the messages from everyone, and no one knows you were receiving the messages.  (ii) Twitter is a good tool for this kind of communication because it throws away (or at least doesn't show to the whole world) old tweets.  Anyone who is trying to make sense of the pattern in the tweets can only dig for so many days in the past.


If we can ignore the few exceptions, all systems are designed by the majority, and naturally, designed to the convenience of the same majority.  When a minority finds it uncomfortable to be in such a system, they create a subsystem where they are the majority.  (Or they join an existing system where they can be majority.)

9 Jan 2011

Note to self: Don't fall for aesthetics again

It looks I will have to get a replacement laptop in a month or two, and every now and then I think of getting a MacBook.  Could be because of unintentional peer pressure.  Almost everyone in my company carries a MacBook around, so it won't be surprising if a part of mine is sold on the beauty of the machine.

Here I am going to enumerate the reasons why I should stick to a Linux machine -- or rather my past (bad) experiences with the Apple machine.  Just so that I don't fall for aesthetics again ;-)
  • MacBooks do not have Home, End, Page Up, and Page Down keys.  Command+arrows work in some programs, but not all.  Some programs might respond to Ctrl+arrows.  Bottom line is that no key combination can be programmed into my muscle memory, and I would be frustrated by the lack of productivity.
  • Apple believes that people run several different apps simultaneously, and that it's not common for a single app to have several open windows.  You'd press Command+Tab to switch between apps and after switching to the app you want to, you press Command+` to cycle between the windows of that app.  But I do pretty much everything on the browser, so technically I have only one app open with a dozen windows.  Suddenly, all I have is sequential access to my windows!
  • This might have improved by now, but when I used a MacBook about two years ago, the UI was mostly mouse-centric.  Some dialog boxes just cannot be closed with the keyboard, for example.  I am a keyboard warrior and I go out of my way to avoid using the mouse.
  • They still have the freezing problems.*  Not more than two weeks ago I saw a colleague trying super hard to bring his MacBook back to life after it got stuck somewhere.  The laptop would go to sleep, wake up, and do all that, but just won't let him do any work.  He had to power down the machine to get it back to working.  If they haven't fixed that problem in the past two years, I don't think they will fix it in the next few months.  No matter how brilliant the sleep indicator is, if the machine would lose my work I don't want it.
  • Mac OS has only one clipboard, which means I will have to explicitly copy stuff before I can paste.  I know there are people who get confused by X's primary selection and clipboard, but I am not one of them.  In fact, I love them.
  • I know there's a Mac App Store that may make it easy for me to find and install apps.  But hey, apt-get is a hundred times easier and it costs no money :-)
* I came up with this a few weeks ago: MacBooks are like ice cream.  Pleasant to look at and use, but frozen most of the times.

3 Jan 2011

Facebook Disconnect

When I open TechCruch, I see a Facebook widget on the page with a listing of my friends who have "liked" TechCrunch.  In addition to enabling me to connect with my friends, this widget tells Facebook every time I read something on TechCruch.  Facebook now knows that, e.g., I am more interested in Android than, say, FourSquare.  Facebook knows so much about me without my permission or willingness to share with Facebook.  Without getting anything from Facebook in return.

Of course, Facebook might show me more relevant ads.  Facebook might provide me a more personalized experience, sure.  But I am not sure if I trust Facebook enough to give that information about myself away.  Plus, I don't even open Facebook frequently nowadays.

Yesterday I was seeing a video about Facebook and privacy and it dawned on me that Facebook has been collecting my information for a long time now!  It's not that I am a privacy freak or anything.  I have been using Google Web History since the day it has been available, and I have found it useful.  Occasionally I search my Google web history to find a page that I once visited but forgotten its URL or search terms to find it again.

But Facebook is not like that.  I have no idea what Facebook will do with my data.  They don't even show me what URLs they have from my browsing history.  And I don't use Facebook as much for them to "personalize" my experience either.  So I went ahead and installed Facebook Disconnect on my Chrome.  I can always rethink my decision later, if there's a need.  For now, Facebook doesn't have to know what I am up to online.

2 Jan 2011

The Dancing Wu Li Masters

A good friend of mine gifted me The Dancing Wu Li Masters, a very fascinating book about "new physics", i.e. quantum mechanics.  I am on page 56, and book has already surprised me several times with the information in it.  It says:
Newtonian physics and quantum mechanics are partners in a double irony.  Newtonian physics is based upon the idea of laws which govern phenomena and the power inherent in understanding them, but it leads to impotence in the face of a Great Machine which is the universe.  Quantum mechanics is based upon the idea of minimal knowledge of future phenomena (we are limited to knowing probabilities) but it leads to the possibility that our reality is what we choose to make it.
(Don't worry much if this is not very clear to you... this one is explained over several pages in the book and it will be very clear if you are reading it in the book.)

In another place it quotes a book of Carl Jung on psychology, and the idea resembles what I saw in The Secret:
The psychological rule says that when an inner situation is not made conscious, it happens outside, as fate.  That is to say, when the individual remains undivided and does not become conscious of his inner contradictions, the world must perforce act out the conflict and be torn into opposite halves.
It's a very good read if you like science in general.

Scientists say it well

There are several ways a single thing can be explained.  But there are times when you look at some explanation and go wow.  I am gonna list some really cool explanations that I have heard.
  • The first such explanation I remember was given by a MySQL trainer.  He was talking about different data types and gave the best explanation I have heard of why floating point data in computers can be inaccurate.  He said that every data type in computers is finite, and there are infinite numbers between any two fractions, say 0.1 and 0.2.  So floating point representations hop through the interval including some values and skipping several values.  For instance, one implementation of float type might be able to only represent 0.1, 0.12, 0.14, 0.16, 0.18, and 0.2.  You simply cannot represent 0.17 using such a type.  (When using such a type, your computer cannot differentiate between 0.1734 and 0.1748; it will treat them as two equal numbers!)
  • Someone told me sometime back that if you keep applying the brake, it would eventually fail.  I looked it up on the web, and I found a curious explanation (I don't remember the source).  It said that while applying brake, we transform the kinetic energy from the wheel into heat energy.  When there isn't any more kinetic energy left to move the vehicle forward it stops.  (If we keep applying the brake, the brake will get so hot it cannot take any more heat from the wheel.  Since no energy is taken off the wheel the vehicle keeps moving.)
  • The Dancing Wu Li Masters says that no one has ever seen an atom.  To see if science has improved since then or still atoms cannot be seen, I did a Google search and found an answer Argonne National Laboratory's site.  The answer is more than 17 years old now, but the way scientists answer questions is interesting.  Arthur Smith of ANL says that atoms cannot be seen because all atoms are thousands of times smaller than the smallest light waves we can see using our eyes.  It conveys the idea directly that we don't see objects, but all we see is light.