Friday, July 27, 2007

Tool for checking key events with curses

I'm doing a bit of curses programming at the moment. I've made a tool to check the keys entered are as expected. Do what you like with it.


#!/usr/bin/evn python
import curses
import curses.ascii

keys = {}
for name in dir(curses):
    if name.startswith('KEY_'):
        keys[getattr(curses, name)] = name

for name in dir(curses.ascii):
  if name.isupper():
    keys[getattr(curses.ascii, name)] = name

for i in xrange(128):
    if curses.ascii.isprint(i):
        keys[i] = "'%s'" % chr(i)

s = curses.initscr()
s.keypad(1)
curses.noecho()
try:
    while True:
        c = s.getch()
        s.clear()
        try:
            key = keys[c]
        except KeyError:
            key = '%d' % c
        s.addstr("Key = %s" % key)
        s.refresh()
except:
    curses.endwin()

Wednesday, June 13, 2007

Google Analytics = WOW

Wow.

I just went back to Google Analytics for the first time in a while and their new interface is just amazing.

Check it out:

Safari on Windows

So apparently you can get Safari for Windows.

There are two possible reasons I can see Apple doing this:
  1. The want to improve website compatibility with Safari - by having a Windows version hopefully more page designers will check compatibility and thus their core OSX users will get better support.

  2. They want to use this as their iPhone development platform - Safari will have a mode for running iPhone applications in a browser window the same size and behaviour as the iPhone (which will be like Dashboard applications?).

My gut instinct is that this started when the iTunes developers tried to see how easy it would be to port other apps. Apple must have a reasonable number of Windows savvy developers by now...

Wednesday, June 06, 2007

Have you mooed today?

I notice that apt-get is not the only mooer in town. Try ip moo (from iputils).

Sunday, June 03, 2007

The thin Gnome line

I'm finding recently I'm not making any significant progress on glChess. When I get around to some development after I've gone through the flood of incoming bugs there's no time to add new features! I really want to get the GGZ support into 2.20... I stopped spending time on the flood of Sudoku bugs a while ago.

It is interesting as more distributions change to Gnome 2.18 how many 1 in a million (or other appropriate large number) bugs turn up. I can only assume this user has somehow overwritten their gobject install... Weird *. There seem to be a lot of errors in peoples libraries. Hard to know what to do with these bugs as they're outside the scope of glchess but I'd prefer not to close them NOTGNOME too quickly.


* It would be good from a maintainers point of view if the big distributions like Ubuntu had a background process that audited all installed files so corruption could be picked up (and the packages re-installed).

Monday, May 21, 2007

Nouveau + Linux Graphics

One thing the Nouveau project is doing well is to make open-source graphics more accessible. There are links to a bunch of articles which while still young give insights into what does what. Looking at the nouveau source code shows it really isn't overly complicated - that hard work has already been done by Mesa. A DRI 3D driver basically requires a kernel module to do the IO and an X driver that can convert OpenGL to native card protocol. The difficulty is this protocol is not (publically) documented. But looking through the code and googling shows that a lot of the information is out there. It needs to be compiled into a "Missing Manual".

If I had the time I would love to work on a project like this. Once past a critical point the value to the open-source world would be immense.

As Dave Airlie and Ben Skeggs said at LinuxConf.au; "Graphics drivers are not that hard..."

Sunday, May 20, 2007

Gnome Games Icons

Gnome games now has new Tango icons in all resolutions:


These were made some time ago by (mostly) Daniel Derozier but only some of them were in use in 2.18. I found out about these icons from the Tango mailing list and found there was some complications getting these icons used (see bug 354507).

What seemed to happen was an all too common situation in open-source where everyone wanted the change but it wasn't used due to confusion/politics/endless discussion. It seems very common with distributed development (with people you have never met) that feedback can come across as criticism. Without formal management it's very easy for issues like this to be missed and fall through the cracks.

One thing that I think helps is to divide the change into smaller parts. For instance if a bug is opened with a change that is generally good then commit that change and aim to open more bugs to fix details with the change. If all the details must be fixed before committing then the change is in danger of never reaching completion or ending up in a design by committee situation.

(note that this post is feedback and not criticism!)

Sunday, May 13, 2007

Too many parodies...

I've just watched too many Get a Mac parodies... This one was quite good though:



I use Macs a lot a work for point-of-sale and applications and have been generally impressed with them. They can be tricky locking down but I imagine the other OSs are similarly difficult.

