Electricmonk

Ferry Boender

Programmer, DevOpper, Open Source enthusiast.

Blog

Failures count more than Successes

Tuesday, February 8th, 2005

Failures count more than Successes. A nice article on the understated importance of correctly handling software failures.

Natural order sorting

Tuesday, February 8th, 2005

It’s sometimes humbling to learn new things about programming which are actually really basic stuff. Things that should have been obvious but which you never really thought off.

Take for instance the subject of sorting. Sorting is done via an algorithm which compares strings (a collection of characters). There are different types of comparisons from a programmers perspective:

  • Normal comparison
  • Case in-sensitive comparison
  • Numerical comparison (comparing two strings which represent numbers)

That last one, numerical comparison, is about ASCII values (actually, the second is too, but less so). Normal string comparison compares two strings using the value of the individual characters. For instance the string “abc” consists of the ASCII values 97, 98 and 99 and “bcd” of 98, 99 and 100, so “abc” is smaller than “bcd”.

However if we have the string “100” and the string “20” and these are compared using the above string comparison routine then “100” will be smaller than “20” because “100” has the ASCII values 49, 48 and 48 and “20” has the ASCII values 50, 48. 49 is smaller than 50, so “100” is seen as smaller than “20”. (This, incidentally, is called lexicographical comparison) This is what the numerical comparison is about. Instead of comparing the ASCII values, it compares the real values of the string (100 v.s. 20 instead of 49 v.s. 50).

Nothing really new for me about this.

But what if you’ve got the following strings? “img1.gif”, “img2.gif” “img10.gif” “img15.gif”? They will need to be sorted by ASCII value, because the string contains letters, but also by numerical value because it contains numbers. If we use a normal comparison function the list will get sorted like this:

  • img1.gif
  • img10.gif
  • img15.gif
  • img2.gif

Also not new for me, and in this case quite easy to circumvent by stripping of the first three chars. But things can get quite complex pretty quickly. What if you’ve got these strings: “1-2”, “1-02”, “1-20”, “10-20”? I never really thought about how these things were handled since I never really needed it.

Turns out though that most programming languages have a comparison function (or lib) for this so called ‘Natural Order comparison‘ (sometimes also called ‘collate‘ comparison). Here’s a little list:

There’s probably one for your favorite language too. From now on I’m gonna use it instead of the default strcmp().

Your new Open Source project

Tuesday, February 8th, 2005

Nice article on Newsforge

How to plan your new open source project

Lots of startup projects on the big online free software repositories have been abandoned right after being created, or linger in alpha stage for many years. I have founded four open source projects, of which two have been successful, while the other two just stopped and faded away. From that experience, here’s some practical advice on how to make your project more well-known, how to motivate others to join your project, and how to make sure it stays alive and active for a long time — maybe even reaching a 1.0 release (which should be part of every project’s goal, should it not?).

Finally something done on dutch press propaganda

Friday, February 4th, 2005

I couldn’t find any websites carrying the news item, but I just heard it on the radio. Something is finally being done about propaganda in the dutch press. For months now, I’ve been hearing news items in which some criminals race/ethnic background was mentioned which had absolutely nothing to do with the news report in itself. It was making me sick to see such obvious, let’s be honest, anti-foreign-ethnics propaganda. Minister Donner(?) has finally stood up against this trend in the media and believes the ethnic background shouldn’t be mentioned unless related to the news.

Finally, after years, it seems our government is becoming a bit saner again.

Becoming a Debian developer

Thursday, February 3rd, 2005

NewForge has a nice article on becoming a Debian developer.

The article gives nice insights into the process of becoming a Debian developer. It’s not as easy as it seems. I know some people that know some people that are Debian developers, and I’ve heard about the keysiging thing before. For some reason, I always thought that would be the hardest part of becoming a Debian developer. (The article does stress the importance of an advocate btw). But when I read about things like this:

My P&P [Debian Philosophy and Procedures] questions started with the necessary stuff about understanding the Debian Social Contract and the DFSG (Debian Free Software Guidelines). Then they moved on to some fairly difficult questions about licensing issues. Then there were a long string of questions about details of the normal Debian practises for things like handling bug reports, non-maintainer uploads, internationalisation of packages, and so on.
The testing of knowledge about the P&P shouldn’t be that hard. I’ve read them a bunch of times, and I’ve got the impression that I know what the soul of Debian is all about. But presenting soon-to-be-or-not-to-be developers licensing issues is an actual test of your understanding of (and compassion for ) the Debian project’s goals. I’m not sure what kind of questions they ask, but they will probably be a mix between tough legal and moral problems. Then again, apparentelly you get to do it over and over again until you get it right.

