Tagged: geek stuff

These blog posts have all been tagged with geek stuff. These tags appear to be related:

16 Sep
Python-RSA 4.0 released!

After over two years of silence, Python-RSA 4.0 has been released! There are many improvements and also backward-incompatible changes (hence the increase of the major version number).

Get it while it's hot at the Python Package Index, or just install with pip install --upgrade rsa.

31 Oct
Blender Conference 2016

BConf 2016 was awesome, as ever. This is just a blog post to share the slides of my workshop "Develop add-ons like a pro".

17 Mar
Python-RSA 3.4 released

Python-RSA 3.4 has been released! This is the first release from GitHub, and contains a lot of improvements by myself, Michael Manganiello, and Filippo Valsorda, including the solution for a side-channel vulnerability.

Get it while it's hot at the Python Package Index, or just install with pip install --upgrade rsa.

Click here for more details and a plan for the future.

04 Feb
My name in the modern world


My last name is a technical hurdle. At least, for many people. In this high-tech, modern, globalized society, one would expect that a simple accented character shouldn't be an issue. After all, even a small child can write Stüvel correctly with a stick in the mud. So why is it such an issue in the world of computers?

06 Nov
Python FlickrAPI 2.0 released

Python FlickrAPI library version 2.0 has been released, and can be downloaded from the Python Package Index with more info at my FlickrAPI page.

The major change is that the "new" OAuth-based authentication is used. This makes our Python FlickrAPI library a lot more future-proof.

Thanks to Jim Easterbrook, Thai Nguyen, Nick Loadholtes and Bengt for their contributions.

30 Jul
Moving from pwsafe to KeePass

My favourite password management tool, pwsafe, is getting old. It's no longer part of Ubuntu and I've had to compile it myself for quite a while now. It's also not supported on Android, and shows other signs of aging. So, I moved to KeePass. Exporting my database to CSV was simple, and to make the job of importing it correctly into KeePass even easier, I wrote a simple Python script.

Click to see the code...

18 Jun
Python FlickrAPI 1.4.4 released

Python FlickrAPI library version 1.4.4 has been released, and can be downloaded from https://pypi.python.org/pypi/flickrapi with more info at https://stuvel.eu/flickrapi

The changes are:

  • Changed default API URL to use HTTPS (Joseph Hui).

  • PEP 8 compliance (Luar Roji).

  • Replaced Distribute with Setuptools.

In the mean time, we have made more progress on the upcoming version 2.0. We can always use more bug testers, bug fixers and documentation writers; check out https://bitbucket.org/sybren/flickrapi/ to get involved!

10 Mar
Reloading your code in Blender

Blender lets you script more or less everything. You can have your code inside Blender (and the .blend file) itself, but I prefer to store it outside the .blend file. This makes it easier to handle changes, and allows you to use any editor you want. The downside is that reloading your code becomes a bit of a hassle. This is a little snippet I wrote to reload my code in Blender with the click of a button.

Click to see the code...

28 Feb
Counting pixels in Blender

For my research, I'm using Blender to generate images. I wanted to know how visible a certain object is in the final render (i.e. how many pixels it occupies). For this there is the "object index" render pass (aka "IndexOB" in the compositor). I've been struggling with it, since it always outputs that the index is 0, even though there are multiple objects in the scene.

Well, with the help of mfoxdogg on the #blender IRC channel, we found a solution: You need to set the index by hand, for every object you're interested in. If you go to the object properties (in the properties explorer), in the section "Relations" there is a slider "Pass Index". This is set to 0 by default, and you can set it to any positive number you want. This is then reflected in the output of the "IndexOB" render pass.

Click to see how I counted the pixels...

22 Feb
Python-RSA version 3.1.4 released

Hacking, the analog way

It's been a while since I've been working on my RSA library, and in the last weeks I've released a few new minor versions. Here are the differences since my last blog post about it:

  • Fixed Python 3.x incompatibilities.

  • Dropped support for Python 2.5.

  • Added support for loading public keys from OpenSSL

  • rsa.pkcs1.verify() returns True when successful (thanks Tim Heckman)

  • First updated Distribute (thanks Jason R. Coombs), later replaced Distribute with Setuptools.

  • Fixed typo in pyrsa-verify help message

31 Oct
Installing Windows 8 with different product key

New laptops often are shipped with the Windows product key stored in the EFI/BIOS/whatever. The result is that you don't get a product key prompt any more. Great for reinstalls, as copying the key by hand is very error-prone. However, when I wanted to install a fresh Win8 Pro version, the embedded "Home" version key wasn't accepted and the installer did not ask for another key. It was simply impossible to install Windows 8 Pro.

This blog post will describe how I got it installed in the end.

