Pages

Thursday, November 03, 2005

mdb

mdb is a very powerful debugger. Unfortunately for those with a gdb background, its a bit too powerful. (gdb cripples the mind, being so simple to use.). And when you have to keep switching between mdb and kdb and kwdb and q4, it futher complicates stuff.

So I have decided that I would keep adding mdb tips, links and everything else, for ready reference in this post. Sun's Modular Debugger Guide, after all, is no good for someone looking for 'mdb by Example' kind of a book. This post from Jonathan Adams weblog, however is a good one.

Here are other good links. ....

Tuesday, August 23, 2005

gdbm

If you are looking for a fairly simple, embeddable in memory database ( actually a hash), gdbm is just what you need. Based on the Unix dbm, it has a simple API and an LGPL license. Of course, there is nothing like SQL queries, Encrypted Relational DBs, transaction support and all that, but then, if you need that, there are bigger and more complex databases available out there. ( There was one recently out, from IBM, but it was all java).

Here is what GDBM's man page says

GNU dbm is a set of database routines that use extensible hashing. It works similar to the standard UNIX dbm routines.

Tuesday, August 16, 2005

Make

Adrian Reau has a good article on freshmeat, discussing the shortcomings of venerable make program.
Anyone who has ever tried to make a portable build system for more than a couple of platforms would agree that make is just not enough. There are so many heavily used, Gnu Make features that are not there on other unixes.

Unfortunately, the portability problem isn't solved by the use of Make replacements he has suggested. But for other problems , like recursive make, these (esp. cook) seem to be decent replacements. Unfortunately, the build chain never gets the importance it should (becuase our focus is to fix customer issues, and build problems are essentially developer issues).

Tuesday, June 07, 2005

Future

What is the primary focus of Linux development. Performance was undoubtedly what Torvalds had in mind. Guided by the dreams of 'World domination', becoming an easy to use desktop operating system with windows like GUI / Ease of Use/ Hardware Autodection etc. top the wishlist today.


Which makes me wonder, whether there is going to be a time, when Windows itself would be history, & linux would be the de facto standard. That would be the time when we would see FreeBSD/NetBSD/OpenBSD emerging as alternatives, and people arguing why the *BSD's are superior to Linux, in terms of security. Others who are not so paranoid about security may be arguing why Linux isn't as free as the Hurd. And of course the dedicated band of followers of Apple's Macs would still be around, arguing why Mac still beats them all.

Monday, June 06, 2005

Never Again

Today I spent around 3 hours in a worthless meeting discussing how to
make builds.
At the end of it I have little to show for.

This is the worst way to waste your time, and I swear to myself that I
am never going to do such a meeting ever again.
I am going to pull out halfway, if I happen to be in such a meeting,
however impolite it may seem.

Saturday, June 04, 2005

Performance Woes

I was happily using my laptop all along, and then, all of a sudden, It seemed as if I had a hardware downgrade.

The first thing I noticed was problems with screen refresh. My primary laptop app is firefox, and it seemed to be give me a hard time. The display wouldn't refresh properly, and just a couple of minimize maximise events would result in X server becoming unresponsive for quite a few seconds.

I had just upgraded to the high performance jk series kernel 2.6.11, and with such a poor performance I suspected the kernel itself. Reverting to 2.6.7 didn't helped. The X server didn't had any memory issues, top didn't showed any anamolies, and vmstat statistics were just fine. Swap was unused, and there was enough free memory. I even suspected firefox , and later X, so upgraded both of them, to no avail. Considered upgrading to xorg, but didn't had the time or the courage to go through all that.

I had almost decided to ditch my half mepis - half debian distro, and load a hoary hedgehog quickly.Ubuntu is what I use at work on the desktop most of the time, but that meant wasting a lot of customization effort , and countless hours installing arcane softwares only I need on my laptop.

Feeling somewhat bored today, and with nothing worthwhile on my hands , I thought of the joystick issue I had faced sometime back with tuxkart a long time back. I thought I would fix the game so that the joystick can be used with an otherwise nice game, and fired tuxkart.

