Archive for category Programming

Getting ttwebtop to work on Ubuntu

I use tarantella at work, but ttwebtop doesn’t work by default in Ubuntu. After starting up, it isn’t possible to type at all in the text boxes. To fix that, you need to add the following to your bashrc (or init script of choice)

export XKEYSYMDB=/usr/share/X11/XKeysymDB

That should work.

Leave a Comment

TimeZone converter 0.2

A few small bug fixes and UI corrections in my earlier project:

Application:

TZConvert.jar

Execute with java ver. 1.6

java -jar TZConvert.jar

Source:

TZConvert.zip

Leave a Comment

Finding duplicate files using md5sum

Been a while since I posted something.

Anyway, as usual I’m driven by need. I’ve got zillions of dupes on my hard disk, thanks to my wife’s unique file management techniques – I hope she doesn’t read this blog entry! :)

And I didn’t like Fslint etc., wanted something simpler. So here is something I think will work fine – will try to poke holes in it before I actually test it out of course!

find . -type f -name "*" -exec md5sum {} \; > md5all.txt
cat md5all.txt | awk '{print $1}' | sort | uniq -d > dupes.txt
cat dupes.txt | while read line; do echo "--------------------"; grep $line md5all.txt; done


Should be fine I think.

Leave a Comment

Howto setup lxr on Linux (Ubuntu Feisty)

The purpose of this post is to describe how to setup lxr for personal use on Linux – I use Ubuntu Feisty on my machine. Most of the commands need to be run as root, so you may want to do:
$ sudo bash
right at the beginning. Or you can prepend sudo to each command.

Setting up apache on Ubuntu Feisty.
# aptitude install apache
# /etc/init.d/apache start
Note: I don’t think I did any other settings really, but I had setup apache earlier – don’t remember now. I’m including it here for completeness. I am only accessing my webserver as localhost, and have not changed anything anywhere.

Setting up lxr on Ubuntu Feisty.
# aptitude install lxr

This gets lxr 0.3.1-4 – you need to have universe enabled in /etc/apt/sources.list. If you have enabled just now for the first time, then also execute ‘sudo aptitude update’ before installing lxr. And that ends the part about installing lxr. The compile-by-hand folks are just masochistic :) .

Add the following lines to /etc/apache/httpd.conf at the end:
# Linux Cross Reference Stuff
Alias /lxr /usr/share/lxr
<Directory /usr/share/lxr>
Options All
AllowOverride All
</Directory>

Create a file /usr/share/lxr/http/.htaccess which contains:
<Files ~ (search|source|ident|diff|find)$>
SetHandler cgi-script
</Files>

I now restart apache. Don’t know if this is essential, I guess reloading should be enough. But hey, this is my personal machine, no harm done :) .
# /etc/init.d/apache restart

Since I only want to access the cross reference locally, I am not changing any settings in lxr.conf. At least, not yet. You can check /usr/share/doc/lxr/README.Debian.gz for more details.

Now we setup the cross reference.
1. Create /usr/share/lxr/source if it doesn’t exist.
2. Create a directory 2.6.22 inside it – this is the linux version I am cross referencing.
3. Untar the kernel source inside this directory in a subdirectory ‘linux’ .. i.e., you now have /usr/share/lxr/source/2.6.22/linux with the source in the linux directory.
4. Add a line with contents ’2.6.22′ (without the single quotes) in /usr/share/lxr/source/versions
5. ln -s /usr/share/lxr/source/2.6.22 /usr/share/lxr/source/defversion
6. cd into /usr/share/lxr/source/2.6.22 and execute ‘genxref linux’
7. Make a cup of tea.
8. 10 minutes later (since you must never hurry a good cuppa) visit http://localhost/lxr/http/blurb.html
9. You’re done.

Note: I have not described how to setup the glimpse database, but that is documented in the lxr readme as well. You should read that anyway. Incidentally, generating the glimpse database would be step 8.a, just after the ‘genxref linux’.

15 Comments

A simple timezone converter

Screenshot-TZConvertSo I wanted to fool around in netbeans, swing and java – here is the outcome. It’s a simple program which lets you set the date/time in one timezone, and see the corresponding date/time in another timezone. I needed this – am not always online but still need to figure out the time in different zones. Invocation is simple, unarchive the tar.gz and then execute: java -jar TZConvert.jar

TZConvert.jar is in the dist directory. You can download it here. The program is GPLed for extra goodness :) .. note that it is developed on java 1.6. If you are using Ubuntu Feisty you can now do an:

aptitude install sun-java6*

(I forgot the exact package name!) My original plan was to make this a Thunderbird plugin, but it appears I cannot write plugins in java for Thunderbird.

Leave a Comment

Declaring global variables in header files

is a NO-NO! My colleague asked me why – so here is the answer.

If you do something like this:

  • Declare a variable, say ‘int glob_x’ in ‘x.h’
  • Include ‘x.h’ in ‘a.c’ and ‘b.c’
  • Try to link a.o and b.o into one executable, and you will get a linker error, duplicate symbol.

Basically, the header file is included in both the files, and the variable glob_x is now global in *both* the c files, which leads to a clash when you try to link them together.

The correct way of doing this is:

Make glob_x extern in x.h, and declare the variable in only one of your .c files. Now you can use the variable in any .c files that include x.h, and there will be no linker error.

8 Comments

Dbx cheat sheet – Solaris (updated)

An updated edition – dbx-cheatsheet-solaris1.pdf.

Leave a Comment

Dbx cheat sheet – Solaris

I created a small cheat sheet for dbx on Solaris. Actually I’m working on a longer tutorial about debugging on Solaris – this was a slight detour. You can find the pdf hereĀ dbx-cheatsheet-solaris1.pdf – the export from Google docs wasn’t as nice as I thought it would be. Maybe I’ll stick to Openoffice for a while.

Leave a Comment

Formatted output – printf

This is the piece of code I saw today:

printf ("%.*s\n",l,s);

This is the same as

printf ("%.2s\n",s); //l=2 in my example.

I suppose everyone knows this, and I’m the only idiot! Rather nice, when you don’t know before hand what width you want to print. I clearly need to go back to K&R.

1 Comment

System information on Solaris, the programmatic way

Again, work in progress. But at this point I think I have got everything I’m interested in at the moment.

The root node in solaris_proc.pdf has two childern – one is about getting process information from /proc and the other is about getting system information using libkstat.

Please email/reply to this post in case there are any corrections!

Leave a Comment

Follow

Get every new post delivered to your Inbox.