Sunday, December 21, 2008

Screenshots of some useful Linux apps

Note: this is not a countdown. This is not even a countup.

1. Disk usage analyser:
This application shows how the disk space is being utilized among various files and folders in your system. It also includes a graphical, nested pie chart which shows in a straightforward manner how your disk is being used.

2. Amarok:
Amarok is one of the better of the (30+) music players available for Linux.
While the UI of Amarok has actually been criticized for being too clunky or something, I personally think this looks good. My only complaint is that between version 1 and version 2 the app seems to have misplaced its graphic equalizer.

3. Clock:
This is the default clock available in gnome. This sits as a time display on your task bar, until you click on it. Then, it displays a calendar, a world map with night/day shown, and local times and weather of any locations you add to it.

4. Brasero:
Brasero gives you a very simple interface to create and burn any type of cd/dvd/.

5. Panel monitors:
You can add applets to the panel which monitor CPU usage, Memory, Network usage, etc. I have set this up as something which becomes visible on mouseover.
Note the time on the analog clock: this was actually taken after the screen shot where it said 5:05 pm. In this one it's 5:15:27 pm; the second hand is hiding the hour hand.

oh yeah, btw, check out my wallpaper!

Sunday, December 14, 2008

Fun with Linux (Too technical, you can skip this)

The best thing about linux is that you always discover new things while working with it. For example, I recently discovered that you can open GUI windows from the shell prompt by using a command called zenity. This was very interesting as it widens the gap between console programming (which every student is taught) and GUI programming (which a developer has to know to make anything useful) considerably.

Now I could do stuff like display my own notifications:


This was done by a simple command like this:
zenity --info --text "Hello World"

but of course, a window showing "Hello World" is not very useful.

Ever wonder why all computer language books give a "hello world" program as their first example? I mean who wants a program that says hello world and does nothing else? See, this is not the way to attract potential new programmers to the world of coding...


So, anyway, I decided to make a practical app to see what I can do with this... but what to do? I got the idea after piping the output of ps to a text box:



Hmm, I could make my own process manager, which would be a most rudimentary app to hunt and kill processes running. The element I would be using is a list box (zenity --list). This unfortunately does not allow output to be piped in. So I had to write a perl script which converts stdin to command line option for a zenity list:


#!/usr/bin/perl -w
use strict;
use Data::Dumper;

#my $seperator="\t"; #TODO: pass this as command line option.
my @columns;

my $line = <stdin>; #Input comes from standard input. Caller should redirect.
chomp $line;
$line =~ s/^\s+//;
@columns = split (/\s+/, $line);

my $columnCount = $#columns;

foreach my $column (@columns) {
print qq{ --column $column };
}

while ($line = <stdin>) {
chomp $line;
print qq{FALSE $line };
}
The alert reader will notice that this script will convert any tabular input into command line option for a zenity list - maximum reusability!

All that remains is to pipe the out of ps and take the output of zenity as parameter for kill:


#!/bin/bash
listWindow() {
psParams=pid,ppid,comm,time,pcpu,stat #Edit this to modify columns
zenity --list --text="Select the processes to kill:" --width 640 --height 480 --checklist --separator=" " --column Select \
$(ps -u $USER -o $psParams\
| tee >(zenity --progress --pulsate --auto-close)|perl /home/prasanna/bin/mkzenitylist.pl)
}

pid=$(listWindow)
while [[ -n "${pid}" ]]; do
zenity --question --text "Really kill processes with pids: $pid?" && (kill $pid ||
for i in $pid; do
if ps p $i >/dev/null 2>/dev/null; then
zenity --question --text "$i did not die: force kill?" && kill -9 $i
fi
done)
pid=$(listWindow)
done
Voila! One task manager ready! On launching, the first screen looks something like this:
Let's say I select 'gedit' and click ok:
Clicking ok will kill the process, and take me back to first screen. Clicking cancel would take me back to the original screen without killing anything.

This obviously is not the best process manager you can think of; It's not even real time (I certainly don't use this - I use the default task manager that comes with the OS :) )
But, it is nevertheless, usable. And that was the point of this exercise: to make a GUI app that is simple and usable in a real world scenario.

Saturday, November 29, 2008

The Thanksgiving 2008 Incident

Or the Mumbai Terror Attacks. Or India's 9/11. Or as it is written here, 29/11.

10 men held a whole city at siege for 50 hours.