Personally I have no desire to become a Debian developer. To be honest, it seems that being a Debian developer takes up enormous ammounts of time, which I simply don’t have.

Censorship

Wednesday, February 2nd, 2005

I keep finding more and more insightful or otherwise interesting articles on useless-knowledge. For instance, an article on press censorship. A small quote from the article:

Now, I do recall a certain FIRST AMENDMENT in the Constitution that prohibits censorship. Furthermore, there is a reason that we have free press. It is to keep us informed of what is actually going on so that we are not fed propaganda. If the government is allowed to censor any articles that they want, then we can be led into a completely false idea of the world.
— Jack Lepiarz, Should Government Censor Newspapers?

I’m particularly interested by this line “to keep us informed of what is actually going on so that we are not fed propaganda”. It made me wonder about something. Is the press really telling us ‘what is going on’, or is it in fact already spreading propaganda? I’ll explain what I mean:

I’m fairly sure that the press in my country is free. Ever since we’ve seen some terrorist activity here, our press has gone the same way as the U.S media. We are being bombarded with terrorist threat news-items. Suddenly, the press is making it seem like they’re everywhere. Some months ago, it was not uncommon if the media reported three or more bomb-threats a day, most of which were fakes.

How is this relevant? It’s not. Not for my country, at least. However, it is relevant in the U.S. There, the presidential candidates made a big point of terrorism. It was, in fact, probably the most important thing on the political agenda. And both candidates used the press to push their political agenda. “Vote for me, and terrorism will be fought.”, “Vote for me and we’ll end this non-sense.”

So, even though perhaps it wasn’t meant that way, the press coverage of terrorism had become propaganda. Even without being censored. Does this mean we might as well censor the media, since it won’t matter? I don’t believe so. Yes, there will be positive uses of censorship. A highly moral governing body might use it to stop ‘popular’ and ‘hot news’ reporting, which I think would be a good thing. It is however more likely that censoring will be misused to push even more political agenda’s even faster and more effectively.

The Joys Of Smoking

Monday, January 31st, 2005

The Joys Of Smoking.

ListPatron and GtkGrid

Friday, January 28th, 2005

So far I’ve been using GTK’s GtkTreeView in ListPatron. While this works fairly well, editing and manipulating columns is quite a hassle. For instance, it is practically impossible to select a column, let alone more than one column.

Someone on #gtk+ (FreeNode IRC network) pointed me to GtkGrid. I’ve done some research on grids for GTK 2.+ versions, but couldn’t really find anything useful. Must have overlooked GtkGrid. After some searching in the Gnome mailinglists, I stumbled upon this link

When GtkGrid was first suggested to me, I thought to myself “This is gonna require a major rewrite of ListPatron”, which I didn’t like at all. But when I found GtkGrid’s homepage, I was much delighted by the following comment on the site:

Not only that I’m reusing existing GTK+ code but I’m also trying to make the API for GtkGrid as close as possible to the GtkTreeView API. Changing your code from one to the other is just a matter of changing 2 lines.

Guess I’ll be rewriting ListPatron to use GtkGrid instead.

Only thing that’s bothering me is this:

First of all, for version 0.2.2 you will need to apply the patch grid-0.2.2.patch to GTK+ if you want to use the Combo renderer

ListPatron isn’t using Combo boxes for cellrenderers yet, but I was planning on using them. Now, I don’t want to force people to recompile GTK just so they can use ListPatron with Combo boxes in the sheets. I still have to find out if it’s just for version 0.2.2 that this patch is required, but if it’s also required for future versions, I’m not sure I’ll be happy with that.

Update:
Some problems:

  • Development seems to have stopped.
  • It’s missing some features I need

When I find the time (hahaha, I always say that) I’ll e-mail the author and ask him what’s the status on the project.

ListPatron v0.1.1 released

Thursday, January 27th, 2005

Ooh, a major bug crept into v0.1 of ListPatron. Apparently, if you loaded a ListPatron file, it wouldn’t save that file anymore. Only new files were saved. Saving also still worked if you used Save As... Stupid! It’s fixed in the v0.1.1 release. (Also fixed the README, which said you had to have GTK development headers for v2.4.6, where in fact you needed v2.4.14).

Nethack statistics II

Thursday, January 27th, 2005

Did some more work on the Nethack Statistics. (Script attached to the end of the file)

It’s still much to slow. Running it on my logfile with 288 lines takes 8 seconds. 1 Second would even be too much for such a small file. Of course, the Bash script is horrible, and it calls on grep and cut way too often. Perhaps I’ll rewrite it in PERL or something.

The text of all posts on this blog, unless specificly mentioned otherwise, are licensed under this license.