Python: Newbie Code for String Histogram

Well, I have been pretty lazy about blogging lately, so pardon the amateurish code. But well, ever since no_mind egged me on to learn python, I have been learning it. Just finished a few code samples and this looked nice. It actually generates a histogram of the number of occurences of characters in a string.

#! /usr/bin/env python

#python program to input a number and generate a histogram of the characters in it
import string
for char in txtarray:
    if chardict.has_key(char):
for pair in charlistpair:
    print pair[0], “t”,
    for i in range(0, pair[1]):
        print “|”,


PDF Creator

Just wanted to post about a great software that I am using to print from excel using vba to a pdf file. Adobe Acrobat was too messy, and cost a bomb. However PDF Creator is an open source project developed in vb which is quite cool. It is still a bit buggy, but is great work. If anyone is looking to contribute, look up the site of the developers.

Getting Skype to work on intrepid ibex with video

I have a logitech quick cam express web cam and a cheap microphone I picked up at nehru place. I installed skype from the repos and neither the audio nor the video would work. Chats worked fine though. So began trying to get them to work.

I decided I would get the latest deb version from the skype website and work with that. You can get the deb package or other packages from here.

During install I am warned that it is better to keep the older version from the repository itself, but I go ahead and install the new version.

I still have no luck and the test video in video options of skype shows a green noise, with no audio input.

Audio Input Setup

First the Audio. Make sure that your alsa mixer settings are proper. You could try recording with the sound recorder or audacity to ensure that your microphone is plugged in right.

Then in the Audio options in Skype set the Audio input device (Sound in) to the hardware device. For me it is HDA Intel (hw:Intel,0). Sound Out and Ringing should be set to pulse audio.

Go ahead and do a test call from the main skype window. You should now have audio. If not, try changing the sound input to various values, applying and then testing.

Video Setup
This seems to a common problem with Skype on Intrepid Ibex. I got the workaround from a thread on Ubuntu Forums.

We begin based on a tutorial by Howard Shane.

Since this is Ubuntu, we are assuming the USB device is already mounted and ready to go. However we can check by
$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 046d:0928 Logitech, Inc. Quickcam Express
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 045e:0084 Microsoft Corp. Basic Optical Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In my system, it shows the camera on the second line. Your camera should be detected too.

Once you are sure that your camera is up and running, you can install cheese to see if the cam works.

$ sudo aptitude -y install cheese
$ cheese

Start the Video playback and ensure that your camera is online.

Ok, now we only have to configure skype to startup differently.
$ sudo gedit /usr/local/bin/skype

Paste the following lines into the file
LD_PRELOAD=/usr/lib/libv4l/ /usr/bin/skype

Then make the file executable.
$ sudo chmod a+x /usr/local/bin/skype

Skype now works fine with video too. To test, open skype options and select the video section. Select the appropriate camera (there usually should be only one) and click the ‘test video’ button on the top right. If everything is ok, then the button will be replaced by the video.

JSP programming on Ubuntu with Tomcat 5.5

I am working on a few assignment for my MCA course and installed Tomcat on Ubuntu through the official repositories. However I had some trouble getting it to work and finally this guide worked.

Actually what we need to do is add this line to ~/.bashrc
export CLASSPATH=$CLASSPATH:/usr/share/java/jsp-api-2.0.jar:/usr/share/java/jsp-api.jar:/usr/share/java/servlet-api-2.4.jar:/usr/share/java/servlet-api.jar

You may also need to set permissions to enable normal users to write to /usr/share/tomcat5.5/webapps . Or just add the current user to the adm group.

Configuring Outlook to access Gmail through POP3/SMTP

Many of my users have been requesting me to provide a guide on how to download mail over there dialup connections from gmail through pop3. Even if you are not using dialup, but would like to have an offline copy of your mail in case your internet connection gets flaky, or if you internet connection is slow and you would not wish to wait eternally for pages to load, this tutorial might be of interest to you.

This tutorial illustrates enabling POP3 in gmail and configuring Outlook 2003 for POP3 Access of Gmail

Enabling POP3 in Gmail

1. Keep your Gmail user id and password ready.
2. Open Internet Explorer or Firefox and enter in the address bar

3. If you are not signed in already, you will be asked for your user id and password. Enter the details in the appropriate fields and sign in by clicking on the ‘Sign In’ Button.

