Saturday, December 10, 2005

oh the irony of time: Paul Graham on the switch of from Common Lisp to Python

This is just another stupid post on the switch of from Common Lisp to Python.

I did a quick search on for all Paul Graham posts, and look at the two top posts in this particular order:

startup using Lisp
One of the cooler new web apps I've seen is written in Common Lisp. It's an "aggregator" like Slashdot, except the stories ...
- comp.lang.lisp - Jul 26, 12:17 pm by paulgraham

Reddit rewritten in Python
I told them it was fine with me if they wanted to rewrite the thing in Python. It's not as if the program is some hugely sophisticated collection of macros and continuations. Most of the complexity in the software is social, rather than technical. Python is perfectly adequate for it. Incidentally, the last straw, I've been told, was some bug in CMUCLthreads that kept making the system crash.
- comp.lang.lisp - Dec 9, 1:00 am by paulgraham

Thursday, November 17, 2005

another beautiful example of why opensource just works

On devmeeting.2005-11-15.log you can see the log of a 3 hours IRC session where the project leader sorts through a bunch of open tickets on the bug tracker while giving directions to several contributors. Really amazing. Try doing that at work !

Thursday, November 03, 2005

Dilbert, Placebo and Focus, by Scott Adams. Found about it recently. It's hilarious, definitely a must-subscribe.

13 things on nature that do not make sense (mostly physics related. The piece on placebo is really interesting)

Prototype photo camera: First you take the picture, then you care about what to focus.

Wednesday, November 02, 2005

Why I stopped developing end user apps with Linux as the target platform long ago

I always suspected Linux usage was near 1% when considering all end user computers but then I came across this ranking of operating systems visiting the BBC homepage which tells that only 0.41% of the 32 million requests to the BBC servers analyzed came from Linux users.

It means that for every 1000 users stumbling by my software only 4 of them will be able to run it !

Wednesday, October 12, 2005

Java performance urban legends

From Java theory and practice: Urban performance legends, revisited (I guess this small article got slashdotted a few weeks ago, so everyone probably has already seen it):

Allocation in modern JVMs is far faster than the best performing malloc implementations. The common code path for new Object() in HotSpot 1.4.2 and later is approximately 10 machine instructions, whereas the best performing malloc implementations in C require on average between 60 and 100 instructions per call.

Good to know about that since I always thought anything Java would be slower than C++. Makes me feel less guilty when writing Java.

All this also reminds me of this sig I saw once on usenet:

The march of progress:


printf("%10.2f", x);


cout << style="font-weight: bold;">


