The Netherlands is nowhere near Kiev

Not to mention that Singapore is slightly southern where it should be, or that Houston is a bit too close to Monterrey, but I’m too picky there.

Found in one of those companies doing website monitoring 24×7, which shall remain nameless. In terms of maps (and geographical knowledge in general) I’ve seen much worse, if you ask me, even in non-US mass media.

Steve Yegge on Apple APIs

A comment at the bottom of his own lengthy but otherwise interesting article:

One more important point: I’m surprised that some people seem to think I’m implying some programming studliness from my little 3-day excursion. Not so: any first-year college student or intern, or heck, self-taught dude in his basement, could have done exactly what I did. I failed utterly to convey the right point here, by unfortunately being way too subtle about it. The recounting of total hours spent was a hats-off compliment to Apple for having written such great APIs, documentation, and tools. Let me be clearer about it, then: Apple’s development environment is nothing short of amazing, which I fully expected, knowing it derived originally from NeXTStep and has had fifteen or twenty years of innovations piled on. The APIs are _clean_. This is why I was able to narrow down the APIs I needed so quickly. The whole thing I got working was no more than 50 lines of code, most of it error-handling. That’s C code, so it’s impressive how much it accomplishes in so little space. The takeaway here is that more programmers ought to jump in and start playing with OS X. You get results faster than you’d think.

wp-super-cache problem? Easy fix

I’ve just installed the excellent wp-super-cache plugin to accelerate things a bit in this blog; today somebody sent one of my pages to reddit and I’ve had more users than usual! – by the way, thanks for coming! :)

Update: I admit, it also has a bit to do with the reading of today’s entry in Coding Horror ;) But I love WordPress nonetheless. I prefer it over MovableType (which I used during one year and a half).

The only glitch was: at first, it didn’t work. I think you know the feeling.

The plugin was enabled, everything was activated, yet no files were cached: exactly this same problem. And I found a quick fix to it, hence this post: fire your FTP client of choice and go to /wp-content/cache. If you don’t see a “supercache” folder in there, just create it. Magically, if you have some traffic on your blog and you dig in that folder a couple of seconds later you’ll see already lots of files! No need to modify .htaccess whatsoever.

If you want to populate it, log out of the WordPress admin and start clicking on your blog. This plugin only creates cached files for anonymous visitors! I also turned on the compression so you should start having faster response times.

It was the only thing to do manually to get it working. Hope this helps! Any comments, as usual, more than welcome.

Installing PostgreSQL 8.3 on Leopard

This is the documented path to my discovery of PostgreSQL 8.3, which I’ve never used before. Now that MySQL‘s community is getting hammered to death by Sun, and thanks to all the good things I’ve heard about it over the years (including enhanced performance on multicore systems and greater scalability), I really wanted to install it and play with it.

Frankly, it’s not easy. At all (actually this is why I think MySQL is so popular, because of the ease of installation!) So hang tight and read on. Continue reading

Extracting e-mails from a vCard file with Python

Let’s say that you have a vCard file. You can export it from your Mac OS X AddressBook.app, or from any other similar application. Now you need to extract some information from it, namely the e-mails, for spamming your friends with some boring news. Typical.

Enter vobject. This Python library is part of the Chandler effort (which seems to be somewhat ill-fated since Mitch Kapor announced he was leaving the project). Anyway, you can download this library from here and then install it using the common sequence:

python setup.py build python setup.py install

Finally, here’s a bit of code to quickly extract the names and e-mail addresses from a vCard file called “vCards.vcf” containing lots of vCard instances, one after the other (AddressBook.app exports data this way, instead of creating on file per contact):

[source:python] import vobject

f = open(“vCards.vcf”) s = “”.join(f.readlines()) f.close()

a = vobject.readComponents(s)

counter = 0

while True: try: # “next()” seems to throw an exception # when there aren’t any more “Components” # in the stream… # Talk about nice flow control! b = a.next() counter += 1 if b.contents.has_key(‘email’): # “repr()” below avoids # unicode –> ascii exceptions print repr(b.fn.value), repr(b.email.value) except: break

print “%d e-mails found.” % counter [/source]

The library documentation, to put it simply, isn’t as good as the library itself (see? I can be politically correct sometimes :) Maybe I missed a better way to iterate over the contents of the whole stream of vCard instances inside the file (using exceptions for that is yuck!), but then again, feel free to add your comments below as usual.

Quick spec from your Python tests

Using Python’s own unittest package, here’s a small script that can iterate over your test suite to output a small, quick, nice list of the tests in your application:

[source:python] import unittest

loader = unittest.TestLoader() tests = loader.loadTestsFromName(‘path.to.your.tests.package’) for test in tests.tests: print test._tests[0].class.name.replace(“Test”, “”) for method in test._tests: print ” %s” % method._testMethodName.replace(“test“, “”).capitalize().replace(“_”, ” “) [/source]

This would yield something like this: Business     Accounts have at least one entry     Clerks cannot close accounts Security     Users can create new accounts     Anonymous users cannot access private areas ...

Of course, you’ll get better results if you follow Google’s naming conventions for your tests… ;) This is not rspec (nor an alternative to it) but it might be useful to some of you.

Just as a reminder for Django users: you might need to

setenv DJANGO_SETTINGS_MODULE application.settings

or

export DJANGO_SETTINGS_MODULE=application.settings

in order to make the script work properly! At least I had to :)

ACOR SOS racisme: il n’y a pas de fumée sans feu.

(reçu par e-mail)

Chère sympathisante, cher sympathisant,

Le 1er juin 2008, l’initiative UDC “pour des naturalisations démocratiques” sera soumise au vote. Son titre semble anodin et faire appel au bon sens. Y aurait-il quelqu’un pour souhaiter des naturalisations antidémocratiques? Rappelez-vous pourtant: le tribunal fédéral a annulé les “naturalisations démocratiques” qu’avait inventées la commune d’Emmen.

Naturaliser à la tête du client, sur un fond de rumeurs et de préjugés régulièrement alimenté par des campagnes choquantes, est-ce cela la démocratie? Continue reading

How to build ohcount on Leopard

If you do not know ohcount, you should; the guys at ohloh.net have GPL’d one of their core components, namely the one that allows you to perform source code line counts in your own projects. Neat and useful!

However, the current ohcount distribution (which you can download from this link) does not build out-of-the-box in Leopard. Here’s how I made it work in my own Leopard G4 PowerBook (PPC) computer. Continue reading