September 29, 2009

Quote: A general principle of Robustness

The general principle of robustness according to Jon Postel is as follows:

Be conservative in what you do, be liberal in what you accept from others.

It is a very captivating statement and I leave it up to you to the see the boundaries of its essence.

The quote is available in RFC 761 as follows:

2.10. Robustness Principle

TCP implementations should follow a general principle of robustness: be conservative in what you do, be liberal in what you accept from others."

September 18, 2009

Emacs tips and tricks: Whitespace removal

The artist mode of Emacs can be used to remove the whitespaces in an Emacs buffer. This can be done as follows:

1. Add the following lines of code to your .emacs file

(defun clean-whitespace()

(interactive)


(artist-mode)


(artist-mode-off))


Now bind this function to a keyboard shortcut of your choice. I personally chose f6, so in the case of f6 add the following lines to your .emacs file

(global-set-key [f6] 'clean-whitespace)

This shall be enabled the next time you run emacs.

If you wish to update it in your current session, then open the .emacs file. Select the lines of code added and execute M-x eval-region.

September 17, 2009

Python Tips and Tricks: Tab completion in Python Shell: How to enable Autocomplete in python shell

Autocompletion using readline libraries is really helpful while working in a shell environment. Python has a support for the readline library, hence it is possible to use readline for autocompletion in python shell.

The following steps need to be followed to enable autocompletion or tab completion in the python shell:

1. Create a file called .pyrc in your home directory (you can name is anything, however, I preferred to call this .pyrc). This can be done by executing the following command:

touch ~/.pyrc

2. Open this file using your favourite editor, such as emacs or vim and add the following lines in the ~/.pyrc file

import rlcompleter
import readline
readline.parse_and_bind("tab: complete")

3. Now to ensure that the above code is executed each time python starts, add the following lines to the ~/.bashrc file. This is assuming you are using the bash shell.

export PYTHONSTARTUP="[path to pyrc file]/.pyrc"

Once this is done, execute your .bashrc file by executing

#> source ~/.bashrc

Now you can test this. The output would be something similar to this

Python 2.5.2 (r252:60911, Sep 30 2008, 15:42:03)
[GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>> import os


>> os.

Display all 224 possibilities? (y or n)



September 11, 2009

Downloading youtube videos: abby and cclive

Another technique to download youtube videos and other sites such as dailymotion is a tool called cclive which has a front end called Abby. One can download this tool in fedora using the command

#> yum install cclive abby

Abby also acts as a front end for clive. Once installed, when running for the first time you are asked to add the path to clive or cclive and the folder where you wish to download the videos. The path to cclive and clive can be obtained by executing the command

#> which clive
or
#> which cclive

Once this is done, one needs to add the URL of the video (by clicking the + icon on the left and the download videos icon which is to the bottom right of the list of videos.

Voila!!

In case you wish to use the command prompt, the commands for cclive are similar to those of clive.

You can now view these videos even when you are not connected to the internet.

September 8, 2009

How to configure and synchronize Google Calendar in Thunderbird? : Use Lightning with CalDAV

There are a few Thunderbird Add-ons that help one use Google Calendar; however, one of the the simplest and the easiest way to access, synchronize, and hence use Google calendar in Thunderbird is by using CalDAV. I am not sure which features one misses out on using this technique compared to the Add-ons available, hence, I am not the best to compare this technique with those provided by the Add-ons. However, this technique has worked seamlessly for me.

The following steps need to be followed to enable Thunderbird you use your calendar at Google Calendar. The assumptions are: Thunderbird is installed with the Lightning Add-on, and you have a Google account and can access Google Calendar.

1. Open Thunderbird. Click on (in the menu) Go->Calendar (Ctrl+3).

2. Click (in the menu): Calendar->New Calendar. A new window will be open which asks you
to create a new calendar.

3. Select "On the Network" and Click "Next"

4. Select CalDav and in the Location Field enter:

https://www.google.com/calendar/dav/ [ your Google Calendar ID ] /events

For your primary calendar your Google Calendar ID is your email address: For example, [ME]@gmail.com. For specific calendars in google calendar one can use the technique provided here. PLEASE SELECT HTTPS and not http.

5. Assign it a name and other properties you wish to assign.

6. Once this is done, you will be prompted for your google id and password.

Voila!!! You can now synchronize your Google Calendar with Thunderbird. To check it add an event in Google Calendar from your web browser and see if that event shows up in Thunderbird and vice-versa. It will work, but I would advise you to try it.