Click for the solution...

30 Oct
Blender conference 2013

Last weekend Amsterdam was visited by a great group of over 250 Blender professionals and enthousiast, for the Blender Conference 2013. This year it was my pleasure to give a workshop about my research, and how I use Blender to visualize my result.

For the attendants (and other interested people), I've put my presentation, the Blender file and accompanying SQLite database online: https://stuvel.eu/files/bcon_2013_sybren_workshop.7z

You can still see the workshop online on Youtube: https://www.youtube.com/watch?v=Wt8WdSvaRms&feature=player_detailpage#t=620 (the first 10 minutes is just people leaving the previous workshop, and me setting up).

click for the video...

09 Dec
Start XBMC from remote

The Android XBMC Remote app has a "Power on" button. This button sends a wake-on-lan (WOL) packet to the XBMC server, so that it can wake up. However, my XBMC server runs all kinds of server stuff, so I don't want to let it sleep. Still, XBMC uses more than 10% CPU power even when it's in idle, so I don't want it running all the time either.

I've written a small Python script that executes a command every time it receives a WOL packet. This is then used to start XBMC.

Click for the source code...

17 Jun
Python-RSA version 3.1.1 released

Hacking, the analog way

Python-RSA version 3.1.1 has been released. A lot of things have been improved, thanks to Yesudeep Mangalapilly.

  • Much, much faster

  • Compatibility with Python 3.2

  • Lot of bug fixes

Check the Python-RSA page for more information!

Observant readers may have noticed that I snuck in a tiny minor release. Version 3.1.1 introduces full Python 3.2 compatibility for the key saving/loading stuff as well, and fixes some doctests for Python 2.7. Nothing in the actual RSA stuff was changed.

24 Feb
FlickrAPI and OAuth

This summer Flickr will stop supporting their old authentication system and move fully to OAuth. I've gotten several questions about whether Python FlickrAPI will support that. No worries, it will. If you want it fast, clone the repository, implement OAuth (don't forget the unittests) and send me a pull request.

02 Nov
Hacking in Fallout 3 improved

Hacking of a security terminal in Fallout 3

Ever since I bought Fallout 3: New Vegas, I've been playing their hacking mini-game again. Of course I'm using my own hacking tool to help me. Today I made a small improvement: it now also suggests which words to try first. It picks the two words that are most different, and suggests you try those.

Check it out yourself!

05 Aug
Python-RSA version 3.0 released

Hacking, the analog way

Python-RSA version 3.0 has been released. A lot of things have been improved:

  • Much more secure

  • Following industrial standard PKCS#1; this means compatibility with OpenSSL

  • Ability to create and verify detached signatures

  • More elegant method of encrypting large files

  • Ability to save and load keys in PEM and DER format

  • Extensive documentation

  • More efficient key generation

Check the Python-RSA page for more information!

photo hosted on Flickr

Update: in the mean time 3.0.1 has been released, which removes an import of the "abc" module. This should make the code compatible with Python 2.5 again. All the documentation (including installation instructions) are the same as before.

29 Jul
My experience with Wicket

Today I found out that I'm not a Java programmer. The more I look at programming languages in general, the more I find Java to be clumsy and short-sighted. For a project at my work I tried Wicket.

A lot of web frameworks in Java have the "I'm scared by the web"-syndrome, in which they try to get rid of CSS and mostly JavaScript, and replace it all with Java. Wicket is no different in that respect. In my opinion, if you're scared of the web, don't build a web interface.

A colleague pointed me to the Play framework. It appears to be very much like Django, but then for Java and Scala. I've given it a go, and it looks very nice!

Read on for some of my reasons for disliking Wicket.

28 Jul
Eclipse doesn't support AES-encrypted SSH keys

Today all of a sudden I couldn't commit to CVS any more. Eclipse refused to accept my SSH key passphrase. When trying to load the file, Eclipse tells me failed to decrypt id_rsa.

I recently re-encrypted my private key using ssh-keygen -p, which used AES for the encryption. It turned out that Eclipse doesn't support that.

The solution is quite simple: use openssl to re-encrypt using DES3:

cd ~/.ssh
openssl rsa -in id_rsa -out id_rsa-eclipse -des3
mv id_rsa-eclipse id_rsa

Please note that you may need to restart Eclipse, as it may cache your old key.

10 Jul
Added random padding to Python-RSA

Hacking, the analog way

I'm thrilled to let you know that I've just added encryption and decryption with random padding to my Python RSA module. The code has become much more secure than it was before, and also makes it capable of encrypting and decrypting binary data! This is a big step towards the practicality of the implementation.

I've implemented the padding according to the PKCS#1 standard. The RSA Algorithm page by DI Management explains how to do this very clearly; cudos to them!

