Sunday, April 26, 2009

Ubuntu 9.04

Ubuntu 9.04 has just been released and I upgraded. But there were several hitches. I am noting those down in this post along with their workarounds:

1. IPV6 problem In the past IP addresses were 4 numbers separated by dots like this 123.123.123.123 Each of those numbers have to be below 255, with some numbers reserved for LAN addresses, etc. (E.g. 127.0.0.0 is a shortcut for a loop-back i.e. to the same device where the IP packets originate. So 127.0.0.0 for each computer is the same computer itself)

Because the population of Internet users are growing these IP addresses are not sufficient. So they invented IPV6 -- a new way of specifying the addresses. Don't ask me the details because I don't know...but I do know that they can handle a lot more addresses than IPV4 Most modern browsers support them. Operating systems support them. Routers support them, and most nodes along the way (E.g. DNS servers) on the Internet support them. But many website servers still do not support them. Also you will find certain DNS servers and some ancient routers not supporting them.

That leads to problems. So for the time being the best way out is to do two things:

a) Switch off IPV6 in Ubuntu. A hard thing to do if you are using Kernel 2.6.28-11-generic. I found out after several hours. In Kernel 2.6.28-11-generic everything is burnt in, so you need to recompile the Kernel keeping the support of IPV6 outside of it ... something that I did not want to do. Luckily for me, Kernel 2.6.27-11-generic was also available on my machine, so I commented out the reference to Kernel 2.6.28-11-generic in the Grub boot file
Then I wrote the following line in a file called bad_list (which in my case was non-existing, so it was a new file that I created) The location of that file is /etc/modprobe.d/ This is a system protected folder so you need to use sudo

sudo nano /etc/modprobe.d/bad_list

Inside that file, I wrote one line:

alias net-pf-10 off

On some sites, they recommend that you can also write these two lines in /etc/modprobe.d/blacklist.conf

blacklist net-pf-10
blacklist ipv6


b) Switch to the DNS servers provided by openDNS (www.opendns.org)

Without doing the above two, you will find that Opera 9.26 will not work

2. Intermittent hanging of Gnome
Gnome hangs every now and then, especially when the new Firefox (3.0x) quits. There are also several other points at which Gnome hangs. For e.g. changing the wireless settings (the points may differ for you) I don't know why this is happening. Possibly a display manager problem. Possibly a hardware. I'll keep you posted. The whole screen gets mangled and nothing works ...only the mouse moves around. I can't even quit the blessed system gracefully; and I have to power off the computer manually. Not a good thing to do because I can possibly fry the hard-disk that way. I later on learnt that there could be a key-board short cut : CTRL-ALT-BACKSPACE which I could use to restart the desktop manager. Unfortunately, they've disabled that shortcut key in this version of Ubuntu for some vague usability reason. This is what you are supposed to do if you want the hotkey back:

1. Open a terminal window
2. Give the following command
sudo apt-get install dontzap
3. The above will install a utility called dontzap (It is not installed by default)
4. Give the following command
dontzap --disable
5. Restart

Now for some reason the computer hangs, you can try CTRL-ALT-BACKSPACE and you will be able to start again (All work in that session will immediately lost... but still it is better than a fouled up hard-disk)


Saturday, April 11, 2009

Wink and language settings

