Corrupt superblock? Recover ext2/ext3/ext4 filesystem data

diskMy build VM got corrupt today and I was on the verge of losing my temporary changes scattered across 4 different code branches. I googled a while for a solution and and I found the following links very useful:

Additionally, using TestDisk I was able to copy all my modified code even before I tried fixing the disk. TestDisk came to my rescue once before as well when my 1 TB NTFS formatted externally powered disk was not getting detected anywhere.

Another interesting article on how to handle bad blocks on hard disk.

George Bernard Shaw: The Sources of Idealism

coffee_compOne of the highly acclaimed essays by the great iconoclast J. B. Shaw. I read it after a long time online here. It is such a pleasure to read Shaw. As my sister once told me – his works are like an avalanche of strong shocks. Be warned that it is always complex and needs patience to understand him. After all, he is the one who could say– “The power of accurate observation is frequently called cynicism by those who don’t have it.”

The Jargon File: all about hacker slang

tux_compFun and interesting facts about the Nerdvana:
The Jargon File

Here’s a list of the commonly used expressions:
AFAIK = As Far As I Know
AKA = Also Known As
ASAP = As Soon As Possible
BTW = By The Way (used to introduce some piece of information or question that is on a different topic but may be of interest)
COLA = comp.os.linux.announce (newsgroup)
ETA = Estimated Time of Arrival
FAQ = Frequently Asked Question
FUD = Fear, Uncertainty and Doubt
FWIW = For What It’s Worth
FYI = For Your Information
IANAL = I Am Not A Lawyer
IIRC = If I Recall Correctly
IMHO = In My Humble Opinion
IMNSHO = In My Not-So-Humble Opinion
IOW = In Other Words
LART = Luser Attitude Readjustment Tool (quoting Al Viro: “Anything you use to forcibly implant the clue into the place where luser’s head is”)
LUSER = pronounced “loser”, a user who is considered to indeed be a loser (idiot, drongo, wanker, dim-wit, fool, etc.)
OTOH = On The Other Hand
PEBKAC = Problem Exists Between Keyboard And Chair
ROTFL = Rolling On The Floor Laughing
RSN = Real Soon Now
RTFM = Read The Fucking Manual (original definition) or Read The Fine Manual (if you want to pretend to be polite)
TANSTAAFL = There Ain’t No Such Thing As A Free Lunch (contributed by David Niemi, quoting Robert Heinlein in his science fiction novel ‘The Moon is a Harsh Mistress’)
THX = Thanks (thank you)
TIA = Thanks In Advance
WIP = Work In Progress
WRT = With Respect To

Which programming language to start with?

hacker_compThis is an eternal question dug over and over during engineering graduation days. IMHO, it’s best to start with C. It is a very rich language and is more powerful than any other non-obscure 😉 programming language ever written. Many other programming languages are written based on C. It is not very difficult to learn new programming languages when you already are well-versed in one. In my personal experience, I studied for 15 days and scored 98% in SCJP then conducted by SUN Microsystems. I haven’t worked regularly in JAVA since 5 years but even today it doesn’t block me from looking into a piece of JAVA code or reviewing them. The truth is – learning a language doesn’t matter if you know only the syntax and features of the language, a complete understanding of how to convert any logic into that language in the best possible way is required. It takes minimum 6 years for a good programmer to claim that he knows C (or any other language) well. One more point to remember here is – if you are interested in systems programming it’s better to marry C ;); C++, JAVA etc. are engineered more towards customer requirement oriented rapid application development. I mean business, not elegance.

New programming slangs

cool_penguin_smallA collection of exotic new expressions for regularly faced situations. For example, last week I had to tell a 5-yr experienced developer to RTFM when he dragged me to his desk to ask why the files from his test rpm are not able to overwrite the ones from the already installed package and is throwing conflict messages. Once I read a manager fired his developer because he did not know how to redirect a program’s error messages from the console to a file.

I loved the “Drug Report” and “Fear Driven Development” most. How about you?

Dijkstra's railway car toilet parable

Hilarious and enjoyable. Read on…

(Recently I found the following text in manuscript among old papers of mine. It must have been written in the middle of 1973, but I don’t think that in the intervening three years it has lost anything of its significance. Hence I now incorporate it in the EWD-series.)

A parable.

Years ago a railway company was erected and one of its directors —probably the commercial bloke— discovered that the initial investments could be reduced significantly if only fifty percent of the cars would be equipped with a toilet, and, therefore, so was decided.

Shortly after the company had started its operations, however, complaints about the toilets came pouring in. An investigation was carried out and revealed that the obvious thing had happened: despite its youth the company was already suffering from internal communication problems, for the director’s decision on the toilets had not been transmitted to the shunting yard, where all cars were treated as equivalent, and, as a result, sometimes trains were composed with hardly any toilets at all.

