Convert a set of Images to a Youtube Video (PNV->AVI->FLV)

If you have a set of png files, let say screenshots of a new application you have created and you want to convert them into a video, then this is how you do it.

mencoder "mf://*.png" -mf fps=0.5 -ovc lavc -lavcopts vhq:vbitrate=1500 -o video.avi
ffmpeg -i video.avi -b 2028k -s 320x480 -r 30 -acodec copy video.flv

This first command will convert the png files in your present directory into an avi file. The second one will convert it from avi to flv. FLV is the format used by youtube.

Single Keyboard Shortcut to Launch/Raise an Application

I have recently shifted from KDE4 to Gnome3. In KDE you can create application specific keyboard shortcuts to raise windows. I typically create one each for Firefox, Thunderbird, my terminal etc. That way switching between windows is lightning quick. Gnome doesn’t seem to have that kind of functionality. So I asked on unix stackexchange, if there is a way to achieve the functionality. The clue was to use wmctrl.
Continue reading

Adsense Client – Simple Adsense Application for your Android Phone

Introducing “Adsense Client” – a new Android application I have created to help you track your Adsense Earnings on the go. I have been look for a decent application to track my Adsense Earnings. However all the free applications are severely limited and do not offer even the basic functionalities and hence I decided to make one of my own. This is my first attempt at making a full fledged Android application. I have tested this application across all Android software versions greater than 1.5. This application won’t work for Android s/w versions less than 1.5. Continue reading

Ruby 1.9.2 Final Build for Ubuntu, Kubuntu Maverick (10.10) Uploaded to Launchpad PPA

Sometime back I added the final ruby 1.9.2 build for Ubuntu Lucid. I have recompiled the same for Maverick today and have uploaded it to the ppa. Along with the ruby1.9.2 packages I have uploaded the ruby-default package too. This setups the update-alternatives system for different ruby versions. Read more about it here. Continue reading

XSL template for Generating Per Page TOC for Docbook HTML Output

Sometime back I worked on this upcoming Ruby On Rails Book and helped the author convert his docbook to various formats like HTML, PDF, EPUB, Kindle etc. While working with the HTML output, I figured that the standard output spewed out by the Docbook XSL stylesheets is quite boring. So I improvised a lil, added per page TOC, pretty css, icons etc. I spent quite some time on the per page TOC feature. Here’s the XSL template that I wrote for the TOC. Continue reading

Bash Tricks: Deal with a Flaky Internet Connection

Its been about 9 months in Vietnam now. One problem that I have to deal with on a day to day basis here is the flaky Internet connection. There are good days and bad days and bad days are incredibly frustrating. The Internet is ON and OFF every five minutes. I wrote this simple script which will wait for the Internet to be active before executing commands given to the script as an argument. I have found this very useful for commands like git pull/push, svn update etc.

PING=$(ping -q -c 1 &>/dev/null; echo $?)
while [ $PING -gt 0 ]; do
  PING=$(ping -q -c 1 &>/dev/null; echo $?)

I call it "wfi", wait-for-internet. Dump this script into your bin directory and give it executable permissions.

To test this script, disconnect your wifi/ethernet connection and then run the following command.

wfi ls -l

Reconnect your wifi/ethernet, and you'll see that the command gets executed as soon as your Internet connection is up.

wfi git pull

Now I can execute these commands through wfi and then go back to my work and be less exasperated.

Sample Bluetooth RFCOMM Client App in C

I recently worked with a client who wanted a Bluetooth RFCOMM client-server application. The server would sit on an android phone, while the client will run on an embedded linux device. The rfcomm client portion was just sample code that he wanted to base his implementation on. I wrote a quick app for the same. The code you are about to see is ugly and can be rewritten to look more pleasing to the eye. Also includes a horrible goto hack. But it works and can be used to base rfcomm implementations on. Continue reading

Bash Tricks: Get the Value of a Variable whose Name is Stored in Another Variable

If want to find out the value of a variable whose name is stored in another variable, you need to dereference the variable. This is how you do it.

Lets say the name of the variable is test123 and it has a value equal to 123. Also the name test123 is stored in another variable varname. To find out the value of test123, you will use the ! dereferencing operator.

@~$ test123=123
@~$ varname=test123
@~$ echo ${!varname}

Took me a while to figure this out.

Easily Create Sitemaps for Static HTML Websites Using Google’s Sitemap Generator Tool

All popular CMS softwares come with addons/plugins to automatically generate sitemaps for your website everytime you add new content. I recently added a few documentation sites which are all plain html files. I needed a tool to generate the sitemap files for these websites. After googling around a bit, I came across google’s own sitemap generation tool. It’s a very good tool and I highly recommend it for sitemap generation for html websites. Continue reading