When I installed Ubuntu, I had set the language to "English, India" Evidently some programs are not designed to accept that gracefully. I installed the nice presentation and tutorial creation software called "Wink" and I found that all the menu items, tool bars, and other messages were replaced by place holders. Being a programmer myself I realized that they are the mnemonics used internally by the program to patch in the message from the appropriate language file as the program loads. As there was no setting for Indian English, it did not know what to do next. Maybe the Wink developer (http://www.debugmode.com ) could consider a graceful default if a particular language setting was not available.

Anyway, I shifted to UK English and the program works fine now.

Prolog on Linux and a few lessons

I code extensively in Prolog and much of my work was done in an esoteric version of that language; Visual Prolog (earlier PDC Prolog, earlier to that... Turbo Prolog, yes from Borland) Visual Prolog is a fantastic language even though strict Prolog afficionados may scoff at it. It truly has some remarkable features and the PDC people are rightfully not so worried about where their language is placed. Unfortunately from version 6.0 onwards, there is no version for Linux, so I went looking for one. Version 5.2 did have a good Linux compiler but it was still a commercial one, and so not suitable for open source apps; an area I am now getting into.

I tried out two Prolog interpreters/compilers: SWI-Prolog and then Gnu Prolog. SWI-Prolog is extremely well supported but it is not as fast as Gnu Prolog. Gnu Prolog has an extensive range on how it can work: It can act as an interpreter, or it can even compile to various forms of compilation: bytecode (similar in nature to Java) and native code.

One can even create a customized Prolog interpreter with one's own extensions -- this was very appealing for some of my projects. I had written my own version of Prolog called "Web Prolog" which has not seen the light of the day by the outside world but was used quite effectively in my own office. Gnu Prolog interpreter creation feature may make Web Prolog even better and usable by many more. Oh I am digressing...

So here I wanted to try out Gnu Prolog's compilation feature. So I wrote this very simple test, and guess what; called it test.pl

go:- write('Hello world').

It compiled all right to create the executable "test" with the following compiler command:

gplc test.pl

but when I gave the following command

test

Nothing! Nothing happened! After several vexing minutes, I realized that Linux was probably not running test from the same folder where it compiled and there is another executable somewhere which is being executed. So I gave this command to find out

which test

And it returned

/usr/bin/test

Now I definitely was not compiling my program at /usr/bin/test (Nobody should, Work always in your own folder or sub-folders underneath it)

Dumb! What was that version of test doing there? No idea. Who created that? I think it came with some installation. I checked the date and it was created last year, so it was not because of some compilation I did.

Important takeaway lesson for Windows users:

In windows, when you run a command in a current folder, Windows will first execute from the current folder and if it is not existing there it will go checking the environment PATH. In Linux, not so. If you want to run from the current folder then you have to specifically state it thus:

./test

It is an excellent security feature, which is better explained elsewhere.

Now the program was not correctly written or compiled. gprolog was jumping directly into the interpreter. I wanted a squeaky little program of my own. So here is the actual code for gnu prolog:

:- initialization(go).

go:- write('Hello there').

And this is how you compile it:

gplc -o mytest --no-top-level test.pl

The above produces an executable called mytest Aha, the satisfaction of seeing someone on my laptop LCD telling me "Hello there" ....hmmmm

Wednesday, April 8, 2009

Sound issues in Ubuntu

If you get some faint crackling sound in the speakers and nothing else, the way I did with the Conextant/NVidia sound card then run this command

alsamixer -Dhw

It is possible that the PCM Mixer volume is muted or set to zero. When you run that command, you will be given a text interface which you can control using the arrow-keys. (I think such interfaces are known as CURSES interface, for some reason) You should navigate to the mixer section, which I believe is the 2nd option and turn it all the way up.

More later

Tuesday, April 7, 2009

Browser and File Manager Tweaks

I did not like the default Ubuntu Nautilius file manager. Nautilius has a nasty refresh problem: Once you click on a folder, it will not show the content unless you force a refresh by slightly resizing the window. What a pain.

So I installed Thunar instead. You can do that using the Add/Remove Applications feature of Ubuntu. I made it the default file manager by following the instructions given here Or you can use the scripts here

I was hoping that it would change the default file manager even inside Firefox. But sadly it did not. After much googling I realized that I was searching for the wrong information. I should have asked for "file picker" and not "file manager"

Well, to make Firefox use Thunar instead of the earlier Nautilius, I had to start a new window in Firefox and go to the special url called about:config That is a shortcut to reveal some quite advanced configuration inside Firefox. You will get a warning that if you do something wrong, things can go terribly wrong indeed. So be warned and proceed. It will display a huge list of configurable items.

I then searched for this ui.allow_platform_file_picker On clicking it, it will change the value from true to false (Clicking it again will turn it back to true) Make sure that you set that value as false

That's it. Close that window and you'll find that Firefox is now using Thunar.

You have a similar option in Opera too: Go to about:config in opera and search for File Selector. The options are usually hidden. Click on "File Selector" and it will display a value: 0 means auto. Try with 1 or 2 for the other file managers available. One of them should work properly for you.

Sunday, April 5, 2009

Programming Re-captcha with Rebol

Captcha is a good system to prevent automated submission of forms by spammers. There is a free web-service from http://www.recaptcha.net that allows anyone to create a recaptcha form and use it for your own forms. It is quite simple actually.

You will definitely need to read this http://recaptcha.net/apidocs/captcha/client.html It explains how to embed the Recaptcha form within your own form on your own site.

If you want to get under the hood then read http://recaptcha.net/apidocs/captcha/ It will explain how to write your own Recaptcha processor. You may skip that if you use the Rebol system I've developed.

I program a lot in Rebol. However, there is no Recaptcha library specifically for Rebol. Turned out that it was quite easy to write one. The following piece of code is what you need in Rebol. I cannot get into the details of how Rebol works. Read docs at http://www.rebol.com for that.

In the following piece of code, it is assumed that the variable 'vars' is a bound object containing the values of the form being processed. If you insert the standard recaptcha into your form, then you should get vars/recpatcha_challenge_field and vars/recaptcha_response_field in that object. If you do not know how to do that, then simply use this script http://www.rebol.org/view-script.r?script=safe-cgi-data-read.r

This also assumes that your site is working on an Apache server. The REMOTE_ADDR environment variable is set on Apache servers. I am not so sure about other servers. Replace {YOURPRIVATEKEY} with whatever they sent you when you registered your site with recaptcha.net The public and private key is specific to your website.


Lastip: get-env "REMOTE_ADDR"

chall: replace/all vars/recaptcha_challenge_field " " "+"

resp: replace/all vars/recaptcha_response_field " " "+"

result: read/custom http://api-verify.recaptcha.net/verify

reduce ['POST rejoin ["privatekey={YOURPRIVATEKEY}&remoteip="
Lastip
"&challenge=" chall "&response=" resp
]


]