And finally tuxkart proved to be my saviour, as it cribbed about DRI being disabled. The performance was terrible too, so I was damn sure DRI works with my Intel Extreme Graphics card (Intel 855 .../ I810 driver).
A grep on XFree86 logs showed direct rendering was indeed disabled. A couple of google searches and several changes in XFree86 config file later, I ended up with DRI still being disabled. The only thing that improved was the X resolution, I switched that to 1280x768 on my WXGA screen.

Now XFree86 logs are really big and I finally chanced upon a line saying DRI disabled because 4kB of additional memory required was not available. Googling this didn't helped much but then, I found the root cause , still higher up in the logs, a complaint about /dev/agpgart being unavailable. I quickly did a modload agpgart, Ctrl Alt Backspace, and there it was, my X server with DRI enabled, Tuxkart running happily, and glxinfo showing that DRI is indeed enabled.

So I quickly edited /etc/modules, added agpgart at the end, and proceeded to blog what I might require again.

Thursday, May 05, 2005

1 2 3 testing ...

Now this entry is just to test if the gnome blogspot entry really works. Seems like it does. Formatting options are limited, but this is still very convenient. If only blogger will export an API to publish pictures, I would have posted an screenshot.


To test the add link button here is a link to my resume

Tuesday, May 03, 2005

Automatic Proxy Configuration

I connect to two different networks while at home and office, and one of them uses an http proxy, while the other one doesn't.

The solution is to have an autoproxy.pac file, accessible from the localhost ( I am anyway running apache on my laptop, but the same thing should work using file://somedir/autoproxy.pac.

You configure the proxy script in Edit->Preferences->Connection Settings->Automatic proxy configuration url

So here is the one I found from the net, and the ideal version of autoproxy.pac (that didn't work)

function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(),"192.168.82.0","255.255.255.0"))
return "PROXY 192.168.82.56:3128";
else
return "DIRECT";
}

It doesn't works becausemyIpAddress() returns 127.0.0.1, which has something to do with interface metrics. So this is my modified version, that works

function FindProxyForURL(url, host)
{
if (isResolvable("server.delhi.solidcore.com"))
return "PROXY 192.168.82.56:3128";
else
return "DIRECT";
}

This would put some load on the DNS, in that server will be resolved, and it would take slightly more time, but this works, esp. in a DHCP environment.

My home network consists of a Fedora Linux router that connects to 24online cable network. Sometimes I don't want to put the router on to just access internet from my laptop, so I use this script (run as root)

#!/bin/sh

# Set environment for cable access
ifconfig eth1 172.16.6.1
route add -net 0 gw 172.16.1.1
echo 'nameserver 172.16.1.1' > /etc/resolv.conf
linc start

where 172.16.6.1 is the static IP assigned to me by my cablewalah , and 172.16.1.1 is the 24online gateway. linc is a daemon that allows you to log-in to a 24online network (you can use crclient instead, but thats closed source and buggy). Actually just saying closed source would have been enough :)

Saturday, April 30, 2005

Code Reviews

Do code reviews help. Are they some sort of magic cure, a panacea for all evils that affect us ?
Some would like us to believe so. What do I think. Having worked in a SEI CMM Level 5 company, I couldn't agree more with Taran,

I'd like to think that code reviews have value simply because I
have personally wasted a lot of valuable time in them, worrying about
alphabetizing variables and so on. But that doesn't make it so, and
nobody really can prove whether they are worthwhile are not.

Code Reviews tend to be silly things in corporate settings. They
argue about code formatting, how many spaces equate to a tab, and so
on. My personal favourite was getting trashed for not alphabetizing my
#define variables by NAME instead of what I had done - alphabetizing by
variable type, then name. Yes, these things are really done in
professional shops. Also, if nobody else in the room is familiar with
the history of the code and the function of the code - not to mention
the dependencies, and so on - is it really a code review? How can you
analyze 12 lines of code in one class when you're dealing with a
complex software system with high interaction? Not unless the people in
the room *know* the code - all of it. Unlikely.

