Two days ago, as I switched on my computer, I got this error message; “A disk read error occurred. Press Ctrl + Alt + Del to restart”. It is the dreaded Black Screen of Death. The most probable reason for this message is that the hard disk on which the computer is booting would have crashed or its in the process of crashing.

The best you *must* do at this point is that, remove the faulty hard disk, connect it as a slave to another computer and take backup of all data. After data is safe, you can try and find out the point of failure. After all, that error message doesn’t necessarily mean that your disk has crashed.

Probable Points of Failure

  1. The bus connecting the hard disk to the mother board is faulty.
  2. The master boot record (MBR) on the hard disk got corrupted.
  3. SMPS (Switch Mode Power Supply) failure. In this case, your computer may not boot at all. But there are times when only one of the power plugs may fail.

If anyone has encountered any other points of failure, please let me know in comments and I will add them here.


  1. For the faulty bus, you can grab another bus cable from the secondary drives, connect it to the mother board with the faulty hard disk and try booting. If it works properly, head straight to the electronic store to get a new cable.
  2. To replace the corrupted MBR, pop in your operating system’s installation CD/DVD and follow the on-screen instructions. For Windows, boot in from the installation CD, press ‘R’ for recovery console, give your administrator password, and type the following the commands: fixboot, fixmbr. For linux, you must reinstall the boot loader (grub). Restart the computer now. If all is well, it should reboot properly.
  3. Remove the power plug connected to the faulty hard disk and connect one of the other plugs that are attached to the SMPS. Reboot the computer now and try.

In my case, my hard disk had crashed. But thankfully, I had proper backup of all data.

HttpURLConnection in the JDK has a bizarre bug. When it receives a HTTP response code in the 3xx range, it performs redirection to the web page mentioned in the “Location” header. However, when it does this, it forgets to send all the cookies with the request. Therefore, if you are working with any of the web 2.0 APIs which perform redirection and require this authentication cookie with each request, you are doomed because the server will redirect to the login page thinking that this is an unauthenticated request.

The solution for this is pretty simple. If you have written code like below:

URL u = new URL(“”);

HttpURLConnection conn = (HttpURLConnection) u.openConnection();

You have to add one more line that sets redirection to “FALSE” & do the redirection yourself with the cookies, which becomes like:

URL u = new URL(“”);

HttpURLConnection conn = (HttpURLConnection) u.openConnection();

conn.setInstanceFollowRedirects(false); // do not redirect

String locHeader = conn.getHeaderField(“Location”); // get the location

String cookies = conn.getHeaderField(“Set-Cookie”); // get the cookie

u = null; conn = null;

u = new URL(locHeader);

conn = (HttpURLConnection) u.openConnection();

conn.setRequestProperty(“Cookie”, cookies); // set the cookie yourself


Done! That should solve the bug. If this seems too much to do, then you should consider using this excellent HttpClient library from Apache.

I did the above mentioned stuff for this Free SMS Java Library because:

  1. The library has to be very small because it is just one file.
  2. Eliminate external dependencies that will bloat the library.
There you go! Now, if you have encountered this bug you have the solution to squash it. Have fun!

There are a number of use-cases for which you would want to browse a mobile-optimized website on your PC. When you visit the mobile website on your PC’s web browser, the website displays the full content much to your dismay. However, when you visit the browser on a mobile, it displays a perfectly mobile optimized page.

In these cases, there are some simple steps that you can follow to open mobile websites on your PC:

  1. Download and install the latest version Firefox from
  2. Visit Firefox Add-ons page and download the Modify Headers addon.
  3. Install the addon and restart firefox.
  4. From the firefox window, select “Tools” menu & click on “Modify Headers” option (Tools -> Modify Headers).
  5. The window will open as shown:
    Modify Headers Addon Window Click to enlarge
  6. Below the title bar, there’s a drop down. Select “Add” from the drop down box.
  7. Now in the text box next to the drop down, type “user-agent”.
  8. In the third text box, paste this string – Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE51-1/100.34.20; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413.
  9. Click on “Save”.
  10. The screen should look like as shown in the screen shot below:
    Filled screen of the addon Click to enlarge
  11. Using the buttons on the Modify Headers addon window, you can enable or disable particular items.
  12. That’s it! Whenever you want to view a mobile website, just go to Tools->Modify Headers and enable the user agent you added in step 8. When you don’t need it, just open this window and disable it.
  13. You can close addon window after you have enabled/disabled items.
  14. Enjoy! 🙂

Behind the Scenes:

Most mobile websites make use of the HTTP header called “User-Agent”. This header tells the server what kind of web browser the user has. So, mobile websites usually look for the name of the device manufacturer in the User-Agent header. If it matches one of the manufacturers then the mobile optimized web page is sent.