lns: load result

either lns/1 = "true" [

print [" Re-Captcha was correct!"]
;;;;at this point you may take the rest of the form
;;;;and proceed using it

] [

print ["Re-Captcha was not corret. Please try again"]

]

Friday, April 3, 2009

Don't panic if something breaks!

In Ubuntu, you could screw up things if some of the startup files are mangled. I accidently wrote something wrong in the /etc/environment file. (Unlike other Linux implementations, Ubuntu keeps the enviroment settings in the /etc/environment file) This can be a bit of a bother for some utilities that require some settings that are normally kept in the .bash_profile file of the user (That is what I've come to know so far but I guess I need to investigate this further)

Anyway, to cut a long story short; I ended up fouling /etc/enviroment. When I restarted the computer, it gave a scary warning "Your session hardly lasted 10 seconds" and someting more about possibly running out of hard-disk space (which obviously was wrong because it was practically a squeaky clean computer)

After hyperventilating for a while, I managed to calm myself down. Fortunately, I have developed this habit from quite some years... of remembering the last few things exactly. So that just in case something like this happens, you know how to retrace. I know many others who go about doing things in a daze and then cannot undo what they have done. Basically you need to keep a log of activities. Whether you do that in your head or otherwise is your choice.

So I realized that it must be to do with the stuff I wrote in the /etc/enviroment file. It struck me that the Ubuntu 8.1 is actually a live disk. I placed it in the drive and booted from it as if nothing had happened. I could get into the system. I opened up a terminal window. Then I gave a "sudo" command to give myself editing rights (which does not have a password ... because you loaded from the Live CD ... but you have to give the command nevertheless.) Now the hard-disk location had conceptually moved it was now under /media/disk1 or something like that ( In other other computers I can imagine it to be different). So I loaded /media/disk1/etc/environment into the nano editor and removed the offending lines that I had written earlier, and I saved the file.

Now when I rebooted everything was in order

Thursday, April 2, 2009

Linux windows media issues

When you install a media formatted on a Windows computer (usually Fat32 or NTFS) and then bring it to an Ubuntu machine, by default all the media is set to the root ownership. Hence changing the ownership is not possible unless you are root. But there is still a surprise for you: If you do morph yourself as the "root" user, such media will still prevent you from changing the ownership. Try this:

1. sudo bash


At this point you will become the root user. Now let us try to change the ownership of a folder in a media called "G-Drive" which was previously formatted by Windows.

2. chown xyzabc:xyzabc /media/G-Drive/myFolder
Now this will seem to work. But hang on a sec...

3. ls -l /media/G-Drive
you will now find that all the folders in G-Drive are still belonging to root:root

Bleah! So what do you do? Install "Disk Manager" (A Gnome project) using Ubuntu's Add/Remove Applications feature. Start that up and under "Advanced Configuration" place a tickmark next to the Windows media, and then edit its parameters as follows. The locale=en_IN is possibly because I am in India. You would have to modify that as per your locale. Or maybe omit it entirely.

defaults,utf8,umask=0000,uid=1000,nosuid,nodev,
uhelper=hal,locale=en_IN,gid=1000

(All of above should be in one line. I gave it separately in two lines for convenience)

Now in the Disk Manager under "General" tab you can even tick "Detect new devices on startup" and also "Enable write support"

Root is nicely protected

When you install Ubuntu 8.1, it will ask for a default username and a password for that username. It will then proceed to give all the administrative rights to that user. Whenever you want to perform some admin tasks, you can precede the command with "sudo". It will then prompt you for the password for the main username. On giving that, the command following sudo will be executed with administrative rights.

However that does NOT mean that such a user is the "root". The "root" is a special user who is sometimes; though rarely, needed. In the default Desktop version of Ubuntu 8.1 you cannot set the password of the root directly. However the main user can morph into the root using a terminal window.

Just give the following command:

sudo bash

It will ask for your password. Give the password that you had set for the default username. That is it. You have now become the root for that session of the terminal.

I think this is a good policy because the "root" user can create havoc on a Linux system if you are not careful.

Read more here http://www.cyberciti.biz/faq/ubuntu-linux-root-password-default-password/

Swinging through SVN

I have most of my files on an SVN (Subversion) version control system (Hosted at Dreamhost...they are quite good at Subversion hosting) When I migrated from Windows to Linux, I now have the problem of migrating my SVN client too.

On Windows, there is this fantastic SVN client called TortoiseSVN. It is simply a no-brainer. Once you install it, just right click on a Windows explorer file listing and you can get all the required SVN commands at your finger tips. Those who are not familiar with the way Subversion works, will need to read the help file on it. It should not take more than half an hour. Read about the following commands at the very least and how to perform them using TortoiseSVN: checkout, commit, update, add, rename.

There is no version of TortoiseSVN for Linux. Instead I installed RapidSVN. It does not include a right-click context menu to any file-listing. (The concept of Windows Explorer is not present in Linux as far as I know. They have file managers and you can use one of many. Or even several of them together) RapidSVN has its own user interface. Fortunately, it recognized my external hard-disk containing the folders and partitions made in Windows XP Home. Then working with RapidSVN was again a nobrainer. You have to go to the Bookmarks menu and add an existing working folder to RapidSVN. It easily recognized my external hard-disk and the folders under version control. After that, you will get all the files in that folder in an explorer kind of environment. And then you can perform all the Subversion commands from there.

It worked quite well for me. Now I can keep working both between my Windows machine as well as my Linux box.

Wednesday, April 1, 2009

Move over, Windows

Just bought a new notebook computer: Compaq CQ60-101-AU Athlon Dual Core 64 bit. After trying out Windows XP Home I finally settled on Ubuntu. I thought of starting this blog to record and share my experience.

Installing the drivers for Windows was a nightmare but it is possible. There is a blog out there which lists all the drivers to download. The drivers must be put in the right sequence and one must follow every instruction carefully. The Atheros wireless driver listed there was wrong. So I downloaded the one from the HP Compaq site after searching for it via Google. Strangely enough it is not directly listed on their site. So if you were to dutifully browse for the software on the Compaq site for the CQ60 model, you probably may not find that Atheros driver. Moreover, the driver is supposed to be only for Vista. But what the heck, I tried it out at 5.00am after many frustrating hours and sure enough it worked for me even for Windows XP Home. So much for user friendly help.

Anyway after all that work; I finally threw out Windows XP Home. Reason? The ass$%$% of the Microsoft help fellow simply hung up on me. He did not believe that I had broken my original Windows XP Home CD and I was using my friends CD (though my own license) for installing. So much for honesty.

Anyway, I thought it was high time that I did move onto Linux. All those crappy trojan and virus writers are having a field day on Windows. I had been looking at Linux since the time when it was that small lil' penguin. But it has grown up considerably. And lots of very important software that I need, like Ardour -- a music recording studio -- is available only on Linux. Bye-bye-Microsoft! Somebody should tell them to write better OS, and train their Bangalore staff better.

Ubuntu 8.1 installed in a breeze on my machine. 2 Gig RAM. Bloody hell. No driver to download. Nothing. At the first boot, it detected the NVIDIA card and asked me whether I should install the proprietary drivers from NVIDIA. (Most, if not all Linux are very evangelistic about being open source. They do not like proprietary stuff coming into their installations) In my excitement, I missed something and the driver did not get installed. On the second restart, I hunted around the Ubuntu interface and sure enough it was quite easy to find the required menu entry to re-invoke the NVIDIA driver installation request. This time around I got it right and I got a spiffy little machine with NVIDIA graphics working great. And that Atheros Wireless Card... well, what about it ? Nothing. Ubuntu had anyway recognized and installed the requisite driver the first round itself. (Here I am sticking my tongue out at Windows)

Now about the software. There is this myth that Linux has very little software. That is really weird. If you take a look at the Add/Remove Application menu you will see the tons of stuff that are available. I quickly installed all the apps that I wanted. I fumbled a bit at a web camera movie making utility. I thought that none were existing for Linux. There were some references to using VLC and Mencoder and such like. But they were so full of Linux jargon that they were not for me. Though I did install VLC and I've used it on Windows: It is one of the most powerful applications in that genre. I almost gave up my dreams of making cute little Youtube presentation till I came across this cheeky application called Cheese from projects.gnome.org Wow. Talk about simplicity.

After all that, I needed to run some apps from my old Windows machine. Thankfully, I don't install software on any Windows machine. I use the portable versions of software that don't leave registry cruft. The only programs that I install on the main Windows machine are: a good anti-virus, Java, Free Download manager, Acrobat Reader, a registry cleaner and I try and avoid to the best possible all other installations. That is an excellent approach. I have this external hard-disk containing all the portable applications from portableapps.com and I carry that around and attach it anywhere I want. It does not require a powersupply and it is a good 320Gig Western Digital with a 2 year warranty. I have my data also on that drive. (Which I also back up on another; more rugged drive elsewhere)

So how do I run those portable apps? Some of them have direct equivalent in Ubuntu: Firefox, OpenOffice, etc. But I do have some that have no synonymous app in Linux. So here comes WINE, the windows emulator that I installed on my Ubuntu box. Then from winetricks.org I installed a utility called winetricks (huh... difficult to guess?) and downloaded and installed some esoteric components from the Microsoft arena; mainly scripting control which was required by one of the crucial apps that I had written.

Now I am in business and I can even pause for some wine!