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:
#!/bin/sh
#
# 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

Singapura

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.