Read it all here http://www.knowprose.com/node/82

Do I review others code ? I do, but that is when it starts failing.
(I do read code written by experts a lot , not for reviewing, but to learn how to write good code. )

Do I like others reviewing my code ? They are most welcome, provided that they point out bugs, not formatting issues. I have a set of personal preferences I have developed. Any attempt to introduce a UNIFORM coding style (guidelines) is just that, like introducing a school uniform for the programmers. I would change my coding preferences, my indentation style and my variable naming style the day you convince me that yours has some tangible benefits, well worth the efforts I put in. Till that day, I code the way I do, so may you.

The best way to overcome indentation issues and have a uniform look and feel is to use a program like indent, because the debate over tab and spaces and braces and newlines is an eternal one.


Wednesday, April 06, 2005

Linux on Compaq Pressario V2036AP

Copyright © 2004 Qasim Zaidi
Authors homepage:
http://thruput.blogspot.com

This document was created 02/13/05.
Last updated 02/15/05

System Specification

Intel Centrino Mobile Processor 735 (1.7 Ghz)

14” WXGA Screen
Bluetooth, Intel 2200 Pro Wireless Lan
5 in 1 Card Reader
USB, Realtek 100Mbps NIC, Smartink 56kbps Softmodem
S-Video Out, IE1394
60 GB, 512 MB RAM, 2MB L2 Cache

This laptop of the Pressario V2000 Family, came with 256 MB RAM,which I upgraded to 512 MB.It came preinstalled with MS Windows XP Home, with a single NTFS partition spanning the entire disk.

Linux Distributions tried on this Laptop

I first tried to install Mandrake 10.1 Community Edition on this Laptop. Installation went smoothly, and it successfully resized the NTFS partition , using ntfsresize. However, the system won't boot. It hanged in one of the startup script, so I booted into Single User mode and commented the firstboot script. This didn't helped either,as it again stopped in one of the runlevel 5 scripts. I was short of patience, so I decided to give Ubuntu a try.

I had no great hopes from Ubuntu, having read some of the reviews of how difficult its Laptop installation was. True to my premonition,the installation itself hanged quite early enough.


My thoughts finally turned to SuSe 9.2. On my desktops I run FC2,FC3 , FreeBSD & Solaris. However, I didn't wanted to run Fedora on the Laptop, and I wanted all of the hardware to be working.

As I started waiting for 3.1 GB SuSe Download to finish, I decided to give SimplyMepis a try. And it simply ran, out of the box. So I installed it on Harddisk, and thats what I am running as I writethis.

SimplyMepis


SimplyMepis is a single CD , KDE only live distribution, based on Debian. Installation is point and click, and its optimised for 586 &686 systems. Even non-free software such as Real Player are preinstalled, and multimedia support is excellent. Since I never intended to use my desktop for anything else (Desktops are much better for coding, my primary job function), I found this very impressive.


Almost everything worked out of the box. That excludes the soft modem. Wireless didn't worked initially and I am yet to test bluetooth, since I don't have any blue tooth devices.

Intel Pro 2200 Wireless adapter

SimplyMepis didn't came with ipw2200 support installed, though it did had modules for an older model (Intel Pro 2100 Wireless card). I

downloaded the latest drivers & firmware from ipw2200.sf.net.
Also had to download and install sources for kernel 2.6.7 (and later 2.6.11) as they are required to compile the driver.

After compiling the module, and making install, you will have to copy the firmware manually (and you have to download it too!, from the same location).

For compiling the modules, if you are getting a lot of errors, just go to /usr/src/linux and do make (after copying the correct config file from /boot to /usr/src/linux/.config) . You can press Ctrl-C and cancel build just after first few lines. Then go to ipw2200 extraction dir and recompile.

Once you are able to load the ipw2200 module, to make it load automatically at boot time -Edit /etc/modules and add ipw2200 on a new line.
Since this file is processed much before the networking subsystem comes up, thewireless device will be named eth0, and the other NIC card becomes eth1.

