Friday, February 20, 2009

VIM improvements

If you have vim 7.x version, you should know that vim supports auto completion for certain languages like c, php, python, html, css, xml, javascript.

To enable autocompletion in vim, you need to create a file in your home directory

$ vim ~/.vimrc

Copy the following code into this file

autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete

And save the file.

Now open your file in vim and check out autocompletion

$ vim mycode.php

For autocompletion press Ctrl-X O. You should be getting a dropdown of available functions/variables and on the top of the screen a definition of the selected function.

Another thing that could be done in vim is tabs. Yup check out the following commands

:tabe oldfile.php - open oldfile.php in new tab for editing
:tabnew - open a new blank tab
:tabn - go to next tab
:tabp - go to previous tab
:tabr - go to first tab
:tabc - close current tab
:tabo - close other tabs

Coding is fun!!!

Thursday, February 12, 2009

upgrade nvidia drivers on ubuntu 8.10

So, you have an nvidia graphics card and you want to enjoy the high resolution and smooth graphics that comes with nvidia. You want to see the eye-candy graphics on kde 4.2. Firstly when you install ubuntu, you might not get the nvidia drivers enabled by default. So get and install the default driver available with your ubuntu version install "envyng".

$ sudo apt-get install envyng-qt

Now this is an utility that installs the stable version of nvidia drivers compatible with your version of ubuntu. To install the driver run the program

$ envyng -t

Follow the on-screen instructions to install the driver. You would probably get driver version 177.82. for nvidia. Once the process is complete, restart the computer. Now you should be getting better graphics.

There are people like me who are not satisfied with the latest stable version of driver. To upgrade to the latest version of driver first download it from the nvidia website.

For 64 bit ubuntu you can go to:

And for 32 bit ubuntu you can go to:

For my 64 bit ubuntu 8.10, i could see that the latest version available was "180.29". Go inside the directory and see the available drivers RUN 13650 KB 02/06/2009 08:48:00 PM RUN 13652 KB 02/06/2009 08:48:00 PM RUN 20453 KB 02/06/2009 08:48:00 PM

Why are there 3 drivers instead of one. Well, what nvidia does is that it compiles a basic driver and then keeps on adding more stuff into it. So basically you should download the latest "pkg#" version of driver. In our case it is

So, now you have the latest driver with you and you want to install the driver.

Switch to a console. Press "CTRL-ALT-F1".
Login using username and password
Kill all gdm/kdm sessions

$ sudo killall kdm

Firstly lets remove the old driver

$ sudo apt-get remove nvidia-177-kernel-source nvidia-177-modaliases nvidia-glx-177 nvidia-glx-177-dev

That should clean up the system of old drivers. Now run the new driver.

$ chmod a+x
$ sudo ./

It opens up a blue screen and you got to answer tons of questions. Also try to remain connected to the internet cause it might try to download kernel-modules for your driver. If it fails to do so, it will compile the modules. Let the script also modify your xorg.conf file (it will ask your permission to do so).

Once everything is done, simply reboot.

And enjoy kde 4.2 eyecandy with latest nvidia drivers.

installing flash player on ubuntu 64 bit

Basically you can install flash player on a 32 bit ubuntu machine by using apt

$ sudo apt-get install flashplugin-nonfree

It downloads and installs flash player. And all you have got to do in restart firefox.

The issue I faced was how to install flash player on a 64 bit ubuntu machine. As far as i am aware there is no stable release of any flash player for a 64 bit machine. The only way to make the flash based websites work is to install something known as "nspluginwrapper".

nspluginwrapper allows you to use 32 bit netscape compatible plugins on x86_64 browsers. So, the flash plugin is 32 bit but nspluginwrapper allows it to run on browsers compiled for x86_64 machines.

To install flash plugin for 64 bit browser using apt:

$ sudo apt-get install nspluginwrapper flashplugin-nonfree lib32mss-mdns

Restart firefox and bingo, you have flash plugin on your browser.

Tuesday, February 10, 2009

mount iso image in ubuntu without burning them to disk

Another thing that could be done in linux is that you can mount the ISO image of any CD and browse/work on it. Following are the simple commands which help you achieve it

suppose you have a downloaded kubuntu-8.10-desktop-amd64.iso, and you want to check its contents.

jayant@localhost:~/$ sudo mkdir /tmp/kubuntu
jayant@localhost:~/$ sudo mount kubuntu-8.10-desktop-amd64.iso /tmp/kubuntu -t iso9660 -o loop
jayant@localhost:~/$ ls /tmp/kubuntu/
autorun.inf casper dists install isolinux md5sum.txt pics pool preseed README.diskdefines ubuntu umenu.exe wubi.exe

Bingo, your iso image is mounted and you can easily browse thru it. You dont need to burn it now.

To unmount the image simply issue

jayant@localhost:~/$ sudo umount /tmp/kubuntu

I hope this helps.