4. You will now be signed into the Gmail Web Interface.

5. Click on the ‘Settings’ Link on the top right and you will be taken to the Settings page.

6. Click on the ‘Forwarding and POP/IMAP’ tab at the top of the settings page and Enable POP3 Access. You have two options. You can either enable POP3 access for all mail that you have ever received or enable only for mail that you receive after enabling. If you enable for the first option, and you already have a lot of mail in your account, it will take some time to download all the mail.

Configuring your Outlook 2003 Client

The steps mentioned below assume you have already configured Gmail for POP3
1. Open Outlook.
2. Click the Tools menu, and select E-mail Accounts.
3. Click Add a new e-mail account, and click Next.
4. Choose POP3 as your server type by clicking the radio button, and click Next.
5. Fill in all necessary fields to include the following information:

User Information
Name: Not your Email ID. Fill in your name here
Email Address:

Server Information
Incoming Mail Server (POP3):
Outgoing Mail Server (SMTP):

Login Information
User Name:
Password: Enter your gmail password here

6. Click More Settings… and then click the Outgoing Server tab.

7. Check the box next to My outgoing server (SMTP) requires authentication and select Use same settings as my incoming mail server.
8. Click the Advanced tab, and check the box next to This server requires an encrypted connection (SSL) under Incoming Server (POP3).

9. Check the box next to This server requires an encrypted connection (SSL) under Outgoing Server (SMTP), and enter 465 in the Outgoing server (SMTP) box.
10. Click OK.
11. Click Test Account Settings… After receiving Congratulations! All tests completed successfully, click Close.
12. Click Next, and then click Finish.
13. Download the latest updates for Outlook from Microsoft. This will help prevent the most common Outlook errors Gmail users see. For this visit or email the Delhi Regional Office for receiving Outlook 2003 updates in a CD.

Spell Check with Open Office 2.4 on Ubuntu 8.04

Apparently Open Office on Hardy Heron doesn’t come with Spell Check support out of the box. To enable it, you need to follow the following steps.

1. Open up Open Office Writer and goto the menu item “Install New Dictionaries” in File>Wizards.
2. A Read-Only File with text links to various languages opens. You will want to click on ‘English’

3. In the page that is displayed click on the button “Start DictOOo”
4. A dialog opens. (In case you are not able to view the windows fully, goto the Gnome Menu item “Appearance” in System>Preferences and set the Visual Effects to None to disable Compiz. Do once again from step 1.)

5. Click ‘Next’ Once and in the next screen, click on the button “Retrieve the List”. Open Office will connect to the dictionaries server and retrieve a list of dictionaries available. You are serially allowed to select the needed a) Spell Checker dictionaries in the first windows, b) The Hyphenation Dictionaries in the next window and finally the c) Thesarus Dictionaries.

6. Click Next Once while it downloads and displays information on the files to be installed. Click Next Once again for it to finally install the selected dictionaries.

That is possibly all you need to do to setup your dictionaries. Now go to the Open Office Menu, “Tools> Options”, Expand the “Language Settings” Section, select “Languages” and set “Default Language for Documents: Western” to English (USA) or English (UK).

When you select a language, if it has a tick mark with ‘ABC’ written to the left of the name of the language, the Dictionary for that language is installed. English(India) apparently doesn’t have a dictionary that can be downloaded yet.

Hope this helps. Let me know if the post was useful

Using Postgresql on Linux Mint/ Ubuntu

To install postgresql in Ubuntu or Linux Mint issue the command
$sudo aptitude install postgresql

Apt will download and install the necessary packages for you to use the postgresql server on your computer. However, postgresql will not be started immediately and if you use a command like psql to connect to it, you would probably get an error like:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

To start the server
$sudo /etc/init.d/posgresql start
However on my installation, I got an unknown command error. A bit of digging showed that there was no object called postgresql in the /etc/init.d directory. A quick ls at /etc/init.d showed that the link was actually postgresql-8.2. So if the previous command to start the server does not work, a bit of digging around would help to find the correct name.

Or of course, you could just restart the damn box. :-)

The server is now installed and started. We now have to create a user who can create a database. Or as postgresql is fond of saying, we need to define a role.
We log into the postgres profile of bash:
$su - postgres

Create a new user with database creation permissions as
$createuser -d -S -R -P graydot

You will be prompted for a password and then to reenter the password.