Next, you need to automate this process, so that wireless is up if
the keyboard switch is on. This requires you to edit the
/etc/network/interfaces file. Here is mine


auto lo
iface lo inet loopback
auto eth0
iface eth0 inet
dhcp
wireless_essid UP
wireless_mode Managed
wireless_key
f8ec3213432d574e63a595b647

auto eth1
iface eth1
inet dhcp

Gnome

I keep switching between Gnome and KDE. Since last few months, I
am running Gnome, in spite of being a KDE Fan, traditionally. To a
large extent, Gnome improvements and its cross platform nature (Its
also available on Solaris and Free BSD) are responsible for this.

Mepis doesn't comes with gnome, but installation is really easy.

All you need to do is

# apt-get install gnome-desktop-environment

However, when logging into GNOME, an ugly error message props
up
Error activating XKB configuration ...

Everything else worked fine. After a considerable googling around
( as this seems to be a common catchall XKB error), the fix was
really simple. Going to Applications -> Desktop Preferences ->
Keyboard and changing the layout from deflayout to US English fixed
this problem.

TouchPad

While the touchpad worked by default in Mepis, the on/off switch
won't work making it difficult to type anything, as the mouse cursor
will be moved. This is fixed simply by removing the mouseproto option
thats passed at boot to kernel in default mepis configuration. The
drawback is, scrolling doesn't works after this.

For Mepis (which I believe actuall uses debian-unstable ), I found several debian packages for Synaptics available , such as

  • ksynaptics

  • qsynaptics

  • xfree86-synaptics-drivers
    which can be installed and used
    to configure the keyboard.

    I found it easier to work with tapping disabled.

Keyboard

See http://www.peakunix.net/v2000.html

for some excellent distribution-independent keyboard information.

If you use GNOME, you need to set up the correct keyboard layout,
from either Applications->Desktop Preferences->Keyboard, or by
manually editing the /etc/X11/XF86Config-4 file.

Once you have restarted your X server with the correct keyboard
configuration, all that remains is setting the keyboard shortcuts,
from Applications->Desktop Preferences->Keyboard Shortcuts.

Arabic (Under construction)

apt-get install katoob

apt-get install ttf-arabeyes ttf-kacst

Wednesday, March 16, 2005

Random thoughts

A month has passed since I last blogged. So what happened.

One big change that happened is I got a new Laptop (A Pentium Mobile, since I finally gave up on the wait for 64 bit AMD laptop). Second is the gradual shift from Fedora to Debian.

It has been years since I am using Redhat. I am a late entrant, I guess the first one I used was RH 5.x. Then I have routinely loaded every release and upgraded to the next one.

I still have Fedora Core 2/ RHEL 3 and Fedora core 3 on my PCs (Lucky enough to have 4 desktops and 1 laptop for personal use). But my primary distro at work is Ubuntu, and at home a combination of Fedora Core 2 and Mepis. So these are all the OS I have installed on my personal computers.

Win XP Pro (office desktop1) -> Don't remeber when it last ran, or even if it runs now. Just an entry in grub menu.
RHEL (office desktop 1) -> Not used since I installed Ubuntu
Ubuntu (office desktop 1)
Win XP Home (on laptop) -> Used sometimes
Mepis (on laptop) -> used frequently
Solaris 10 (64bit AMD- Office desk 2)
Solaris 10 (32 bit Intel- Home desk2)
Fedora 3 (Home desk 2)
WinXP (Home desk 2) -> for others in the family
FreeBSD (Home desk1)
Fedora Core 2 (Home desk1)

And at the top of this, my current weeks interest is virtualization, so I sometimes run Debian on UML and FreeBSD on Qemu.

Sunday, January 30, 2005

Real to MP3

One frequent task I perform is a conversion from Real Audio to MP3. Most of my music content happens to be in real format, but I would prefer to listen to it on my discman, which plays MP3 disks. Hitherto, this required a trial version of StreamBox Ripper, an excellent conversion software, that also supports batch processing.

