Tuesday, May 6, 2008

Great strip from XKCD

This comic is really good, if you like this sort of thing.

Zealous Autoconfig

Permanent link to this comic: http://xkcd.com/416/

Wednesday, April 23, 2008

Leap of faith


The woods are lovely,
dark and deep,

Inviting me to take a peek

Keeping faith I take the leap

I break some promises,
satisfaction I reap

Wednesday, April 16, 2008

A script to remove spaces from a file name

I face a lot of problem while dealing with files with spaces in their names on the Unix platform. I wrote a script yesterday to change the spaces in a file name to undescores.

It is very useful for changing the names of all files in a directory along with directory names.

Save the script to your home directory or to /usr/bin or some such directory,

Go to the directory in which you want to effect the name change and run
# find . -depth -exec ~/rename.sh {} \;

This will rename all files in the directory so that the spaces in filenames are changed to underscores.

The script is as follows:

#!/bin/bash
#
# Writen by Mayuresh Phadke (mayuresh at gmail.com)# To change the names of all files in a directory including directory names
# run the command
#
# find . -depth -exec ~/rename.sh {} ;
#
# This command is pretty useful if you have a collection of songs or pictures transferred
# from your windows machine and you are finding it difficult to handle the
# spaces in the filenames on UNIX
#
#set -x

progname=`basename $0`