java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
String s = formatter.format(x);
for (int i = s.length(); i <>

Friday, October 07, 2005

Spatial hierarchical set clustering, anyone ?

Yes, that was the best way to describe the problem I have at hand while designing/implementing the new thumbnail browser widget for imgSeek2. I have a collection of images, each belonging to one or more sets, and I want to implement an algorithm to find the best spatial representation of this on a grid.

I have conventional data structures telling me which images belong to each set and which sets an image belongs to. In other words (I mean, pictures), I have this:

and want to draw this:

So, which approach would you recommend ? Keep in mind that drawing thumbnails using a grid like on the 2nd picture is just as hard as drawing them like Venn diagrams on the 1st picture.

It's really hard to google for such an algorithm so I'll have to come up with something on my own. My first thought is to iterate all sets and generate a tree (not a binary one since a set may have more than 2 subsets) as balanced as possible using a combination of the number of images on the set and number of images shared with other sets as a weight to each node.

I found an interesting usenet post and it seems that R-Tree is the name of the spatial data structure I'm looking for.

Any other ideas ?

Something I'd like to ask an economist

Just in case there is one right now reading this post or someone who also thought about this: There is an annual index compiled by The Economist which basically tells how much a Big Mac costs in dollars on each country. That is, you take the cost for it on the local currency and then convert that amount to USD.

My understanding is that the variation from one contry to the other is explained by how expensive it is to produce and serve a Big Mac on each country. That reflects how expensive is labour, ingredients, etc. OK. So I live in Brazil, and according to that index, the Big Mac on the USA is 28% more expensive probably due to what I mentioned, but how can we explain the absurd discrepancy between how much the engineering consultancy company I work for in Rio de Janeiro can charge for its services to local customers and one doing the exact same thing would charge if it was based in Seattle ? I'm sure the difference is well above 28%, and could be estimated even higher if taking into account my salary here and what I'd make working abroad.

One conclusion I could arrive is that the discrepancy gets bigger as we move up in the cost chain of services, but why ? Is my conclusion correct ?

I thought about it after reading some chapters from Freakonomics. I got a bit interested about this economic phenomenon and wondered if anyone out there know of any other good book discussing this topic in laymen language.

Sunday, October 02, 2005

Yet another multithreading pitfall: random numbers

This one cost me a few hours to detect. Always remeber to initialize the stdlib random number engine for each thread with something like
/* initialize random generator */
srand ( time(NULL) );
otherwise they will all generate the same sequence of "random" numbers.

I wish I could avoid multithreading on this project, but I can't since it's a QT GUI and responsiveness is crucial to the end user.

On a side note: does anyone out there know of a compilation of common multithreading pitfalls floating around the net ?

Saturday, October 01, 2005

The Million Dollar Homepage. One dollar per pixel.

There is no limit to human creativity. On The Million Dollar Homepage, you pay a dollar per pixel of advertisement, and guess what ? The owner is selling 1 million pixels. So far 240,100 pixels have been sold.

And to prove the first phrase on this post, someone is doing the same thing, but charging 20 cent per pixel, with the following slogan "Why pay five times more?". The owner actually bought some pixels on the million dollar page.

On web based project management software, collaboration team and workgroup

Are you also tired of reading about web based project management software ? Well, you are right about feeling this way, because there are over 220 products like this. And just in case you feel like evaluating them in order to start your own project my advice is: start with JotSpot. It goes well beyond the "online collaboration tools" mindset and actually delivers an application framework melted inside a wiki.

Friday, September 30, 2005

mozy - free online backup

mozy: free online backup solution. I hope this works over the http proxy I have at work, otherwise it will be useless to me.

Update: I just asked them ( and they told me Mozy will work with any proxies that allow access to secure traffic (https). Their FAQ should now cover this and include a section dealing with popular firewall software.

Thursday, September 29, 2005

Microsoft and JBoss together ?

Interesting quotes from this C|Net article:

For instance, Chief Executive Steve Ballmer once famously called Linux and the open-source philosophy a "cancer." More recently, Ballmer has changed the tone of his rhetoric: "We compete with products. We don't compete with movements," he said in a recent interview with CNET

And when I was just about to say that JBoss sucks a lot on Windows:

And Shaun Connolly, vice president of product management at JBoss, said that more than half of its customers use the JBoss Enterprise Middleware System product on Windows.

Saturday, September 24, 2005

Web Services Infrastructure and template languages

Enlightening post regarding web services infrastructure and template languages at Web Services Infrastructure: Kid Templating [] by Ryan Tomayko:

Which brings us to Kid as “Web Services Infrastructure”. The concept is simple: for whatever reason, template languages (PHP, ASP, JSP, CFML, ERB, Cheetah, Tapestry, Velocity, etc.) have become a fundamental tool for web development and their usefulness is in no way limited to presentational data (HTML). Templates are simple, templates are cool. You throw some junk in there and look at the result. If the result isn’t right, you tweak your template until it does look right. There’s no layers of magic to get in your way. When something doesn’t come out right, you change the template. There’s no “management” or “container” involved.

There’s no rule that says templates must only be used to generate HTML. Indeed, many of the RSS and Atom feeds in the wild are generated from some form of template. They are never automatically-generated-behind-the-scenes using language bindings and are very rarely generated using some kind of DOM/SAX API.


All this to say that if you’re looking for “Web Services Infrastructure” for exposing processes and information, you’re probably looking to hard. If you have a database, templating, and a web server, you have most of the infrastructure and framework required to begin exposing information from each of your systems in a proven and established way. What you want to be on the lookout for are small and specific enhancements to these existing pieces that allow you to interact with other machines in a more predictable manner or in new and different ways.

The next time someone is selling you infrastructure for Web Services, or SOA, or ESB, or whatever they’ll call it next, make sure you ask “Why?” After they tell you, make sure you understand, agree, and have the problems they propose to solve. If not, ask again. New framework and infrastructure is extremely expensive in more ways than one: you have to ramp people on it and then deploy, manage, monitor, and support it. Sometimes new infrastructure is unavoidable but when it overlaps a large portion of your existing infrastructure, you should make sure it’s bringing back a significant return.

Simple AI Agent

Very stupid agent with artificial intelligence whose sole mission is to explore a room and clean all the dirty tiles. Some sort of vacuum cleaner. Implemented in Python, using Tk for the gui.

python 2D image rasterization examples

Image 2D rasterization example using the Python Imaging Library.

stereo images examples using python

Image processing example using the Python Imaging Library. Functions for working with stereo images are provided: de-interlace, extract blue and red channels, sum two images, scale using bilinear interpolation.

simple compiler for a pascal-like language

gercode- Simple compiler for a pascal-like language, parser done using bison. Generates bytecode.

OpenGL 3D Mesh viewer example

Sample of OpenGL usage. Displays a mesh in four views, featuring scaling, rotation and translation. Implemented in C.

screenshot of it showing a teapot

google hits

Track the amount of google search results for keywords you define, then generate HTML with graphs. Requires gnuplot.

Source code: python source code

gentoo linux menu generator

genmenu is a simple python script for Gentoo Linux systems, that generates a menu file for your window manager from what it finds on /var/db/pkg

Source code: tar.gz

RPC Chat example

Chat application supporting multiple channels. Implemented in C++ using QT and RPC for network comm.
chat session

texture transfer

(another old project)

Image processing example on how to apply a texture to an image given four coordinates supplied by the user. Implemented in C++ using QT.

full source package

100 Most Often Misspelled English Words

The 100 Most Often Misspelled Words. I hope you spel it right the next time !

Friday, September 23, 2005

Giant Bunny

Oh crap...

And behold: YAGBH (yet another giant bunny on the hills).
Checkout some pictures

Thursday, September 22, 2005

Secrets of the Shy - Secrets of the Shy

Those differences are precisely what Putnam is looking for. What he's studying during his unlikely playdates is that elusive temperamental divide between those of us who thrill to the new and those of us who prefer what we know--those who seek out the unfamiliar and those who retreat into the cozy and safe. It's in that divide, many scientists believe, that the mysteries of shyness may lie.

Satellite Image Collection

Nice collection of satellite images

Wednesday, September 21, 2005

gmail tip: multiple email aliases to the same inbox

GMail has a feature (or a bug ?) which allows you to append a plus sign followed by a keyword to your account name and it'll ignore this sufix. Think of it as a way to create several aliases for your inbox.

I've set up one so that all email sent to will be delivered as an SMS message to my cellphone. All I had to do was create a filter like the one below. (and of course, your cellphone company must support forwarding emails to your phone).
Matches: to:(
Do this: Forward to, Skip Inbox
remember to replace account by your gmail account and to the email address your company set you up.

What Should I Read Next?

Don't know what to read next ? Just give What Should I Read Next? a spin. Basically, you enter a book you like and their database of real readers' recommendations will suggest something.

Are we getting smarter or dumber?

In case you didn't notice: we're indeed becoming smarter !

Has intelligence changed at all in the era of the Internet?
Merzenich: Over the past 20 years or so, beginning before the Internet really took hold, the standard measure of "intelligence" (cognitive ability) has risen significantly (well more than 10 points). No one really knows what to pin this on, but it is a well-documented fact.
-- Are we getting smarter or dumber?

The naive vegetarian

From The naive vegetarian:

As we know, when it needs food, our body indicates this to us with the feeling of hunger. But there are also other signals if specific nutrients are deficient. Meat is the best source of several nutrients. When our bodies are deficient in these, we become irritable and aggressive. This is a perfectly natural signal built into our genetic make-up over our evolution: our bodies are telling us to go out and kill something to eat. This is why strict vegetarians tend to be so vociferous. It is a trait that was recognised long ago; it was, after all, the vegetarian Cain who killed the carnivorous Abel, not the other way round. The vegan Kikuyu tribe in Kenya were the perpetrators of the murderous Mau Mau in the 1950s, not their wholly carnivorous, but peaceful, neighbours, the Maasai.

Mind-opening article. Dad always told me not to trust on anyone not eating meat.

Monday, September 19, 2005

Wild Things Photography

I've just stumbled over this amazing nature photo set.

Iceland trip journal

Some guy's trip to Iceland journal. Interesting read.

Why most numbers start with 1

A phenomenological law called Benford's Law or the first digit law, states that in listings, tables of statistics, etc., the digit 1 tends to occur with probability ∼30%, which is much greater than the expected 11.1% (i.e., one digit out of 9).

That has been used by tax experts to detect fraud since any natural data (which are not dimentionless) should exhibit such a distribution of first digits:

Sunday, September 18, 2005


Use it to transfer pixel crominance information from a colored source image to a grayscale target image. See example below:

  • Source code: bzip2 (Requires wxPython)

  • Windows(tm) binary: exe (Stand-alone app, no extra requirements)

Linux on a Toshiba Satellite M35-S359


Before even installing linux or any other operational system, you'll have to split the huge 60GB single NTFS partition into other partitions. The recovery DVD will rewrite the entire 60GB disk if you don't abort it and fdisk/format a smaller ntfs partition on the beginning of the drive. To do so, i followed the following steps: (You could also take a different approach, by resizing the NTFS partition, using

  1. Boot knoppix, or any other linux rescue system. To choose the boot medium, you will have to press F12 during boot.
  2. Use fdisk, cfdisk, or the partition editor of your choice to create a smaller NTFS partition and the other desired linux/windows partitions. In my case, i decided to create the following:
Device Boot      Start         End      Blocks   Id  System
/dev/hda1 * 1 2433 19543041 7 HPFS/NTFS
/dev/hda2 2434 2444 88357+ 82 Linux swap
/dev/hda3 2445 5363 23446867+ 83 Linux
/dev/hda4 5364 7296 15526822+ c W95 FAT32 (LBA)

That is: a 20 GB partition for WinXP, a 20 GB partition for Linux and another 20 GB FAT32 partition to share data (mp3, movies, etc) between linux and windows. (NTFS is mounted as read-only on linux)

You may probably want a smaller linux partition, or a separate partition for /home. I just wanted to keep things simple.

  1. Boot with the recovery dvd this time.
  2. On the screen prompting you to confirm the recovery procecure, you just abort.
  3. You will be then dropped into a win98 "shell". On this environment, i made sure the first ntfs partition was active and formated. To do so, i used fdisk to make this partition active, and then, after another reboot (as recommended by DOS' fdisk) with the recovery dvd (aborting once again) I used DOS' to properly format C:. (This formatting step may not be needed, i haven't confirmed so. But it is safe to do it anyway). As reported on you should change to the recovery virtual drive and run the proper win98 fdisk. There is also a .bat for resuming the recovery process. More details on where to find fdisk and how to resume the recovery process can be found on
  4. Locate a .bat file on the recovery dvd or virtual ram drive, that should resume the recovery process. So you then wait patientely as it transfers the entire winxp home system image with all the pre-installed software. Notice that on the progress screen, it will show that the target partition or disk has only 20GB.
  5. Boot windows normally, just to make sure you have your winxp home system working again.
  6. Boot your favourite linux install iso this time, and proceed with the installation as you would on a normal desktop pc.

My distribution of choice was knoppix, as it gives me a fully working Debian unstable/testing system in less than 10 minutes. So the following instructions may only appply to debian-based systems. (But well, you should easily figure out how to do them on your distribution)

Installing knoppix

  1. Boot the knoppix live cd. I used the latest 3.3 release.
  2. Make sure everything is working fine. Right out of this boot, i had ethernet and audio (not ALSA) working. X11 resolution will be at 1024x768, since knoppix doesn't seem to install nvidia drivers for you. Don't worry, you will have 1280x800 real soon.
  3. Open a root knoppix console (there is an icon on the kde panel for that i guess). Run the knoppix-installer script. (the one for installing knoppix into a hdd)
  4. Follow through the normal questions you'd expect on any linux install, and you should end up with a working knoppix system on the 20GB linux partition you defined on the 1st section. I decided to use ext3 as the filesystem for /.

Improving support


I compiled the latest 2.6.1 kernel available from, and applied the -mm4 patch availble on this same page. Instructions for applying this patch is available at You could take a look at my config file (there are instructions on the official kernel package on how to use old .config files when compiling your kernel. Mostly all you may need is a "make oldconfig") for this kernel.

Please notice that a lot of unnecessary modules are still included on this config, and should probably be removed. But all necessary ones for this toshiba model are there. Please email me with any suggestions.

At the time of this writing, the acpi extensions found on the phoenix bios of this M35 were not supported by the toshiba_acpi kernel module included on 2.6.1, but this patch will make it work. Download the patch and follow these instructions (assuming you have the mentioned kernel sources extracted to /usr/src and /usr/src/linux pointing with a symlink to the extracted kernel source tree).:

cd /usr/src/linux
cd drivers/acpi
patch -p0 < /home/rnc/downloads/toshiba_acpi_0.17-test1.patch

The patch above is now available on kernel 2.6.3-rc2.

Also take a look at the "X11, usb, mouse" section below for some other kernel fixes before building it.

Now compile your kernel with the usual "make bzImage modules modules_install", and don't forget to copy the resulting bzImage (/usr/src/linux/arch/i386/boot/) to /boot and re-run lilo.

Reboot the new kernel, and make sure you have a toshiba dir on /proc/acpi. Also keep in mind that you need to reinstall the nvidia driver everytime you compile a kernel.

toshiba utils

There are some toshiba utilities you should install from, in order to change the lcd brightness for example. All I did was download/install the debian package for fnfx, and make sure the fnfx daemon (fnfxd) runs automatically:

dpkg -i fnfx-0.2-1.deb

speedstep support

The .config file above would give you a kernel supporting intel's speedstep technology, but you'll need a daemon running on background collecting system load info and adjusting the processor speed as needed. And "powernowd" is the one responsible for that. What you should do:

apt-get install powernowd
mkdir /sys
echo "sysfs /sys sysfs defaults 0 0" >> /etc/fstab
mount /sys

wireless support

I haven't tested it yet. All i know is that linux won't support it natively, and INTEL will take a long time to release closed or opensource drivers. So you should try ndiswrapper (

X11, usb and touchpad mouse support

Get the latest synaptics driver for X11 at . It should be a synaptics-version.tar.bz2 file. Uncompress and install it.

Take a look at my XF86Config-4 file. With this config, USB and touchpad with synaptics support will work simultaneously. There are some hacks on the net that will switch between 2 diferrent XF86Config files if you boot with the USB mouse plugged in or not. Google should assist you there.

This config should also contain a modeline for 1280x800 and truecolor, but i guess it will only work with nvidia drivers.

There are some issues with the touchpad: the keyboard will hang or delay when you press keys right after using the touchscreen. Follow the instructions on (search for "psmouse-base") to fix it. So note that you need to change psmouse-base.c as described on Marc Saric's howto before building your kernel.

nvidia driver

For kernel 2.6.1, i had to use the nvidia drivers from . After downloading the latest binary nvidia driver for 2.6.1, all i did was "sh", and an NVIDIA installer compiled/installed everything necessary. Latest official drivers from seems to support 2.6 kernels, so you are probably better off with official drivers.

Also, don't forget to set the proper driver on your XF86Config file. (Again, my config linked above does that for you)

missing serial port errors

Due to a bug on knoppix 3.3, or other Linux distros, a message (ttyS0: LSR Safety Check Engaged) would appear every few seconds on all terminals. To make that go away, as suggested by Karl Tallen (K.Tallen at gmx dot de), I had to remove /var/lib/setserial/autoserial.conf and run (as root) /etc/init.d/setserial. You should also remove the brtty package, because there is still a single error message (something like "device not found").

Further resources

subversion in 2 minutes on Debian Linux

On a Debian (SID) system, it should be as simple as this:
# apt-get install subversion
This will install all necessary binaries and tweak /etc/services so svnserve is executed by the user starting the ssh tunnel upon network activity.

Create a repository to store versioning data:
$ svnadmin create ~/svn
Import a source tree into subversion:
$ svn import /home/rnc/coEdit svn+ssh://
With this import command, all files under /home/rnc/coEdit will be checked in as the toplever dir coEdit on your repository.

Now you need to checkout a working copy of your project source code:
$ cd ~/myWorkDir/
$ svn co svn+ssh://
Now you are ready for commiting and updating source under ~/myWorkDir/coEdit. From here on, refer to /usr/share/doc/subversion/book/book.html for detailed usage info.

Saturday, September 17, 2005

Mobile-phone on the developed world

There is almost one mobile phone for every person in much of the developed world, according to new figures from the OECD. In Luxembourg, phones outnumber people, since many people who live in neighbouring countries have a second handset for use within its borders. Despite their enthusiasm for PCs and broadband links, Canada and the United States have been slower to adopt mobile phones than other rich countries.

I've been using (formerly known as audioscrobbler) for a year now and the short way I have to define it is: "an orkut for music".

Every user populates it's musical profile automatically using plugins for popular desktop media players so the site keeps track of everything you listen, being able to make recommendations, show musical "neighbours", that is, other users with similar music taste, and so on.

It's really fun to browse similar artists on it even if you don't have a profile.

See my profile for example.