Right now these changes are unreleased. I want to add signing and verifying signatures too before I do that. Maybe I'll deprecate the existing functions, as they are much less secure than all the new stuff I'm adding. If you want to try out what I've changed so far, feel free to grab a copy off my Mercurial repository.

photo hosted on Flickr

UPDATE 14:20: I've also implemented PKCS#1 style signatures and signature verification

UPDATE 2011-07-12: the implementation is compatible with OpenSSL, making it very likely compatible with other implementations of PKCS#1 version 1.5!

17 Jun
Python vs. Java revisited


Back in 2008 I wrote a small post about Python vs. Java. I've revamped it by adding more detail, and tossed in a primer on list comprehensions for free. I hope that once you've read that you're convinced that list comprehensions are a Good Thing.

And as an added bonus, I extended my website so that it can do syntax highlighting!

On to the article!

29 Apr
Python serial comm and RTS pin

At my work I'm communicating with an embedded device via a serial-to-USB cable. It works fine, except for one little detail: when the "Ready To Send" (RTS) pin is high, the device shuts down. This is by design, but annoying nonetheless, since almost all serial communication software sets this pin to high. I've written a little Python program that opens the serial connection, sets the RTS pin to low, and shows all data read from it.

You can read the details after the break.

13 Mar
Nu ook op Google Maps

Stüvel Fotografie staat nu ook als "place" op Google Maps, zowel in het Nederlands als in het Engels!

Stüvel Photography is now a "place" on Google Maps, both in Dutch as in English!

09 Jan
Version 2.0 of RSA module

Hacking, the analog way

A guy named Dave sent me an email today, telling me that my RSA implementation was rather insecure due to the use of the "pickle" Python module. Fortunately I had some nice improvements by Barry Mead already in version control, eagerly waiting to be released. Well, Dave gave me a nice insentive to round up Barry's improvements and send version 2.0 into the world.

Please note that it's a backward-incompatible change. The RSA page shows how you can re-encrypt your data to be compatible (and more secure!) again.

20 Aug
Extending Selenium from the client driver

Selenium is a web page testing tool that we use a lot at my work. It can be extended by supplying it with a user-extensions.js file.

We're extending our test application to include support for Selenium Grid. In this setup we can't supply that user-extensions.js file directly, it has to be injected via the client driver. However, this happens too late; Selenium doesn't notice our custom locator functions any more. This is a known issue, also noted by Ross Patterson. I've found a way to work around this limitation. Add the following to your user-extensions.js file such that it's executed after your additions have loaded:

  objectExtend(selenium.browserbot, PageBot.prototype);

It seems to work just fine without any unwanted side-effects. If you tried this, please leave a comment to let us know how it worked out for you!

22 May
Multiple instances of QApplication in one process

I'm working on a PyQt 4 application for my employer Chess. Of course I'm writing plenty of unit tests for it as well. Those tests have to be cleanly separated from each other, so every test that requires the entire application to be up and running should have its own instance. And this is where it gets tricky, as Qt (and thus PyQt) assumes that there will only be one application, and if that application quits the process quits.

In my unit tests, this is not the case. Every test can potentially start and stop an application, and the test suite will continue running. This caused a segmentation fault (a.k.a. segfault) the second time the QApplication closed.

After a lot of puzzling I found out that QtGui.qApp needs to refer to the running QApplication instance, and be set to None when the application has been closed. After I implemented this the segfaults went away.

This is my ApplicationTest mix-in class that I use for controlling my application lifespan. It contains a little trick to stop the application as soon as it has started:

  class MyApplicationClass(QtGui.QApplication):

  started = QtCore.pyqtSignal()

  def exec_(self):
      return QtGui.QApplication.exec_()

class _ApplicationTest(object):
  '''Mix-in class that can start and stop an application.'''

  APP_CLASS = MyApplicationClass

  def __init__(self):
      self.app = None
      QtGui.qApp = None

  def create_app(self):
      '''Creates and returns a new application'''

      self.app = self.APP_CLASS([])
      QtGui.qApp = self.app
      return self.app

  def stop_app(self):
      '''Stops the application.'''

      if not self.app: return


      QtGui.qApp = None
      self.app = None

10 Feb
Song title fades in AfterEffects

I've been working on a video of our live performance in Winston Kingdom using Adobe AfterEffects. To show the title of a song at the start and end of the song, I used a script to automate the fading. Assign it as an expression to the opacity of the text layer and it'll automatically show for a few seconds at the in-point and out-point of the layer, including nice fades:

  fade_time = 1