Now that windows is gone, I had to look for Linux alternatives. I didn't had many hopes, since real-audio is a proprietary format, but I was in for a surprise. Real Networks is paying real attention to the Linux Platform (with a community supported Helix Player, and Free/Closed Real Player). And mplayer does the job of conversion just very well. Here is a shell script that I use to do batch conversions

#!/bin/sh
INPUTFMTS='.ra .rm'

convert() {
for i in `find $1 -name '*'$3`
do
outfile=`basename $i $3`
outdir=`dirname $i`
if [ ! -e $2/$outdir ]; then
mkdir -p $2/$outdir;
fi
mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader $i && lame -m s audiodump.wav -o $2/$outdir/$outfile.mp3
done
}

case $# in
2)break;;
*) echo "Usage: $0 ";
exit 1;;
esac

if [ ! -e $2 ]; then
mkdir $2 || exit 1;
echo "$2: pathname created";
fi

if [ ! -d $2 ]; then
echo "Source directory invalid";
exit 1;
fi

for i in $INPUTFMTS
do
echo "Converting all $i files to mp3"
convert $1 $2 $i
done
rm -f audiodump.wav
-------------------------------------------------------------------------
I guess this script would also work for wma to mp3, you just need to add wma to INPUTFMTS variable.

If I had to write a similar script on Windows , how difficult it would have been. I know this because my last job involved some windows batch scripting and vbscripting. Reminds me of this saying (probably by Larry Wall), about a good programming language

Easy things should be easy, and difficult things should be possible.

Not quite windows.

A tryst with FreeBSD

Now that I have a lot of freespace on my hard-disk, (since removing windows), I decided to experiment with another OS. I use Solaris+Linux at work, and Linux at home, so the choice gets limited to
1) One of the BSDs (FreeBSD, NetBSD and OpenBSD)
2) GNU Hurd
3) Solaris 10
(BeOS & QNX I have already experimented with)

I downloaded HURD quite some time ago, but it could only be compiled from another Hurd natively, and cross-compilation didn't looked easy. In any case, Hurd isn't going to be usable any time soon, so I downloaded the latest stable FreeBSD (5.3).

Linux is no longer good enough. It has lost the exclusivity it had a few years back, so I needed something more uncommon to adorn my desktop. After all, every new kid on the block is running linux today ( or has run it at some point and given up), so you need something more to be accepted like a uber-geek, and thats where FreeBSD fits in very well. At least for the time being :)

Jokes apart, I thought I had get some idea of the BSD kernel, and see if I can port the work I am doing on Solaris to FreeBSD. The two are a lot similar, and as I wait for the Solaris sources to be opened, FreeBSD kernel sources are proving quite helpful. Sun has taken the first step with dtrace (http://opensolaris.org), but my guess is it would still take few more months.

This post, being made from

FreeBSD pluto.solar.com 5.3-RELEASE FreeBSD 5.3-RELEASE #0: Fri Nov 5 04:19:18 UTC 2004 root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386

is a proof that I have got FreeBSD and one of my LAN cards working. (which connects to 24Online cable network) . The other one still needs to be configured.

BTW, Epiphany looks like a browser well done.

Wednesday, January 26, 2005

Adieu Windows

It has been more than a month since I last wrote. I would very much like to have an entry at least once a month.
I am a long time linux user, using linux at work and home, most of the time. Still I had my machine set up for dual boot, and had to go through the rigouros exercise of formatting Windows every few months. Years ago, I would format it to get a clean new shiny system, & after every format, it seemed like I had a hardware upgrade. Since an year or so, I am still following the ritual, but for a different reason; to get rid of all the spyware.

The problem became too bad since I opted for broadband. So last time I had to format, which was around 90 days back, I decided to say good bye to dual booting windows. Of course, I still own hardware devices that are unsupported on Linux, but I am firm in my new year resolution, no windows on my home pc from now on. Fortunately, I no longer need to document my code & other stuff in Microsoft Word, so my office pc is running linux as happily. I have begun converting my powerpoint presentations to OpenOffice formats.

Bye Bye Windows, may you never reside in my PCs RAM and disk ever again !!

Amen