125 Dead. 300+ Wounded. 8 landmarks scorched.

Black Cat Commandos, who were till now a bunch despised for guarding corrupt politicians, finally proved their mettle through a test of fire. Their effective and powerful handling of the incident has impressed not only all Indians, but also people all over the world. Indeed, one backhanded compliment from a typical self absorbed blog commenter was that he believed these were not Indian Commandos, but people flown in from US or Israel. I am not going to reference link that guy here and give him the attention he wants. I would have loved to see his reaction though, when the commander of the commandos started talking in a Punjabi accent...

The government employees of Mumbai also proved their worth. Police officers laid their lives to protect the citizens of Mumbai. It is quite easy to claim that you will sacrifice your life to protect others. To actually follow through on that claim, after you have seen your coworkers dying and wounded, is true courage. The firemen who put out all fires, the doctors who selflessly gave up their nights and weekends, and still continue to do so. The true test of any system is to see how it stands up against a catastrophic failure. Mumbai's system has time and again stood up to this test.

The politicians of India, as usual, came across as predictable and clueless. "Our condolences" and "It was Pakistan" were the first things we heard; but we knew they were going to say that. And the worst part is, it's mostly true, but because politicians always have that snap reaction, you just cannot trust them on it. But then you can rarely trust politicians anyway...
Pakistan's leaders of course denied everything. Also very predictable.

I haven't been in Mumbai for about 4 years now. I don't think of myself as someone from Mumbai. But suddenly when I heard the news, I started to think of myself as a Mumbaikar. I told myself, "don't be emotional". It didn't work.

My emotions are mixed about this.

On one hand I am impressed by the fact that 10 men brought a whole city to a standstill for more than two days. That's badass.

On the other, my blood calls for vendetta. I want everyone who was behind this hunted to the ends of the earth and killed. No courts. No trials. I'm thinking Munich-style executions.

An intellectual part of me says violence will only lead to more violence. Another part of me says, if nonviolence cannot bring about peace, then violence is the only answer.

And when thoughts are finished, questions remain. We need to know more than we know.

Who did this?

How did they manage to do it?

Why couldn't we stop them in time?

What are we going to do if they do this again tomorrow?

What is the price in freedom that we will have to eventually pay out to ensure our safety?

Are we ever going to be safe?

I'm still looking for the answers.

Wednesday, November 26, 2008

Linux/Vista Rant

Most of my acquaintances are surprised to hear a use Linux on my laptop full time. "Really? All the time? Why?" is the most common reaction. I could go on about modern operating system, security, scalability, bleeding edge technology, blah blah blah but that would be a waste of both of our times. So I give out a simpler answer.
"Vista", I say. They then understand.

Everybody knows Vista is slow. But what surprised me is that after using Linux, I found the XP system at my office slow.
Now before you say it, let me tell you my office desktop is a decent system. And I wasn't playing games on it, or watching movies, just office stuff. The occasional web surfing or gmail checking.

'Occasional' can be made to mean different things.

Anyway, I then realized that what I was looking at to see how fast a computer is, is not the speed at which programs are actually executed, but how fast it gets back to me. I click an icon in Linux, the cursor starts spinning. Soon my application is launched. At all points you get all onHover events. You click an icon in XP, the cursor turns into an hourglass. Then, depending on the application, it is either launched immediately, or takes some time.

Openoffice.org does that on Linux, but come on... why would I be doing office stuff on my personal laptop?

You click an icon in Vista, and nothing happens. Then the cursor starts spinning. Then the application is launched.

Vista rated my laptop a '2.8 out of 5' on performance. Well Mr Vista, If my laptop can run compiz, If it can run 3 virtual machines in parallel, then it to be more than '2.8 out of f***ing 5'.

And this is the thing I hate most about Vista; as soon as I switch it on, what do I see? "Please do not turn your computer off". As soon as I turn it on. Everytime. What does this tell you about the rest of the sytem?

Friday, November 21, 2008

Second post: Buying my first car

So I haven't updated my blog in forever, and thought now would be a good time to do so...

