Friday, September 22, 2006

Friday, September 15, 2006

Stuff to watch out for

Here are some projects that I must try/use/keep an eye on. I normally see things like this whizz past on Planet Gnome but forget to bookmark them.

  • Hula - Open source email/calendar WWW server. Looks like it could be as good as Gmail/Google Calendar. (Novell)

  • Dogtail - Automatation framework for GUI testing (RedHat).



Oh and if anyone wants to pay me to work on cool open-source projects like this send me a message!

glChess... Now in 2D!

If glChess goes into Gnome games then I think it needs a 2D mode for those without fast 3D hardware. So after some shameless code stealing from pychess here is the prototype:



You can play a game and all - I'm suprised how easy it was to add in. The hard work now is making the UI able to switch and the rendering code to be efficient.

Oh and I guess I need a new name now...

Wednesday, September 13, 2006

Debian and Python

I've just got glChess to work under Debian Unstable (Sid). Details on the homepage.

This is all thanks to a guy called Guy for reporting it didn't install. I ended up getting Debian running under VMware player and found the issues. They are:

  • Debian doesn't have the Python version in their library package names. So where in Ubuntu we have python2.4-gtk2 Debian now has only python-gtk2. And this package contains the gtk2 bindings for both python 2.3 and 2.4. This seems silly because I can't specify (easily) that I want Python 2.4 and what happens when Python 2.5, 2.6 ... are released? What if you want to save space (e.g. on an embedded system) and drop all support for 2.3?

  • And the madness continues. Instead of putting all the non-core libraries in /usr/lib/python2.4/site-packages they now go in /usr/lib/python-support/python-gtk2/python2.4/. So even though you have only one library address space they're split across directories. Why? It just seems to be overly complicated and an easy way to have address space collisions. I had to rebuild the GtkGLExt bindings but this turned out to be as easy as replacing dh_python with dh_pysupport (I love you debhelper!)



So the long and short of it is I need seperate packages for Debian and Ubuntu. The glChess package only has different dependencies but the GtkGLExt bindings need to be built differently. *sigh*

MIMEfield

I've been working on registering glChess as the PGN file mime-handler. I'd heard legends on how much of a mess the whole MIME thing was (and how it was getting better with freedesktop.org). Well there's certainly a lot of MIME stuff around.

Freedesktop.org has a spec on detection that seems quite good. Unfortunately registration for programs to execute this mime type is elsewhere and so are the icons for this type. Interestingly the mimetypes/ directory in the icon schemes doesn't just contain image files with the mime type name (correct me if I'm wrong!). So you have to register a mime type to an image name which seems redundant. Freedesktop.org also seems to be working on at least some of these issues.

I was just googling my references and I think I want to read this.

In the process I've found a bug in the freedesktop.org MIME database or Nautilus (or both) - PGN files don't get detected as application/x-chess-pgn so Nautilus wont suggest glChess to execute them. It took me a long time to realise update-mime does not update the database Nautilus uses (use update-mime-database /usr/share/mime).

Oh and if anyones noticed there's still a rogue import dbus in glChess 0.9.8. It wont cause any problems if you have the python dbus bindings but it's an unintended dependency that will not be in 0.9.9.

Tuesday, September 12, 2006

Whoops.

0.9.8. Had some DBUS/Avahi networking code enabled by accident in 0.9.7.

Sunday, September 10, 2006

glChess 0.9.7

New version!

This mostly came about when I actually decided to try playing a game. Turns out somewhere along the line I buggered up the logic with the AIs and they could no longer play as black. And this led onto some long-standing AI issues that had been bothering me...

1. The GUI now contains a dialog of AI communication - this should make debugging much easier.
2. When glChess quits it sends signal 9 to the AIs if they don't die in 500ms. This is a bit of an ugly hack (see cecp.py) but I can't find a logical system command to do this.
3. When glChess crashes it kills the AIs. This was a big problem as GNUchess goes off into la-la land and eats 100% CPU when its controller dies (you notice the battery dissapearing on a laptop!). I need to add a GUI dialog to show the stack trace now. After a crash the game is saved too which is good.