show_time = 5
if (time < inPoint + fade_time) {
    linear(time, inPoint, inPoint + fade_time, 0, 100)
} else if (time < inPoint + fade_time + show_time) {
} else if (time < inPoint + fade_time + show_time + fade_time) {
    linear(time, inPoint + fade_time + show_time, inPoint + fade_time + show_time + fade_time, 100, 0)
} else if (time < outPoint - fade_time - show_time - fade_time) {
} else if (time < outPoint - fade_time - show_time) {
    linear(time, outPoint - fade_time - show_time - fade_time, outPoint - fade_time - show_time, 0, 100)
} else if (time < outPoint - fade_time) {
} else if (time < outPoint) {
    linear(time, outPoint - fade_time, outPoint, 100, 0)
} else {

fade_time is the duration of fade-in and fade-out, show_time determines how long the text layer is shown at 100% opacity, both are in seconds. You can make an animation preset by adding a "Solid Composite" effect, setting opacity=0% and assigning the expression to the "source opacity" property.

03 Feb
Python Flickr API 1.4 released

The Python FlickrAPI kit has just been released. The new features are:

  • Using auth_callback=False when authentication is actually required now raises a FlickrError exception.

  • The implementation uses self.flickr_host so that subclasses can override the API URLs.

  • Support for short URLs was added.

Of course the Python FlickrAPI kit is completely dynamic, and so it always supports any new FlickrAPI functionality as soon as it is released by the Flickr team.

The new version can be found at https://stuvel.eu/projects/flickrapi or the Python Package Index at https://pypi.python.org/pypi/flickrapi

11 Dec
Duplicating audio with ALSA

threesixtyfive | day 230

On Linux the most used sound system is the Advanced Linux Sound Architecture, ALSA for short. It's a very configurable system, but it's not easy to dig down far enough to get to its power.

What I wanted to do was to get the same music in the living room and the computer room. The rooms are right next to each other, and my desktop is sitting with its back towards the living room. My desktop has two audio cards, one built-in VIA-82xx and my trusty SB Audigy. All I had to do hardware-wise was to connect the VIA-82xx to the amplifier in the living room and the Audigy to the amplifier in the computer room.

But then came the tricky part - to have one application send its sound to both cards simultaneously. You can configure this on a per-user basis in ~/.asoundrc or globally for the entire system in /etc/asound.conf. It takes two steps:

  1. Create a virtual "sound card" that has four channels. Channels 0 and 1 will be sent to one sound card, and channels 2 and 3 will be sent to the other.

  2. Create a routing "sound card" that mixes its stereo input to the quad-channel virtual sound card.

Place this into ~/.asoundrc or /etc/asound.conf:

  # This is the four-channel card that sends its first two channels
# to one real card, and the other two channels to the other card.
pcm.tworooms {
    type multi;
    slaves {
        a {
           # The first real card, change to "channel:CARD=CardName"
           # for your system.
            pcm "front:CARD=Audigy";
            channels 2;
        b {
           # The second real card, change to "channel:CARD=CardName"
           # for your system.
            pcm "iec958:CARD=VT82xx";
            channels 2;

    # This configures how the four channels of this virtual
    # card are distributed amongst the real cards.
    bindings {
        0 { slave a; channel 0; }
        1 { slave a; channel 1; }
        2 { slave b; channel 0; }
        3 { slave b; channel 1; }

# This virtual "sound card" mixes two channels up to four.
pcm.both {
    type route

    # Its four-channel output is sent to the "tworooms" device.
    slave {
        pcm "tworooms"

    # This defines how the channels are mixed. Input channel 0 is
    # sent for 100% to channels 0 and 2 of device "tworooms",
    # and its channel 1 is sent for 100% to channels 1 and 3.
    ttable {
        0 { 0 1.0; 2 1.0 }
        1 { 1 1.0; 3 1.0 }

So far so good. Now I want surround sound. Unfortunately, when I change slave "A" to surround51:CARD=Audigy and increase its channels to 6 (updating the bindings accordingly) it refuses to work. MPlayer tells me The number of output channels must be between 1 and 6. Current value is 8.

If you know how to solve this, please let me know. ALSA should support more than 6 channels, as demonstrated in the ALSA wiki.

03 Oct
Python Flickr API 1.3 released

Today I released version 1.3 of the Python Flickr API. It's clear that I've been busy with my study and my work, as the world hasn't seen a release in nearly a year. This is mostly due to the dynamic nature of the code - it automatically adapts to any new functionality that's added to Flickr, so no release is required then. This release adds some nifty new things:

  • Added functions to easily walk through sets and search results, querying Flickr no more than needed.

  • Uses the hashlib module, falling back to the md5 module when hashlib is unavailable.

  • Added locking token cache, in case a Flickr API key is used by multiple processes at the same time on the same machine (or shared filesystem)

  • Removed the deprecated fail_on_error parameter.

  • Implemented the auth_callback functionality.

Go to the Python Flickr API.

14 Sep
Why doesn't Windows have a package manager?

After I uninstalled Visual Studio 2005 Pro I got this very long message (I've included it at the bottom of this blog post) telling me to manuall uninstall twenty other programs, in the correct order.

They are capable to install all of this with one single button. Why on earth are they incapable of removing this? Why do I have to remove those programs myself? I'm also fairly sure that I can't even keep the window open so that I have a reference, because it is an installer and thus locks some DLLs that need to be uninstalled too.

Yes, replacing in-use files. It's a thing that systems all over the world have been capable of doing for years. Microsoft is still unable to do this nifty little trick that's oh so useful.

You may wonder why I want to remove Visual Studio in the first place. Well, an update of Internet Explorer broke some programs, so now I'm trying to repair my installation of Visual Studio. The built-in "Repair" function didn't work, without telling me why. So now I'm back to manually having to remove and reinstall every little part.

Please, Microsoft, join the new millennium and start using a package manager like all those Linux distributions have been doing for years. They don't use a package manager to tease you. They use a package manager because it's bloody useful.

Update: after hours of waiting while my computer uninstalled and reinstalled everything, it still didn't solve my problem. Snif.

08 Sep
Removing duplicate mails

To sync my mail between computers I use offlineimap on a secure filesystem. Today I mistakenly ran offlineimap before mounting the secure filesystem, which caused it to duplicate all emails. Not wanting to do any manual work to fix this, I wrote a small Python 3 program that repaired the damage.

Read on after the break for the code.

22 Jul
The current state of Big Brother

threesixtyfive | day 189

Big Brother is watching you. More and more invasions of your rights are done in the quest for "digital rights management" and "protection of intellectual property". Check out Farhad Manjoo's post Why 2024 Will Be Like Nineteen Eighty-Four, as he describes it much better than I ever could. Please, read that post.

30 Jun
Refusing to continue

I've seen this so many times, and thought about writing about it. Today I found some code that is too good an example to let it go. I'm talking about the refusal some people have to using the continue statement. Here is an example in some pseudo-code:

for value in list {
  if value.condition == True {
      do stuff
      do more stuff

It looks like fine code, but personally I'd rather use:

for value in list {
  if value.condition == False: continue

  do stuff
  do more stuff

Read more about my coding philosophy after the break

08 Apr
Multiblend 1.4 released

I've released a new version of Multiblend! Version 1.4 has the following improvements over the previous version:

  • Display timing info after rendering.

  • Added -E option to skip existing frames and render only the missing ones.

  • Smarter distribution of frames.

  • Implemented simpler logging.

  • Verifies that the output directory exists before rendering.

  • Added 'cachesync' executable that can distribute the Blender cache directory (such as used with particle systems) to nodes.

  • Removed use of the md5 module when using Python 2.6 or newer.

  • Replaced the popen2 module with the subprocess module. This limits the compatibility of Multiblend to Python 2.4 or newer on the master node.

  • Split the implementation into several modules to increase maintainability and insulation of the parts.

Multiblend connects to multiple computers on your network, and lets Blender render in parallel on each. This will drastically improve your rendering speeds!

08 Apr
Fighting for Umlaut

For my Master of Science course in Game & Media Technology at the Utrecht University I had to make another 3D animation. This time the focus was on more traditional animation techniques such as stretch-and-squash.

Fighting for Umlaut from Sybren A. Stüvel on Vimeo.

The assignment was to make a 3D animation with your last name playing a role. I chose this particular subject as many, many computer programmers are having a hard time separating UTF-8 from Latin-1, which renders my last name as Stüvel :(

31 Mar
Cleaning up an Ubuntu system

Shining skies

Ubuntu uses quite a nifty package manager. It keeps track of which file belongs to which package. Not only that - it also keeps track of which packages you requested, and which were installed as a dependency.

The package manager can remove unused dependencies automatically. And this is what we'll be using to clean up your Ubuntu system. You see, you can mark packages as installed automatically, even if at some point you requested them yourself. By marking them as "automatically installed" you can be sure that they are only removed when they really aren't needed any more. Here's how it's done:

  1. make a list of manually installed packages:

          aptitude search '~i!~E' -F '%M %100p' | grep -v ^A > manual_to_auto
  2. edit the file and remove from the file the packages you want to keep.

  3. read through the manual_to_auto file again to see whether you can afford to remove the packages that are in there.

  4. mark all packages that you left in the file as "automatic". This will show a list of packages that will be removed and give you a chance to review the changes and bail out before anything harmful happens. Feel free to abort, re-edit the manual_to_auto file and try again until you're happy

          sudo aptitude markauto $(< manual_to_auto)
  5. Be happy with the free space. I've freed up 1 GB on one machine and 500 MB on another with this method.

I suggest you remove at least the following packages from the manual_to_auto file:

  • linux-generic

  • linux-image-generic

  • linux-restricted-modules-generic

  • ubuntu-standard

  • ubuntu-minimal

  • ubuntu-keyring

  • the ....-desktop packages

Be careful; if you're in doubt, remove the package from the list. Everything that you remove from the file will be kept as "manually installed".

If you find out that you removed too many packages, you can simply reinstall the ones you need. Since we haven't purged the configuration files (see below) they should simply work as before when you reinstall them.

I've used information from various sources. However, most of them fail on long package names like linux-restricted-modules-2.6.24-23-generic, because by default Aptitude only shows the first 30 characters of the package name. I also feel more comfortable having a file that I can edit and review before actually marking any packages.

Another cleanup step can be performed by removing all configuration files that belong to uninstalled packages:

  dpkg -l | grep ^r | awk '{ print $2 }' | sudo xargs dpkg --purge

Be warned: this command does not ask for any confirmation. Don't come crying to me when it runs off with your girlfriend.

18 Mar
I'm "Featured Photographer" on Flickr

Foggy house at sunrise

I'm a "Featured Photographer" on Flickr, together with my girlfriend Marit. Check out the Flickr Places for De Gouwe, my hamlet of birth.

22 Jan
RSA version 1.3 released

A new version of my pure-Python RSA implementation has been released. The one major change is improved compatibility with Windows.

Download EGG files for Python 2.4, Python 2.5 or the source package at the Python Package index.

12 Jan
Toying with Voronoi diagrams

For my Master of Science degree I have to work with Voronoi diagrams. They can be easily visualized (and toyed with) with the DotPlacer applet.

Just enable the "Voronoi" check box, and add some points!

08 Jan
Bridged networking in KVM

One of the advantages of VMWare is that it has easy to set up bridged networking. However, I love Open Source so I started to experiment with KVM, the Kernel-based Virtual Machine.

Setting up bridging is a bit daunting, but not that complex once you've gotten the hang of it. I placed everything in a script for easy invocation. One of the features I wanted was that ending the script should tear down the bridged network, even when pressing Ctrl+C. This is my script:

  #!/bin/bash -x

if [ "$USER" != 'root' ]; then
    echo "Restarting as root"
    exec sudo "$0" "$@"

brctl addbr br0
brctl addif br0 eth0
ifconfig eth0 promisc up
ifconfig br0 netmask
route add default gw br0

function restoreNet {
    ifconfig br0 down
    brctl delif br0 eth0
    brctl delbr br0

    ifconfig eth0 netmask
    route add default gw eth0

trap restoreNet EXIT

kvm \
    -localtime \
    -hda kvm-xp.qcow \
    -m 512 \
    -usb -usbdevice tablet \
    -net nic \
    -net tap \

Some of the features are:

  1. It starts bridging eth0 and the virtual machine's network. This means that the VM can do a DHCP query and get an address from my DHCP server, for instance.

  2. The bridge is always removed when the script ends.

  3. The mouse simulates a tablet. This allows for absolute positioning, which you'll notice allows your mouse to transparently move between your host system and the VM.

  4. Any commandline arguments you give to the script are passed to KVM.

  5. To create and remove the bridge, the script needs to run as root. If you didn't run it as root, it automatically uses sudo.

Things you'll probably want to edit:

  1. My desktop uses a fixed IP address, replace that with your own IP address.

  2. My gateway has IP address, replace that with your gateway/router address.

  3. My desktop uses eth0 to connect to the network. If you use another device, replace it.

  4. I use this setup to run Windows XP in KVM. The Windows installation is stored in kvm-xp.qcow, replace that with the harddisk image you want to use.

Enjoy! If you have any questions or remarks, post a comment below.

28 Dec
I can only get health insurance by breaking the law

Frustration (was: threesixtyfive | day 244)

My last name is Stüvel. Apparently, this is very difficult for many programmers and testers to understand. Here are a few of the ways that my name is displayed by various applications:

  1. St??vel

  2. St�vel

  3. St++vel

  4. Stüvel

  5. St&#252;vel

  6. St\xc3\xbcvel

  7. St vel

  8. St☐☐vel

  9. St³vel

  10. StĂźvel

  11. StÃ╝vel

  12. St? <Input Name=

  13. St~vel

  14. StÃ☐üvel

  15. StÃOvel

  16. St?üvel

  17. "your last name contains illegal characters"

Names with accents are really common here in The Netherlands, and even more so in the entire continent of Europe. Many people from all over the world immigrate to The Netherlands, so every application in our country that requires a person to fill in their name should be equipped to handle at least European names.

Nowadays it gets so bad that I'm having trouble applying for health insurance! When applying, I have to fill in my name and other personal information on the insurer's website. There is much money (and fraud) involved in health insurance, so they stress that you are obliged by law to correctly fill in your personal information. This is something I cannot do. When I give them "Stüvel", they ask me to confirm that my name is "St&#252;vel", which I cannot do by law. Then again, I am not allowed to give any other name than my real name, so "Stuvel" is out of the question - it is forbidden by law. In other words: I can only get health insurance by breaking the law.

Pretty please with sugar on top, accept that we live in a world that is made up of more than A-Z and design your systems for it. Unicode has been a published standard since 1991. Perhaps it's a good idea to start using it.

19 Dec
Resting in NWN2: Storm of Zehir

The new Neverwinter Nights 2 expansion Storm of Zehir disallows resting in many areas. This is much more restrictive than what we're familiar with in other NWN2 campaigns - or any other D&D-based game, for that matter. Even after you clean out an entire dungeon, you're still not allowed to rest there.

The solution they give is the Stone of Alarm. It sounds an alarm when enemies get near, allowing you to shut your eyes and get some well deserved rest. Unfortunately, the stone works only once, and costs around 1000 gold pieces. I thought this to be rather lame - to have to pay 1000 gold for each rest is expensive, especially since we're used to always being able to rest.

My solution: unzip my altered Stone of Many Alarms ZIP file in your NWN2/Override directory, and buy a new Stone of Alarm or give it to yourself:

  1. press ~

  2. type "DebugMode 1", enter

  3. type "giveitem nx2_t_alarmstone 1", enter

  4. type "DebugMode 0", enter

  5. press ~

Enjoy resting like we're used to!

PS: the alarm stone fix by "player1" is also part of this new Stone of Many Alarms. Thanks player1!

Download the Stone of Many Alarms

15 Nov
Python Flickr API 1.2 released

Today I released the Python Flickr API version 1.2. Originally the Python interface was made by Beej, and since it's seen many an improvement. Here's what's new in this version:

  • Added ElementTree support for Python 2.4.

  • Made ElementTree the default response parser.

  • The upload and replace methods now take a format parameter.

  • Removed deprecated methods.

  • Upload and replace methods no longer report progress on their callback regarding the HTTP headers.

08 Nov
Hacking in Fallout 3, even easier

Hacking in Fallout 3 has become easier than ever. Now all you need is this website and some typing and clicking. No more cracking your brains, no more hard and difficult counting and checking letters, it's all done for you!

06 Nov
Hacking in Fallout 3

Fallout 3 is my latest addiction. It's a great game by the makers of Oblivion. Part of the game is the hacking of computer terminals. It is basically a Master Mind game, but then with letters. You click on a word that shows up in a memory dump of the terminal you are trying to hack, and the terminal tells you how many letters are correct and in the correct place. Of course, a real hacker would write a program to solve the puzzle. So, here it is:

  #!/usr/bin/env python

known = {
    'detector': 1,

words = '''
detector carpeted declared detailed dramatic devoured demanded
sinister disposal revealed messages released remained defended
peaceful designed prisoner

words = set(words.split())

def dist(a, b):
    return sum(la == lb for (la, lb) in zip(a, b))

for k in known:
    for w in set(words):
        if dist(k, w) != known[k]:
print "Try any of:", ', '.join(words)

The variable words should be filled with all the words you see on the terminal screen. The known variable should contain a dictionary with the known information you got from the terminal. For example, if you pick those:

  • detector: 1/8 correct

  • demanded: 2/8 correct

then the known variable should be:

  known = {
    'detector': 1,
    'demanded': 2,

If you then run the program (using python fallout.py if you saved the script as fallout.py) it will tell you to try "carpeted" or "messages" as your next guess.

The script requires Python, which is installed by default on most Linux and MacOS systems and should be manually installed on Windows.

update: I have automated the hacking so you can easily use this website to make the sometimes difficult hacking a lot easier.

03 Nov
Java does not support Unicode, Python does

Sometimes Java just amazes me. As a friend of mine posted, Java does not support Unicode. Of course, my favourite language Python has a much friendlier approach to Unicode:

>>> s = '⿱𠂉乙'.decode('utf-8')
>>> s
>>> s[1]
>>> print s[1]

Perhaps,. people will some day start to understand that statically typed languages are not a guarantee of a bug-free application. In the end, it's more important that a language does what it is supposed to do.

29 Oct

For the Utrecht University I made a short animation called Pong. together with two fellow students. We used Blender to add models to the MoCap data we recorded, and rendered with Blender + Multiblend.

Pong from Sybren A. Stüvel on Vimeo.

06 Jun
Pure-Python RSA module version 1.2 released under EUPL

By popular demand, we've re-licensed our pure-Python RSA module under the European Union Public Licence (EUPL). This new licence is the first open source license to be released by an international governing body.

RSA version 1.2 is code-wise the same as the previous version - the only difference is the new license. It is also still compatible the GPL. Actually, the module is now dual-licensed, under both the GPL and the EUPL. Take your pick, and use which one suits you best.

24 May
Selecting NVidia screens on commandline

NVidia has a nice program to manage display devices like monitors, TVs etc. I've used this often to play movies on my PC and watch them on our big wide screen LCD TV. What I wanted to do, is automate switching between monitor and TV. The final goal is that I can push a button on a remote to switch the output. Hey, I'm a software engineer, I automate things.

The easiest way to do that would be two write a shell script that can perform the switch for me. NVidia has be so kind as to provide us with software that can do that. It's nv-control-dpy, packaged in the nvidia-settings source, combined with xrandr.

Here is a step-by-step guide of how I managed to get things running.

  1. Hook up your TV if you haven't done so.

  2. Let X detect the TV:

          nv-control-dpy --probe-dpys
    nv-control-dpy --build-modepool
  3. Tell X to include the TV in the current set of displays. You do this by getting a list of numbers from nv-control-dpy --get-associated-dpys:

          Using NV-CONTROL extension 1.14 on :0
    Connected Display Devices:
      CRT-0 (0x00000001): Acer AL1906
      CRT-1 (0x00000002): SAMSUNG
    associated display device mask: 0x00000001

    Add the two (0x...) numbers together and include them in the next call:

          nv-control-dpy --set-associated-dpys 0x00000003
  4. Add a metamode so that X knows which device to enable/disable. The above command gave you the names and numbers of the display devices - they could be TV-0, CRT-1, DPY-4, etc. To enable the device, set it to "nvidia-auto-select". To disable a device, set it to "NULL". Here is the command that I gave to disable my Acer monitor and enable my Samsung TV:

          nv-control-dpy --add-metamode \
                'CRT-0: NULL, CRT-1: nvidia-auto-select'
  5. The last step is to tell X to actually perform the switch. You use the xrandr command for this. First, get a list of possible resolutions using xrandr:

          Screen 0: minimum 320 x 240, current 1280 x 1024
    default connected 1280x1024+0+0 0mm x 0mm
       1280x1024      50.0*    51.0
       1280x960       52.0
       1280x800       53.0
       1280x768       54.0
       1152x864       55.0     56.0
       1152x768       57.0
       1024x768       58.0     59.0     60.0
       832x624        61.0
       800x600        62.0     63.0     64.0     65.0
       800x512        66.0
       720x450        67.0
       700x525        68.0     69.0
       640x480        70.0     71.0     72.0
       576x384        73.0
       512x384        74.0     75.0
       400x300        76.0
       320x240        77.0     78.0
       1360x768       79.0
  6. The last resolution in that list is the metamode we just added. To switch to it, use xrandr -s resolution@refreshrate:

          xrandr -s 1360x768@79

To switch back, use the same xrandr -s resolution@refreshrate trick, in my case xrandr -s 1280x1024@50

Once you've figured out the names of the devices, the bit masks and the meta mode lines, you can of course place the commands in shell scripts and really get to automate stuff. I'll leave that as an exercise for the reader.

10 Apr
Python vs. Java

I've updated this article on 2011-06-15. Comments from back in 2008 are referring to the original version (which cut some corners and was a little too short).

One of the major reasons my company prefers Java over Python, is Java's static type declarations (and all the benefits that follow). If only Python had that, my life would be so much nicer. Here is an example of code I have to work with, and an example of what the Python equivalent would look like.

The background of the code: We have a list of "identifiers" that can identify people who want to use a parking garage. These can be NFC cards, credit cards, and bar codes. We want to filter the list of known identifiers and return only those of type "barcode".

The code in Java:

private List<Identifier> barcodeTypeOnly(List<Identifier> ids)
    final List<Identifier> barcodes = new ArrayList<Identifier>();

    for (Identifier id : ids) {
        if (id.getType().equals(Identifier.TYPEBARCODE)) {

    return barcodes;

What it would look like in Python:

ids = the list of identifiers

barcodes = [identifier for identifier in ids
            if identifier.type == Identifier.TYPEBARCODE]

You could write that last one on a single line, but for clarity I wrote it like this. I understand that the list comprehension construction may not be instantly recognisable, so I wrote a little explanation after the break.