This command in effect tells postgresql to create a user of name ‘graydot’ with database creation permissions (-d), no super-user permissions (-D) and no permission to add roles (-R). The characters in small case for these option allot permissions and the capitals disable them. You should replace ‘graydot’ with your account user name.

We now check if the user has been created as required. Open the Sql prompt by using the command line tool ‘psql’
$psql postgres

At the prompt type
#select * from pg_shadow;

You should see something like

usename |usesysid | usecreatedb | usesuper | usecatupd |passwd | valuntil | useconfig
postgres| 10 | t | t | t | | |
jsemmanuel | 16387 | t | f | f | md5114afb9a66 | |
(2 rows)

Exit psql by typing q
Logout out of the postgres profile by typing exit once

You are now in your user profile.

We now intend to create a database. The createdb command is used to create a new database in postgresql.
$createdb test_db

A new database of the name test_db is now created with the owner set to the currently logged in user.
Open the SQL prompt with the psql command.
$psql test_db

At the sql prompt, type 'l' to see a list of databases and their owners.

These are the basics of installing postgresql in the simplest way possible, upto the step of creating a database. I will be posting more as time permits. This will go up as a tutorial on my website when I finally get around to bringing it up.

Downloading Google Videos

I recently looked up a few videos by Randy Pausch, one was his ‘last lecture‘ and the other was on time management. The former was on Youtube and the other was on Google Videos.

The Youtube video was easy to download with youtube-dl on my Linux Mint Distro, (for how to do this, look up this simple tutorial) but I was stuck on the Google Video. Google Video apparently doesn’t have any download link and is not popular enough for developer to have tools designed for it yet.

I tried ‘Flash Video Resources Downloader’ firefox extension, but it open up a website which says that the flv file is not accessible. I finally had to give up on that and begin some frantic googling.

Jason Striegel at hackszine has made a cool script which seems to work excellent. I have the video downloading in the background at present. The file is 171 mb and the download speed is only like 15 kBps, so it is gonna take some time.

I just need to create a bookmark containing a certain javascript code. In Firefox, I cannot add a bookmark with the address entered manually, so i just bookmarked a page at random, then went to Bookmarks|Organize Bookmarks, selected the previously created bookmark and edited its properties to point to the script he mentions.

This is the exact command for Google Video'VideoPlayback').src.match(/videoUrl=([^$)]*)/)[1]));

And this is for Youtube''+window.location.href.split('?')[1].match(/v=([^(&|$)]*)/)[1]+'&t='+document.getElementById('movie_player').src.match(/t=([^(&|$)]*)/)[1]);

On a side note, the file downloaded will be ‘get-video.flv’ at your default download location or wherever you ask it to download. I can foresee some problems with multiple video downloads in some situations, but firefox just appends a (#) at the end of the video so generally it should not be a problem.

Getting Skype to work on Debian Etch

I was having some trouble getting the new skype 2.0 to work on my system for testing. I downloaded the package from and downloaded file was skype-debian_2.0.0.63-1_i386.deb.

Double clicking on the file just opened up gdebi which closed again.

Running from the terminal, gdebi crashes with the following error.
Traceback (most recent call last):
File “/usr/bin/gdebi”, line 31, in ?
if not[1]):
File “/var/lib/python-support/python2.4/GDebi/”, line 31, in open
if not self._deb.checkDeb():
File “/var/lib/python-support/python2.4/GDebi/”, line 185, in checkDeb
if arch != “all” and arch != apt_pkg.CPU:
AttributeError: ‘module’ object has no attribute ‘CPU’

A bit of research later, figured it was a problem with the python libraries and found this patch at

It simply involves opening /var/lib/python-support/python2.4/GDebi/

and replacing the line in the #check arch section

if arch != “all” and arch != apt_pkg.CPU:

if arch != “all” and arch != apt_pkg.Config["APT::Architecture"]:

Skype now installs without any trouble.

BSNL Tuticorin Dialup – Web Page

At the risk of offending my brothers in faith, with Google I am a hero, but without it, I am a zero.
I know I have heard that somewhere but in a bit of a different context.
Anyway Kannapiran asked on gc today if I could help him out. He said he wanted to know tuticorin’s netone number or webiste. Just putin the keywords, “bsnl dialup tuticorin website” and got the second result as this.
Short work from here to get to the site in question
Total time taken 1.5 minutes. Whoa!! That was fast.