if [ $# != 1 ]
then
echo "Usage: $progname \"file name with spaces\""
echo
echo "This utility is useful for renaming files with spaces in the filename. Spaces in the filename are replaced with _"
echo "\"file name with spaces\" will be renamed to \"file_name_with_spaces\""
echo
exit 1
fi

old_name=$1
dir=`dirname "$1"`
file=`basename "$1"`

new_file=`echo $file|sed "s/ /_/g"`
new_name=$dir"/"$new_file

if [ "$old_name" != "$new_name" ]
then
mv "$old_name" "$new_name"
fi

exit 0

Please let me know if you find this useful/useless or if you have any other comments about it.

Wednesday, April 2, 2008

Tools for developing Dynamic Web Sites

I started developing web sites about an year ago. When I started out I did not know of any of the frameworks which make the job of developing a dynamic web site easy. I spent a lot of time finding tools which suited my need.

In this post I have listed the tools I use. It may help newbies by giving a reference point to start out their exploration.

LAMP Based

The base infrastructure is LAMP with a little deviation. I use Linux-Apache-MySQL-Python (instead of PHP).

For the uninitiated this means I run the Apache web server, with MySQL as my Database engine, on the Linux operating system. Python is used for generating dynamic web pages on the fly.

Framework for Dynamic pages

Django is used for generating dynamic web pages. Django lets you build high-performing, elegant Web applications quickly. Django focuses on automating as much as possible and adhering to the DRY principle. Django is very well documented and the online Django Book makes it very easy for anyone to start using Django quickly.

Frontend

I layout my pages using Blueprint. This is a CSS framework which allows you to have a great layout with very clean and simple code. List formatting is done with Listamatic. It provides a easy way to create great looking lists.

And of course there is AJAX. I use the excellent Prototype and Scriptaculous libraries to add Ajax to my site. These libraries make it easy to have cross browser compatible JavaScripts.

Conclusion

Using tools greatly reduces the work required to be done to develop a website. Choosing a framework/tool which suits you is the biggest task. Think carefully about what you want to achieve and what the tool provides. Use the one which matches your style and requirements.

Monday, March 24, 2008

Mahendra Singh Dhoni - Interview

'If there's commitment, that's victory for me'

India's one-day and Twenty20 captain looks back at six momentuous months in charge

Interview by Siddhartha Vaidyanathan and Nagraj Gollapudi

Read more here. Dhoni talks really well. He seems to be very clear about what he is doing.

Sunday, March 23, 2008

Travelling Salesman Problem

From http://xkcd.com/399/

XKCD Comic

Tuesday, January 22, 2008

Tranquility

Sitting in the park
by the roadside,
among multitudes
of vehicles and men,
Cacophony all around,
Cacophony in my head.

In the sky there's a red moon,
glowing silently with pleasure,
A tree outlined against the night sky,
Water playing in a fountain at leisure.

I journey to a different world,
there is no one except me,
Tranquility all around,
and Peace within me.

Sunday, January 20, 2008

What a match !

There is much more to cricket,
Than just boundaries and Wickets ...

The third match in the ongoing test series between India and Australia was an absorbing contest. There are many things that happened in the match that showed that just cannot be captured in an highlights package.

The best passage of play according to me was a nine over spell by rookie Ishant Sharma to one of the best batsmen of the world, Ricky Ponting. Sambit Bal describes this passage of play here.

Other things that stand out are,

Laxman's uncharacteristic workman like batting in the second innings, to help build the lead,

Pathan making a comeback to the test side and bowling beautifully to get the Aussie openers in both innings

Symonds walking off without a fuss after the umpire had adjudged him LBW of a thick inside edge

Symonds and Gilchrist's counter attack after Aussies were down in the dumps in the first innings ...

The list could go on, as I continue to re-live the match yet again in my minds eye.

Ishant sharma celebrating after getting Ponting's WicketIshant sharma celebrates

Wednesday, January 9, 2008

Django book

The long awaited Django book has been released. The book is now available in stores and online at http://www.djangobook.com/en/1.0/.

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Django was designed to make common Web-development tasks fast and easy. More info about Django can be found here http://www.djangoproject.com/.

Some reasons why you would want to choose Django as your Web framework:

Constructive reasons to use Django instead of Rails

ten reasons why you should use Django

I have been using Django for over six months now and can say that it is really easy to use and can get things done very fast.

Match Fixing?

Going back to the 2nd test match at SCG I keep wondering about the match fixing angle. No one yet seems to be publicly speaking about this. So I want to know why people do not feel that this is match fixing.

Arguments for match-fixing


  1. There were around 12 wrong decisions made in the match. ALL the decisions benefited  one team. If it would have been just a case of bad umpiring, the wrong decisions should have affected both sides equally.

  2. Umpires refusing to consult the third umpire for close calls.

  3. The third umpire giving a wrong decision. This is almost unheard of in cricket.

  4. Umpire consulting the Aussie Captain, Ricky Ponting on whether to give a batman out.

  5. If a player from either side had dropped 12 catches, wouldn't he be investigated for match fixing?


For me all these point to match fixing. Maybe I am missing something, maybe I am seeing only one side of the coin.

So all you pundits out there, is there another side to this? Is there any reason not to treat this match as fixed? Or are the umpires immune to match fixing charges?

Monday, January 7, 2008

Disgusting

The way cricket was played in the 2nd test match at SCG is plain disgusting. If what happened during the course of the match is not fixing, then I am not sure what is.

Umpire giving some wrong decisions can be understood, but what cannot be understood is all the wrong decisions going in favor of the same team, Australia in this case. Also the umpires are supposed to maintain law and order on the field. In this match law was what the Aussie players wanted. Ponting only had to raise his finger for the umpire to follow suit. A match which should have been won fair and square by India was ultimately won by Australia in a tight finish. Between them, Messrs Steve Bucknor and Mark Benson got as many 12 decisions wrong, an unacceptably high number, and that in the end, allowed Australia to eke out a 16th straight Test victory with at least 7 balls remaining in the game.



The ICC would do good to just strike this match off its record books and re-play the game with a set of untainted umpires. They should also start an inquiry regarding match fixing for this match.

The Indian team would do good to just walk out of this tour and return home. If the results of matches are pre-decided what's the point in playing the game?

Related Links:

Losing respect and getting under Ponting's collar

Sorry, Ricky, you don’t deserve to be trusted

Kumble questions OZ attitude

Dodgy deeds leave sour taste

The wrong decisions:


How they went wrong

Australia (1st innings)

  • Over 13.1, Ricky Ponting on 17 caught behind off Sourav Ganguly but given not out by Mark Benson. Australia 45/2

  • Over 29.5, Ponting given out lbw by Benson off thick inside-edge to Harbhajan Singh. 118/3- The one in favor of india

  • Over 46.4, Andrew Symonds on 30 caught behind off Ishant Sharma, given not out by Bucknor. 193/6. This has to be the worst. The edge was oh so clear !

  • Over 55.3, Symonds on 48 stumped off Harbhajan. Third umpire Oxenford rules him not out. 238/6

  • Over 73.3, Symonds on 106 lbw off Kumble. Benson rules not out. 314/7

  • Over 101.5, Symonds on 148 stumped off Harbhajan. Not even referred to TV umpire by Bucknor. 421/7


India (1st innings)

  • Over 12.3 Laxman on 16 lbw off Lee. Benson rules not out. India 25/1

  • Over 78.2 Sachin on 36 lbw off Clarke. Ruled not out by Benson. 293/3


Australia (2nd innings)

  • Over 41.1, Mike Hussey on 22 lbw to Kumble. Benson rules not out. Australia 133/2

  • Over 53.4, Hussey on 45. caught behind off R.P. Singh. Benson rule not out. 188/2


India (2nd innings)

  • Over 33.1, Dravid on 38 ruled out caught behind off Symonds by Bucknor. The ball had clearly hit thepad, and the bat and glove was totally tucked behind.

  • Over 40.2, Ganguly on 51, caught by Clarke off the ground. Benson rules out without referring to TV umpire.

Thursday, January 3, 2008

Dard-e-disco

When I first heard this song, I had dismissed it it as more more boring item number.

But then I heard it again and again on um teem TV channels and it started catching my fancy. And now I am a fan :) This one really takes the cake. The lyrics (by Javed Akhtar) and music (by Vishal Shekhar) and the rendering (by Sukhwinder Singh) ooze confidence. These guys seem to be enjoying every thing about the song.

The situation of the song in the movie (Om Shanti Om) is perfect. A handicapped hero (no hands, no legs, deaf, dumb and blind) has been ditched by his sweetheart. He needs to express is feelings in this situation. So how does he express the Dard (Pain)? Of course by doing a Dard-e-disco albeit in a dream sequence.

Kudos to all ppl involved in this song.

Tuesday, January 1, 2008

The Zen of Python

I liked this a lot. Programming philosophy that I believe in.

Taken from http://www.python.org/dev/peps/pep-0020/ Author: Tim Peters <tim at zope.com>

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!