Monday, May 07, 2007

GGZ

It got to 3pm today and I decided I just couldn't be bothered battling Java all afternoon when I'd really prefer to be working on glChess. So I just went home and did that (I love being a contractor!).

So glChess is getting closer to having GGZ support...



Oh, and it really is wonderful to work on a well designed protocol like GGZ. ICS is OK if you're a human but a nightmare for a computer!

Wednesday, May 02, 2007

Poisonous People

I finally got around to watching my first Google Tech Talk, How Open Source Projects Survive Poisonous People (And You Can Too). It's a really good watch as it both shows how to spot and avoid trouble makers but also how to give good feedback as a project member (hopefully so you're not poisonous too!).

One point of particular interest was their recommendation not to put your name in files - by doing this you are implicitly claiming "ownership" of the code which will discourage potential developers. From looking at other peoples code I think I agree with this idea and plan to remove my name from code in the future.

Saturday, April 28, 2007

Gnome bug triaging

We're getting a lot of bug reports flowing in for Gnome games. I try and knock off a few each weekend but progress is still slow. Most are coming from the automated reports from Feisty users.

So here's my top 3 bugs that need to be fixed asap:

  • #409172 - Sudoku crashes when loading. Haven't looked into this at all but we probably get a few reports each day

  • #418427 and #412690 - Both Sudoku and chess can't find their libraries on Feisty - I suspect this is an upgrade issue only but none of the many reports have any information on how to reproduce

  • #428560 - Some dubious Sudoku code that extracts an integer from label text. Doesn't work when the label is translated. (I've been bugging Joel to fix this).


We need your help!

Saturday, April 21, 2007

Upgrade complete

I've now completed the Edgy->Feisty upgrade. I went to sleep at 1:30 am and continued this morning. I did an network upgrade and it took and estimated 5-6 hours. And the result is? I think I've gone slightly backwards.


  • The installer failed to complete due to the poor quality of the VMWare packages. They've now been removed.

  • fglrx acceleration still does not work. I've changed to the "radeon" driver which runs but is unreliable. I can get the desktop effects working (wobbly windows got annoying after one minute) but playing video stops working when the window looses focus. I noticed glChess renders both the 2D and 3D at the same time, I'll see if this is a driver or glChess at fault.

  • And most annoyingly the US keyboard layout has stopped working for my second keybord. I can't type '/' or '|' which is very annoying in the shell
  • (the keyboard configuration shows the correct layout though).


For me both the Edgy and Feisty upgrades have been disappointing for me. I have a Dell Inspiron 6000 which I think is fairly common and I hope support gets better if Dell starts distributing Linux!

Friday, April 20, 2007

Sunday, April 15, 2007

I've been running Google Analytics on the glChess homepage. Looking at statistics over this period shows the visitors are dominated by the French and Italian:



Are Europeans big chess players or big open-source users or both?

Friday, April 13, 2007

Xeyes in real life

Xeyes in real life. Cool.

glChess spam poetry

Seems glChess is now a sufficiently well know term to be included in spam poetry.

The Commission has concluded that " safeguards schachclub are imposed by federal skakcomputer law and forensic science is webchess glchess practiced go chessboard schachcomputer far less efficient than openings tim krabe rochade ...


I don't know whether to be flattered or annoyed.

p.s. I found this from a feed from Google Blog Search - this is a great way to keep track on what people are saying about your project. Most people don't write to you, they just write about you...

Monday, April 09, 2007

glChess 1.0.5

So here it is:


Yes, it has (simple) timed play support. It needs some cleaning up in the code but due to limited development time I thought it best to "release early".

Notice the navigation buttons are now on the left. I liked the symmetry of them on either side but as a user pointed out when you are in high resolution it takes too much mouse motion to move between them.

The other notable change is the 2D board now rotates and you can choose (from the menu) which side of the board to view.

These changes will be in the Gnome 2.20 release.

Enjoy!

Sunday, April 08, 2007

Beginners guide to Gnome Python games

In Gnome games we need more help to squash some bugs. I've been bogged down squashing Sudoku bugs which aren't too difficult - just time consuming. It's a great opportunity for you to get involved. I think it's hard to jump into development so here is a step by step entry guide to fixing bugs. Note the following instructions work fine for glChess too.

First install Gnome games. You can install this anywhere but I usually make a subversion directory:

$ mkdir svn
$ cd svn

Check out the development version:

$ svn co http://svn.gnome.org/svn/gnome-games/trunk gnome-games
$ cd gnome-games