That’s about it! Hope you enjoyed this brief.

Now go and figure out how to display the iPhone version of Facebook on your PC 😉

Recently I needed a way for Threaded Tweets to do HTTP basic authentication to try out some stuff. As you probably know by now, it is written in javascript and uses no server side code. So, I had to find out some way to pass basic authentication credentials through the XMLHttpRequest object so that I could be authenticated with the Twitter server.

Turns out that it is pretty simple. If you use FireBug on any website that supports Basic Authentication, you will note that a new HTTP header called ‘Authorization’ is added. It looks like:

Authorization: Basic aDkdjfZy==

Now all you need to do is somehow pass on this header to the XMLHttpRequest object. If you use the native XMLHttpRequest, you can use the setRequestHeader method to do this:

xhr.setRequestHeader(“Authorization”, “Basic aDkdjfZy”);

What if you are using jQuery? Then also its pretty simple. jQuery’s AJAX object allows us to change the XHR object before the AJAX request is sent by setting the “beforeSend” callback; which is done as follows:

$.ajax ( {
url: “”,
beforeSend: function (xhr) { xhr.setRequestHeader (“Authorization”, “Basic aDkdjfZy==”); },
succes: function(val) { alert(val); } } );

Base 64 Encoding:

One important part of Basic Authentication is that, you need to encode the username and password into Base 64. There are tons of Base 64 encoding tools written on javascript, which you can use. Example below:

xhr.setRequestHeader(“Authorization”, “Basic ” + encodeBase64 (“username:password”) );

That’s about it. Hope this was useful to you !

Some Updates

Cross-domain GET requests work all the time. The problem is with POST requests. Most browsers don’t allow XHR to POST data to a domain that’s different from the one in which the page is loaded. For this to work correctly, the ‘document.domain’ property must be set correctly.

The second best way to POST to another domain is to use an iframe and submit the form with the iframe as the “target”. Again, to read the result of the iframe, the “document.domain” of the parent and that of the iframe should match. This can be easily set through javascript. Thus, when the form post is done and the page is loaded, its value can be accessed.

Note: Chrome and Safari don’t allow access to iframe’s DOM if its document.domain is different from that of the iframe’s parent.

That is a very common error that users generally encounter when packages are being compiled. Though the log files mention something bizarre, this error can be resolved quite easily by running the following command:

$ sudo apt-get install build-essential

That would do for most cases. Many programs also require a compiler-compiler called ‘bison’. You may install that also by giving,

$ sudo apt-get install bison

This would make sure “configure” scripts work properly.

Hide Menu Bar in Opera

December 18th, 2008

Menu Bar is such a waste of screen real estate in web browsers. There was no inbuilt preference in opera that would enable me to hide or show menu bar with a single key toggle. Opera allows the users to customize its keyboard shortcuts to a great extent. So, here’s how you go about toggling the menu bar in opera.

  1. Go to Tools -> Preferences.
  2. Click the “Advanced” tab.
  3. Select “Shortcuts” from the left side menu.
  4. Select “Opera Standard” under “Keyboard Setup” and click on “Edit” button.
  5. From the “Edit Keyboard Window” popup, select “Application” and then on “New” button.
  6. Now type “F10” without quotes, press Tab key & then type “Enable menu bar | Disable menu bar” without quotes.
  7. Now click “OK” button on both the windows.


Threaded Tweets

December 6th, 2008

Update: Check out the conversations that were generated using this tool 🙂

Have you had a tough time following a conversation on twitter? Only to find that a frustrated you had to wait until the last tweet in the thread was done and then you navigated through the replies backwards. Not anymore 😀

Visit and give the last twitter ID in the whole conversation list & watch as the page gets populated with tweets in the order in which they were posted.

This was quickly hacked up in an hour & hence its kinda very rough. Kindly use this and give me feedback.



December 1st, 2008

Hey guys, thanks to Sudar I came to know about Webbynode.

Its a new linux based VPS service that lets you host your django, rails and other LAMP based apps with full root access to your VPS. Moreover, there are ready-to-deploy stacks for RoR, django and LAMP. Do check them out at

As of now, what I feel lacking from their website are the number of technical articles. Just see how many Slicehost has and you will know. Guess they will surely follow up with more as they launch.

Hello friends! Barcamp Chennai 2 was superb! It was 2 days of fun. What was surprising this time is the sheer number of new faces in the crowd and the number of non-tech sessions. The non-tech sessions were high this time, though the tech sessions were pretty basic ones. Lots of networking happened this time and I came across a really cool bunch of people with whom I will be in touch.

Day 1