Oh, and this all got triggered by me adding support for the Phalanx chess engine. From small things...

Note to self: REFACTOR, REFACTOR, REFACTOR!

Wednesday, August 30, 2006

/etc/iftab

As a follow up to my previous post about ifconfig... I have just discovered /etc/iftab. I love you udev! It's exactly what you want and expect - a table of ethernet addresses to interface names. Done. Aparently there was an older tool called ifrename that used to do this before udev. But yay! Problem solved.

glChess in the news

Gnome games is looking to drop one game and add another for the Gnome 2.18 release. An obvious inclusion is a chess game and someone has suggested adding glChess!

I like this because:

  • glChess is simple - I'm trying to keep clutter to a minimum (many existing programs have a lot of internal AI information / options). glChess would(/should) be good for people who just want to play chess. The networking (when I finish it) should be simple too

  • I like Gnome!



I am a little worried about:

  • performance - The use of 3D means many Gnome users would have rubbish performance. This could be solved by making glChess support both 3D and 2D (the internal design is keeping the scene rendering seperate from the rest of the code, it shouldn't be too hard to make a cairo interface).

Tuesday, August 29, 2006

How to render using Mesa

It is remarkable hard to get your OpenGL software to avoid using hardware acceleration. I required this to test some glChess bugs.

Under a DRI system you disable DRI by quoting out the Load "dri" line in the Modules section in /etc/X11/xorg.conf. After restarting X everything 3D should be slow.

Under an annoying non-standard system (i.e. nVidia) I believe you can link your C program using something like -lGLMesa. However you are royally screwed if you use something like the Python bindings. Then you would have to do some recompiling/magic relinking to make it all work.

glChess 0.9.6

New release!

This version fixes a number of issues with software rendering. I found an interesting bug in Mesa which is now avoided (bug is fixed in Mesa CVS).

Also has a bunch of cosmetic fixes (about dialog, starts with empty board, changed perspective slightly, added icon) and an Italian translation. This release has some disabled networking code to be hopefully re-enabled in 0.9.7.

Friday, August 25, 2006

Arrgh! I hate developers!

Constantly having to change my networking configuration is driving me insane. So I apt-get source ifupdown'd to start some hacking.

I can't believe how complex people manage to make their code - this is a program with only ~2000 lines of C code but it's just unreadable. The indentation is all over the place and there's wacky documentation preprocessor directives spilt all through it. There's probably some elaborate IDE that makes it readable but come on - stop making write-only code people!

Monday, August 07, 2006

Reasons not to use low level languages

I followed a link from Planet Gnome to a patch for Evolution that fixes a lot of memory leaks. Well sure, I thought, it will be fixing some obscure bugs right? Well it turns out a lot of the patch changes are replacing lines like this: /* TODO: Free stuff */. So the product is knowingly produced with memory leaks. Ouch.

I can't blame the developers too much - in C I always found it a mission to keep track of memory (this sort of thing takes time from adding content) but it just goes to show. If you can use a garbage collector, do - anything else should be treated as an optimisation. And any optimisation you do should be able to justify (ideally with numbers).

Thursday, August 03, 2006

A nice webserver


Saw a link to Cherokee today, looks like a nice, lightweight and easy-to-configure web server. I am not a fan of apache (bloated and obscure) so I'll be trying this one next time I need a web server.

Tuesday, August 01, 2006

Google calendar + Evolution

For those familiar with Gnome there is a calendar widget on the upper taskbar (by default). This is probably one of the most useful features of the Desktop: it shows the full date and clicking on it brings quickly brings down a small calendar. I use this all the time and are constantly tripped up when using Windows (their one only displays partial date, tooltips take ages to come up, double clicking on it brings up config window with calendar that takes ages).

So today I thought since this mini-calendar was linked to the Evolution Data Server (implemented I don't know how many Gnome versions ago), perhaps I could put my Google Calendar in there. So double click on a day and Evolution (slowly) pops up. After getting lost in the heavy interface I go Menu->New->Calendar, copy the address Google Calendar provides in the settings and voila! My Gnome desktop now displays all my appointments (and birthdays) one click away from anywhere! 11 chainsaws out of 10!

Monday, July 31, 2006

Playing with Avahi

Today I was playing around with Avahi for inclusion in glChess. The documentation is a little thin but luckily there are some helpful people in #avahi. So in glChess subversion _glchess._udp (still don't quite get the Zeroconf naming) services show up in the (new) join game dialog. I've got the transport layer working for the network so it should all come together some time soonish.

But I can't post without a bit of a gripe... It seems a lot of APIs have ultra generic function/method calls which means when you pass in an incorrect parameter you get some useless error message. Developers *please* explicitly check the passed variable signature is correct and generate a meaningful error message if it does not.

Oh and once the networking is done I need a serious refactoring session.

Friday, July 28, 2006

Broken base tools that need fixing

Here is a note to myself for base Linux tools that require fixing:

  • ifconfig - interfaces are configured by kernel name not MAC address. You should be able to do either as Linux randomly assigns interface names (at least to ethernet devices). On my work PC I have three network interfaces. I think the issue is the USB one gets detected at different times on boot

  • Fix 'ps' - As stated earlier it does not print entire process names even when it has loads of screen real-estate. I think the whole process could be rewritten and work much better.

  • etc etc (post comments of more)

Thursday, July 27, 2006

The crapness of old software

Last weekend I was bitching to Robert about how 'ps' was crap - it only displays 15 characters of the process name no matter how wide the console is.

e.g.

bob@alchemy2:~$ ps -A
PID TTY TIME CMD
1 ? 00:00:01 init
...
4995 ? 00:00:00 gnome-power-man


Sure the Gnome Power Man is a great process but other examples don't work so well. ;) So together we checked out the source (apt-get source procps) and had a crack at it.

Holy crap it is an obscure mess. I have previously found a bug in mount and it was a mission to track it down - that code is appalling too. Why is this old "base" code so crap?

Eventually I found out how the columns were generated in 'ps' and found the column is hard-coded to be of length 15. You could change it to be bigger but the columns can be ordered in any way so if you wanted a complex output it would be too wide. It looked like the column was supposed to expand if it the last one but I couldn't get the damn thing to work. The data is copied so many times through global variables it is too much of a mission.

So I gave up still not sure where the actual printf is...

Tuesday, July 25, 2006

The Python Challenge

Mr Hunter introduced me to the Python Challenge. It's a cool puzzle that presents you with lots of computationally complex situations (which you can solve suprisingly quickly using Python). I think we got to about 15 before I thought I should catch a train home.

I enjoyed annoying him by doing it all from the command line (no smelly files/IDE for me :P)

Friday, July 21, 2006

Ubuntu 6.06 versus 128MB RAM

Yeah when they say that Ubuntu 6.06 recommends 256MB+ of RAM to install they are not joking. I was trying to install it on a Dell Optiplex GX110 and it ran like a dog. The intaller died on the partitioning step (looks like the /dev entry didn't appear). So I deleted the partition table and rebooted. This time since there was no handy swap partition it ran like a very sick dog.

Insert a 128MB DIMM and it works like a charm. I never checked the RAM when I started - it would be a nice feature to write in large letters somewhere at the start of the installer "YOU HAVE THIS CPU, RAM, FREE SPACE" etc. Oh and when did it get so hard to match RAM to a PC? It took many attempts to find a working DIMM (eventually canabalised from an old Optiplex GX110). I'm sure back in the 386 days any RAM would do :)