Configure the package:

$ ./autogen.sh --prefix=/tmp

This will get the software installed in /tmp, you might want to use ~/build or something similar instead.

For the above you will need the appropriate development tools installed. This will be distribution specific so unfortunately you're on your own here... If I remember which ones I installed on Ubuntu I'll state it here. Oh and on Ubuntu Edgy edit configure.in and change GNOME_PYTHON_DESKTOP_REQUIRED=2.17.3 to 2.16.0 because it works fine with the old (installable) version.

Install Sudoku:

$ cd gnome-sudoku
$ make install

To run:

$ PYTHONPATH=/tmp/lib/python2.4/site-packages/ /tmp/bin/gnome-sudoku

Now here's the cool part - because Sudoku is written in Python you don't need to recompile to make changes... What I do is edit the files in /tmp/lib/python2.4/site-packages/gnome-sudoku and run again. You can add print statements, make radical changes, whatever you like. And if things get too broken overwrite the install with another make install.

When you've fixed the change you need to make a patch to attach to a bug report. To do this you need to update the files in ~/svn/gnome-games. What I use is Meld:

$ meld ~/svn/gnome-games/gnome-sudoku /tmp/lib/python2.4/site-packages/gnome-sudoku

Once you've got the changes merged into the checked out copy make a patch:

$ cd ~/svn/gnome-games/gnome-sudoku
$ svn diff > your_changes_description.patch

And send that in.

Don't worry about the patch being perfect, the developers who know the codebase better will look it over and modify/suggest changes to you. It may take time to get a response because we're all volunteers but we do appreciate the work - We need more help and you're the right person for the job! The first patch is always the hardest too :)

Feedback very welcome.

Friday, March 30, 2007

Working with Java

Or should that be Working against Java...

I've more-or-less come to the end of a project refactoring a large Java GUI application for my company and I now feel I can justifiably have a practical opinion on Java. This was my first commercial work with Java and I'll compare it to C/Python/GTK+ which I have used both commercially and in open-source projects.

Java is far more complicated than it should be. Count the number of methods each class has when browsing the documentation. The complexity of the standard library exceeds the complexity of the problems you solve with it. Compare it to the Python or even C library. Instead of containing the basic tools and tools that you use frequently it's full of cruft. I think the programmer should either build up more complex functions themselves or use higher level functions from a different namespace (compare GL and GLU libraries in OpenGL).

AWT and Swing are just a complete mess. Sure this is for historical reasons but Java needs a serious replacement. Maybe SWT is it but if some leadership is not taken to make a "standard" GUI that works I cannot see vanilla Java surviving compared to something like .NET. Case in point, java.awt.Component has four variations on getting keyboard focus. And reading the documentation on each is just worring... You may not get focus, you should use the requestFocusInWindow() because it is more cross-platform. I used to work with a commercial Java developer and he described the cross-platform support as write once; test n times. I now understand.

Packing in AWT/Swing is just too difficult. The simple packing models are too simple for most cases and the complex ones create too much code. While the GTK+ model is more complex to start with I'm always surprised how my windows "just work" (try shrinking a Java window and see everything get messed up). Java needs a universally accepted equivalent of Glade or XAML.

Connecting signals takes too much code. Using Listeners requires you to write loads of empty methods to catch signals you want to and Adapters can't be inherited if you're already extending another class. I hate inline classes with a passion (so much code for so little behaviour!). Using SwingUtilities.invokeLater() (which is a really practical method that should be more central to Java) to create a runnable class every time you want to access one method later? Overkill. Why not just gobject.idle_add(method)?

Threading... All I can say is threading is an optimisation. I've seen too much excessively threaded code that is very hard to maintain. Java seems to implicitly encourage you to thread which I do not like. I don't like that a lot of the Graphics operations don't seem to have an easy way of doing them synchronously. Threading is an optimisation.

Really it's the library that lets Java down. The language is a huge improvement over C. It lacks a little in low level access (I have not really done this in Java but from a first glance it may be missing something like Pythons struct module). I dislike the lack of flexibility over Java but I do like the compile time checking for catching bugs. I must try a .NET project to see if .NET doesn't have the baggage Java does. I get the impression the dominant members of the Java community have the opinion "Don't change anything, we've got too much code" as opposed to "Keep version X stable as we have lots of code, but make version X+1 fix the big problems in X".

My opinion of Java? Not ready for the enterprise :)