Let me start with something many people have to do when they come here to US: how to buy a car.
There may be variations and iterations, but the general procedure goes something like this:

  • Look for a car: There are various media for looking for a car. There are bound to ads in the classified sections of your local newspaper. Here, in the Columbus Dispatch the car ads used to come on Wednesday. There are also websites where people can post ads. I referred Craigslist (http://www.craigslist.com).
  • Shortlist cars: Do a price range search for all cars. I find that 3500 - 5500 works out best. You get decent quality cars without getting a model too expensive. Most people prefer Japanese models (Nissan, Toyota & Honda); I ultimately bought a Chevy and it seems to be doing OK.
  • Compare price: A website like Kelly's Blue Book (http://kbb.com) lists out reasonable asking prices of all models of all cars. Ideally the asking price in the classified ad should be about ~$500 within what is mentioned in KBB. However there are a few caveats you should be aware of: 1) When an ad poster says "Excellent condition" it means "good condition". "good condition" means "fair condition" and so on. 2) An asking price may be higher than KBB because the car has more accessories. Beware: you may be getting an absolute lemon with an absolutely state of the art stereo. This actually happened to a friend of mine. 3) If an ad is asking too low a price, ask yourself "why?". Better still, ask that guy. Some may have legitimate reason for selling too low. Most don't.
  • Get the car history: This is the point where you have to shell out some money. For about 18$ you can get an account at www.carfax.com which will allow you to get the complete accident history of any car; their database is updated by police and insurance agents. This account only lasts a month, however. To get the history of a car, you need the Vehicle Identification Number (VIN). If the ad post has the VIN number, well and good. If it doesn't call up the number given in the ad (if the ad has no telephone number, forget it). The seller will give you the VIN of his car. If he doesn't be rightly suspicious and end the transaction right there.
  • Look at the car: If the car has a clean enough history, ask to meet with the seller. Sometimes a look at the car will reveal what the photo in the ad didn't; scrathes on the other side, paint peeling off, etc. Ask for a test drive, so that you can decide if the car handles OK. If at any point the seller declines, he has something to hide.
  • Have the car checked up: To those of you who are car experts, good for you; but let's face it. Most of us aren't. That's why you need to get the car checked by an expert. Most car sellers will be OK with this; they will only quibble if you try to foot the bill of the checkup on them. Some smart sellers can actually get the car checked themselves by a reputed garage, and show the report to potential buyers. This saves time and money of both parties.
  • Haggle: Provided the car checks out OK till now, haggle the price with the seller. At this point it helps if you have an experienced bargainer at your side. Points to haggle over are sunroof (moonroof?), tires, stereos (can they play mp3s?) and such like. Of course if there's an obvious shortcoming in the car (maybe it shakes from side to side) and you are still buying it, that would be a good point to start. But since you are anyway buying despite that, sellers won't give on such a point.
  • Cash or cheque? Cash. Nobody accepts cheques from strangers. Try your best to convince the seller that your cheque is good, but be prepared to pay cash in the end.
  • Tax: If the seller writes 'gift' on the title deed, you get the car tax free; this is probably illegal. I would have done it anyway, but I had to pay my tax in full. Try to see if the seller is ready to share the tax (I wouldn't if I was selling).
An important step while buying is to make sure that the VIN of the vehicle matches the VIN the seller had given you initially (and the VIN on the title deed). This can avoid a potentially embarrassing situation where the cops stop you for driving a stolen car.

This seems like a straightforward step by step process. But in reality it is a loop, with multiple exit points. I've had the following happen to me:

  • Seller was selling the car because he didn't need the car. He suddenly decides he needs the car again. Coincidentally, this is right after I tell him I want to get the car checked at Firestone.
  • Seller lets me check the car out for 20 $ at firestone. He then sells the car to his friend with my report, and doesn't give me my 20 bucks back. I hope that faulty tie rod broke on that Nissan Altima and you crashed, you bastard.
  • Seller refuses to give phone number.
  • Seller refuses to give VIN.
  • Seller refuses to have the car checked.
  • Seller is very cooperative and friendly. His car has 195000 miles on it.
  • Seller refuses to give VIN. This was a different seller.
  • Seller manages to sell me a Chevrolet with a passenger door that doesn't open without force. He poses as a private seller; turns out his "brother" is a car dealer.
I bought that last car. I was actually in a desperate vehicle situation at that point. Otherwise I'm sure I could come up with more examples of enterprising car sellers.

It could also happen that when you get posted onsite, someone from onsite is leaving back to the home country. You get their car, and since you are the new guy, they help you throughout the process (maybe they even get the car checked by some other sucker). Sure it's convenient, but who would want to do things in such a boring fashion?

Thursday, August 23, 2007

first blog

Testing. Will probably delete this entry. If I remember.