Friday, December 12, 2008

Firefox extension installation error

I was trying to install firebug on my FF2 and got this error:

"installLocation has no properties
file:///usr/local/firefox2/components/nsExtensionManager.js"

After searching the firefox bug tracker, found out the solution.

Go to your firefox profile directory, backup and remove the file "extensions.rdf". Restart firefox and you will be able to install the extensions without errors. But I am not sure about what will happen to your existing extensions, as I had no other extensions installed. So this is all I did:

safeer@myubuntu:~/.mozilla/firefox/qkvt609s.default$ mv extensions.rdf extensions.rdf-bak

safeer@myubuntu:~/.mozilla/firefox/qkvt609s.default$ pkill firefox

safeer@myubuntu:~/.mozilla/firefox/qkvt609s.default$ firefox&

and start installing your favorite extensions :)

Thursday, December 4, 2008

Renaming files with space in name

Working on a file with spaces within its name is is always a headache in Linux. The best way is to rename them to eliminate spaces. For a normal user, even this is guaranteed to give pain if there are a lot of files. Here is the shortcut to do it:

I had a directory with songs that I ripped from a CD which had spaces in name. So i decided to replace the spaces with underscores.

safeer@enjoyfast-lx:~/Music/ONV-Shahbaz-Venugopal/Sahayathrikey$ ls -l
total 57284
-rw-r–r– 1 safeer safeer 6124954 2008-11-06 01:29 01 - Track 1.ogg
-rw-r–r– 1 safeer safeer 5647099 2008-11-06 01:29 02 - Track 2.ogg
-rw-r–r– 1 safeer safeer 5954106 2008-11-06 01:30 03 - Track 3.ogg
-rw-r–r– 1 safeer safeer 5783244 2008-11-06 01:30 04 - Track 4.ogg
-rw-r–r– 1 safeer safeer 5951001 2008-11-06 01:30 05 - Track 5.ogg
-rw-r–r– 1 safeer safeer 6212981 2008-11-06 01:31 06 - Track 6.ogg
-rw-r–r– 1 safeer safeer 5580947 2008-11-06 01:31 07 - Track 7.ogg
-rw-r–r– 1 safeer safeer 5519893 2008-11-06 01:31 08 - Track 8.ogg
-rw-r–r– 1 safeer safeer 5092362 2008-11-06 01:32 09 - Track 9.ogg
-rw-r–r– 1 safeer safeer 6653648 2008-11-06 01:32 10 - Track 10.ogg


Replace space with underscore is done by “tr” utility.

safeer@enjoyfast-lx:~/Music/ONV-Shahbaz-Venugopal/Sahayathrikey$ ls|while read FILE;do mv “$FILE” `echo $FILE|tr ‘ ‘ ‘_’`;done
safeer@enjoyfast-lx:~/Music/ONV-Shahbaz-Venugopal/Sahayathrikey$ ls -l

total 57284
-rw-r–r– 1 safeer safeer 6124954 2008-11-06 01:29 01_-_Track_1.ogg
-rw-r–r– 1 safeer safeer 5647099 2008-11-06 01:29 02_-_Track_2.ogg
-rw-r–r– 1 safeer safeer 5954106 2008-11-06 01:30 03_-_Track_3.ogg
-rw-r–r– 1 safeer safeer 5783244 2008-11-06 01:30 04_-_Track_4.ogg
-rw-r–r– 1 safeer safeer 5951001 2008-11-06 01:30 05_-_Track_5.ogg
-rw-r–r– 1 safeer safeer 6212981 2008-11-06 01:31 06_-_Track_6.ogg
-rw-r–r– 1 safeer safeer 5580947 2008-11-06 01:31 07_-_Track_7.ogg
-rw-r–r– 1 safeer safeer 5519893 2008-11-06 01:31 08_-_Track_8.ogg
-rw-r–r– 1 safeer safeer 5092362 2008-11-06 01:32 09_-_Track_9.ogg
-rw-r–r– 1 safeer safeer 6653648 2008-11-06 01:32 10_-_Track_10.ogg


If you want to eliminate spaces in the file name use:

ls|while read FILE;do mv “$FILE” `echo $FILE|tr -d ‘ ‘ `;done

Tuesday, November 18, 2008

String reversing in bash

I had a requirement where I needed to extract the third level sub domain name from a set of hostnames. "cut" alone was not enough to do the job as the hostnames where at different levels.

What I had was a set of hostnames like this ( This is not the real one that I worked on :P )

safeer@enjoyfast-lx:~/temp$ cat hosts.txt
www.safeer.in
dev.safeer.in
www.dev.safeer.in
mail.dev.safeer.in
mail.safeer.in
svn.dev.safeer.in
pop.mail.safeer.in
smtp.mail.safeer.in
blog.safeer.in
techlog.safeer.in
vm1.alpaha.dev.safeer.in
vm2.alpaha.dev.safeer.in


As you can see the hostnames are at different subdomain levels. So the only way is to extract the third field from right of the hostname. For this I made use of the "rev" command - which basically reverses a string and extracted the third filed as follows.

safeer@enjoyfast-lx:~/temp$ cat hosts.txt |rev|cut -d '.' -f3|rev
www
dev
dev
dev
mail
dev
mail
mail
blog
techlog
dev
dev


Did a sort to eliminate the duplicate entries. That did the trick and I got the result I needed

safeer@enjoyfast-lx:~/temp$ cat hosts.txt |rev|cut -d '.' -f3|rev|sort -u
blog
dev
mail
techlog
www

Sunday, November 16, 2008

Changing Your Wordpress URL

Well, I was thinking about changing my blog URL to a nicer one. Added the new DNS sub domain and pointed it to my server. Created a new entry inapache configuration and moved all the files to the new document root( optional - only if you want to move it into a new location). This is enough to change the URL for a normal website. But for a CMS/blogging software that stores all the data and meta data in databases, this is not enough.

For wordpress, there are two database entries that affects the url. Both resides in the table wp_options. So need to update them as well.

mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='home';

mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='siteurl';
That is it. All set now.

Wednesday, November 12, 2008

Ubuntu Display Tips

Found out a couple of useful shortcuts/tricks while working on my Ubuntu laptop (8.04/Hardy Heron).

Press "Windows" key and move mouse scroll button downwards to get an enlarged display of your desktop.  Move the cursor to the borders of the screen to travel from side to side/top to bottom of the enlarged screen.  To zoom out scroll in the reverse direction

Place cursor on any active window/panel, press "Alt" and move scroll button downwards to make that window/panel transparent.  To turn it back to opaque scroll in the reverse direction.

My "Visual Effects" setting is set to Normal in Appearance Preferences. (System->Preferences->Appearance->Visual Effects)