Monday, 24 September 2012

Quick Setup CherryPy in Python 3

CherryPy is a minimalist, pythonic, object-oriented HTTP framework.
For Windows,
1. Download and install the latest version of python 3.
2. Download and install the latest version of CherryPy with wsgiserver3 support.
3. Test the installation by running an example program (say like below.
import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello World!" = True

4. Navigate to the directory and run python to start the server.
5. Now goto and we will get a "Hello World!" from the server.

Thursday, 20 September 2012

Generete Ant build.xml for an Android Project

If we have an Android project which does not have a build.xml, then we can generate a build script by running the below command.
1. Navigate the android project root directory
2. Update the project to generate the build file
android update -p .

Thursday, 13 September 2012

Common Regular Expressions

Match letters, space, comma, ampersand, hyphen, forward slash, parentheses with length 1..12.
Match 2, 3 digit numbers with 0 to 2 decimal places.
Matches everything including control characters with length 5..255.
Postal code with min length 3, max length 10. Upper case alphabets, digits and spaces.
Mobile number with length 10..15 with an optional plus '+' symbol in front.
Number with minimum 2 digit with first digit not zero and max 3 digit number, with optional decimal upto 2 place.

Sunday, 9 September 2012

Install GCC in Nokia N900

The GNU Compiler Collection (GCC) can be installed in Maemo on Nokia N900, which allows on device development! To install them, first add the Maemo SDK repository to the application catalogs. Do *not* run upgrade (apt-get upgrade) after enabling the SDK repository. After the installation of the build tools, disable the SDK repository. Once the repo is disabled we can run apt-get upgrade command safely.
Catalog name: maemo sdk
Web address:
Distribution: fremantle/sdk
Components: free non-free
After reloading, close the application manager.
In the terminal, run the following.
apt-get update
apt-get install build-essential #installs the necessary packages
Open the application manager and disable the SDK repository. After that run update.
apt-get update

Thursday, 6 September 2012

Writing Bash Shell Logs With Date & Time

Bash shell scripts can be used to do a variety of things. It is very easy to schedule the script to run under crontab. It would be helpful if we log the steps with date time and a message. It can be done as follows.
echo '['`date +%F\ %T`'] Downloading file abc'
#outputs: [2012-09-06 23:20:16] Downloading file abc
NB: The date command is enclosed in back tick, not single quote.