slippens's blog

Blocking referer spam with Apache .htaccess directives

28 April, 2006 - 16:03

The logs of my (drupal powered) website show a lot of referer spam. Some time ago I had this statistics page which contained a listing of the last 10 pages my site's visitors came from (aka referers). Soon spambots found out and spammed this list. I made the list invisible for anonymous visitors, but nevertheless spambots stil target my site (less frequent than when the list was visible, however), polute my stats, use bandwidth, use processing power and kill those cute little puppies. Now I went a bit further to block those dirty spambots ...

help making google better

8 March, 2006 - 13:49

When you point your Mozilla or Firefox browser to a malformed url, for example http// (no : after the http) or http:// (two times http://), you don't end up where you would expect. English google users would get served with Micrfooosobarfts website, while I (a Belgian/Dutch google user) end up at This page explains what is happening here. And to follow the proposed solution, I'll put here a link to information about http.

a clash between locale settings, C extension Python modules and pylab (aka matplotlib)

6 March, 2006 - 16:58

This weekend I encountered a weird problem during programming C extension modules for Python. For some obscure reason floats from my C extension modules were formatted with a comma as separater (e.g. 123,456) instead of with the more familiar point (e.g. 123.456). Obviously some locale related problem. Most of my desktop and applications are set up for Dutch (my native language), but when I'm programming/working I use English and scientific conventions (e.g. a point as decimal separator). After isolating the problem I found out it was related to importing the pylab (aka Matplotlib) module (which I started using for plotting graphs and figures from Python). The following situation illustrates the problem.

Zebra-cubism halftoned Lenna

7 February, 2006 - 02:52

A weird outcome of a halftoning experiment. Not what I would call a good halftone, but it's nice on itself.

lenna with zebra effect halftone

Saving of images in scipy and preventing dynamic range rescaling

1 February, 2006 - 13:30

Scipy is a (set of) open source Python modules for scientific/mathematical/engineering stuff. I (try to) use it instead of Matlab or its open source clone Octave because I don't like Matlab's scripting language and prefer Python's programming features.

If you want to store a 2D array (aka matrix) to an image file, the default behaviour of Scipy's imsave() function is to rescale the matrix to a 0-255 range (like Matlab's imagesc() function). For example:

Reading OpenDocument office files from Python

20 January, 2006 - 19:58

The OpenDocument file format (aka "OASIS Open Document Format for Office Applications"), is an open and free standard for office files. It's fairly easy to read OpenDocument files in/from Python. Basicly, an OpenDocument file is just a zip archive but with another extension (".ods" spreadsheets, ".odt" for text documents, ".odg" for graphics and so on). The files in the zip file are mainly some XML files, like content.xml, settings.xml and styles.xml.

Basicly, we just need two standard python modules from the nice standard Python library to extract data from a OpenDocument File: zipfile for handling the zip compression and xml.parsers.expat (or another xml parser module) for parsing the xml. A possible/simple/minimal way to do read a fictional spreadsheet file pelican.ods is as follows:

lenna lorem ipsum

6 January, 2006 - 18:10

I want to share an image with the world.
It is not art. It is just the result of a experiment that — how should I put it — went wrong.

To be continued

ugly binary image

fun with reflective linux commands

3 January, 2006 - 16:43

Man, this is heavy linux/unix commandline fun:

which which
locate locate
man man
help help
info info
whatis whatis
echo echo
touch touch
yes yes
whereis whereis

Blender: change active camera

28 December, 2005 - 21:38

It's a simple concept, but I already lost a lot of time looking for the solution: changing the active (aka default or just render) camera in Blender. I just can't find any clue in the (context) menus or in the wikified Blender manual. Google directed me to this Blender survival guide in which the solution is concealed:
select the camera which you want to make active and press ctrl + numpad-0 player on Linux

19 December, 2005 - 17:36

Today I bothered to intall the player just to give it a try. The installation (on my Kubuntu 5.10 Linux laptop) was very easy. I just downloaded a tarball with the Linux binary from the player download page and extracted it to a local folder in my home directory. Next I had to tell my webbrowser (firefox) to use this player for links with the lastfm:// protocol (like explained here). That was all to make it work.