Monday, December 15, 2008

append newline at end of files

Frequently when you download source code off the internet and try to compile, you end up getting a bunch of "warning: no newline at end of file" . to append a newline at the end of each *.c and *.h files use the following one liner.


find ./ \( -name "*.h" -o -name "*.cpp" \) -exec perl -i.bak -lpe 'print "\n" if eof' {} \;


ps: the space between the '{}' and '\;' at the end is required and there is no space in between "\;". else the follwing error occurs

find: missing argument to `-exec'

Monday, December 08, 2008

Sunglass

While this place has mostly computer related stuff, this time I just want to say if you are running a marathon and it is expected to be sunny, a sunglass helps a LOT. Not that I am a great runner or anything. But this time I was wearing one and in between at around 34 km or so, I took them off and boy the sun looked horrible and I can easily imagine it would be far more depressing without the sunglass. FWIW I shaved 1 hr and few minutes off my last years 7 hrs 15 mins time and I am sure the sunglass made some difference.

Monday, December 01, 2008

Resize an image using Imagemagick

you can just use convert to resize an image. Infact you can convert and resize in one go



convert infile.jpg -resize 10% outfile.png