Yesterday morning, I attended a session on Git, by Sreeni from ThoughtWorks. Its a source control system which was developed by Linus Torvalds. I recently signed up at GitHub to host the SMS Web Service program & this session was really very helpful in getting me started. Next session was intro to Ruby on Rails by Prakash from ThoughtWorks (this was in a different track). Most of the hall roared with laughter when one of the campers asked what the difference between Rails and Javascript. Hmm! With this question I came out of the hall and met Kausik, Bharadwaj, Moyeen, KAPP, Shyam and a few more guys. We were discussing about programming languages, mainly about python and various IDEs. I also struck a deal with Shyam to collaborate on an open source mobile project. More details about it will be available soon.

By the time we finished our discussion on the hallways, it was lunch time and we headed to Tiffanys. We ragged Moyeen 😀 about his GF and stuff. Moyeen is a good sport you see 🙂 so we had a nice time. Post lunch, there was a session on linux kernel basics and then came the best session of the day.

It was on Open Street Maps by a final year engineering student named Arun Ganesh. Open Street Maps is a community effort to map out the whole world. A wikipedia of sort for mapping. Arun had done some seriously good tasks of mapping out Teynampet & sharing it with the post offices in his area to get it validated. He also pointed out that, where Google or Yahoo maps take a few years to map changes in locality, those changes are reflected relatively immediately on OSM. That’s mainly because of the volunteers who edit the maps on a day-to-day basis. Unlike Google or Yahoo maps, OSM allows you to change the underlying mapping data itself, which is pretty cool. When Arun showed the OSM website on his browser, someone asked what the software was 🙂 The audience brought the ceiling down by laughing. I was pondering about building a mobile software for displaying OSM on Symbian mobiles. Interested anyone? I may start this in a couple of month’s time.

My session on the recent “Assign Categories” wordpress plugin was next. Response was good 🙂 and I’m happy. After this, there was a session on web 2.0 (old stuff?) but then, myself and a few others used the law of two feet and discussed various other topics between cups of coffee. I also answered a few questions on my wordpress plugin during this time. Day 1 came to an end with this.

Day 2

Today was superb I should say. The first session was from Viru [viru {at} physicssociety {dot} com] about “Indian Education System Sucks”. The word ‘s**ks’ provoked the audience very much and what followed was very hot debate with a few solutions to the current problems. Solutions being that students should be allowed to ask questions and teachers should encourage that. Also, more amount of practicals should be introduced in the curriculum for understanding the subjects better rather than mugging up. I believe CBSE has solved part of the problem here. By making the syllabus huge, they have effectively discouraged students from mugging up & vomiting. So, to answer questions in the exams, they have to understand the subject well; else they flunk. There are lots of side effects to this. But we will discuss it some other time.

Second session was on “Global Financial Meltdown” by Syed, Sukumar and Ganesh (of Rupya). It was superb. Though I did follow the news on the financial meltdown, I learnt a lot from the discussion. One specific portion that still stays fresh is the news that India Inc. is spending Rupees 1 Lakh Crore to help the failing banks. They are buying stock at a discounted rate and imagine the returns when the meltdown ends! 🙂 . There was also a small discussion on how it affects the IT industry. Software service companies have to be on watch was a view that was shared by everyone.

Post lunch, the talk was on “Disaster Management”. Since Mr. Mani, DSP of Police couldn’t turn up, it turned into a fun group discussion. The hall applauded when Sukumar advised the campers to take “good care” of our lives. Point well taken.

After this it was time for our discussion using the law of 2 feet & then it was time for Thomas’ session on “How to become an innovator”. Crux of the talk is that, you have to condition your mind in to thinking out of the box and he recommends the books written by Edward De Bono. Siddhi‘s session on creating a really good office space was enlightening as well. On the whole, Day 2 rocked and I learnt plenty of things today.


Wifi sucked 🙁 Most of the time, it didn’t connect. Wifi Gurus are most welcome to share gyan on how to setup a reliable wifi for (un)conferences. May be this would have been a great session at Barcamp.


Please search for BCC2 or BarcampChennai on Flickr and other places.

Crowd size was optimum this time, which made the sessions all the more interactive. Were you there and I missed talking to you? If so, please drop a comment and I will get back in touch with you. Thanks!

Barcamp Chennai Logo

Yay! barcamp chennai second edition is happening today and tomorrow at IIT Madras in the IC & SR auditorium. The previous barcamp was truly awesome and I sincerely hope, this one will also meet the expectations. There are lots of interesting talks lined up and whats even more interesting is that, there are lots of new faces this time :D 

We are also planning for an all-night code camp for tonight. If its happening, I will post more details about it here. If you are attending, do let me know. I will be around. For more details about barcamp, check out

If you are taking pics/videos/tweeting about the event, use the tag “BCC2”. That would make it easier to search and find the relevant pics, blog posts and videos.

See you there!