In order to solve the problem, a bit of information was associated with each car, telling whether it was a car with or without a toilet, and the shunting yard was instructed to compose trains with the numbers of cars of both types as equal as possible. It was a complication for the shunting yard, but, once it had been solved, the people responsible for the shunting procedures were quite proud that they could manage it.

When the new shunting procedures had been made effective, however, complaints about the toilets continued. A new investigation was carried out and then it transpired that, although in each train about half the cars had indeed toilets, sometimes trains were composed with nearly all toilets in one half of the train. In order to remedy the situation, new instructions were issued, prescribing that cars with and cars without toilets should alternate. This was a more severe complication for the shunting people, but after some initial grumbling, eventually they managed.

Complaints, however, continued and the reason turned out to be that, as the cars with toilets had their toilet at one of their ends, the distance between two successive toilets in the train could still be nearly three car lengths, and for mothers with children in urgent need —and perhaps even luggage piled up in the corridors— this still could lead to disasters. As a result, the cars with toilets got another bit of information attached to them, making them into directed objects, and the new instructions were, that in each train the cars with toilets should have the same orientation. This time, the new instructions for the shunting yard were received with less than enthusiasm, for the number of turntables was hardly sufficient; to be quite fair to the shunting people we must even admit that according to all reasonable standards, the number of turntables was insufficient, and it was only by virtue of the most cunning ingenuity, that they could just manage.

With all toilets equally spaced along the train the company felt confident that now everything was alright, but passengers continued to complain: although no passenger was more than a car length away from the nearest toilet, passengers (in urgent need) did not know in which direction to start their stumbling itinerary along the corridor! To solve this problem, arrows saying “TOILET” were fixed in all corridors, thereby also making the other half of the cars into directed objects that should be properly oriented by the shunting procedures.

When the new instruction reached the shunting yard, they created an atmosphere ranging from despair to revolt: it just couldn’t be done! At that critical moment a man whose name has been forgotten and shall never be traced, made the following observation. When each car with a toilet was coupled, from now until eternity, at its toileted end with a car without a toilet, from then onwards the shunting yard, instead of dealing with N directed cars of two types, could deal with N/2 identical units that, to all intents and purposes, could be regarded as symmetrical. And this observation solved all shunting problems at the modest price of, firstly sticking to trains with an even number of cars only —the few additional cars needed for that could be paid out of the initial savings effected by the commercial bloke!— and, secondly, slightly cheating with regard to the equal spacing of the toilets. But, after all, who cares about the last three feet?

Although at the time that this story took place, mankind was not blessed yet with automatic computers, our anonymous man who found this solution deserves to be called the world’s first competent programmer.

*         *         *

I have told the above story to different audiences. Programmers, as a rule, are delighted by it, and managers, invariably, get more and more annoyed as the story progresses; true mathematicians, however, fail to see the point.

Plataanstraat 5
The Netherlands
prof.dr.Edsger W.Dijkstra
Burroughs Research Fellow

Source. All the transcriptions. The collection is invaluable.

Android handwriting recognition software

android_compOne of the things I miss most in Android in spite of all its goodness is a good handwriting recognition software. The ones I found either need the stylus or support OEMs only. Thinking of writing one with support for finger touch and releasing it as an app in the Android Market but don’t have all the time required to spend on it. Anyone interested is welcome. I have a rough sketch of the algorithm and can proceed with it.

Update: Google Gesture Search recognizes handwriting on Android.

Hacking broadband on Linux


1. To check my actual network IP address:
2. A dictionary of common router passwords:
3. nmap and whois tools available in Linux. [Try “nmap –help” for quick description of the switches available. whois is self-explanatory.]


If users do not take necessary precautions, it’s too easy to reach the router settings of broadband users.

First I checked my actual IP address @
I found that it is

So I ran nmap on this range on port 80:

$ nmap -p80 > scanres

I opened the file scanres in vi and searched for “open”. I found the following entries:


In order to check some more information like who the IP belongs to, I used:

$ whois

Now I have got a vulnerable IP with port 80 open. I tried opening it in Firefox and it asked for the username and pwd:


I tried out default usernames and pwds for some common routers in India from and I could hack into the router in 4/5 tries. [Sometimes the authentication string shows the make of the router. For example TD-W8901G means a TP-Link router, IB-xxxxx means an IBall router. Some manufacturers must be real dumb to do it!] I entered the Interface Setup and could find the PPPoE username. And an 8-dot password almost always means “password”. As users have no way of changing it, the “password” is as good as hard-coded.


Finding a weak router will take around 40 seconds for a seasoned hacker who will reduce the IP range +/-25 his own IP as the nmap scan range.