luft·mensch

How to couple a service to a USB device

I am a music junkie, and so is my wife. We are both heavy users of Logitech’s Squeezebox system. Even though Logitech doesn’t distribute hardware devices any more, Squeezebox always was, and still is, a great — free and open source — software solution for those of us who want ...

more ...

Building a static website: the content provider

Now that you have a basic skeleton up and running, it is time to think about how to push your content into the open. I currently am on a solution using Amazon Web Services but I’ve tried four different approaches so far. I’d like to discuss their respective ...

more ...

Building a static website: the website generator

I became aware of static website generators when I read a blog which was built using Octopress. I was surprised how many of the features worked out of the box that I had wrestled with using Drupal, among them a proper support of Markdown, typographic refinements, code inclusion and sytax ...

more ...

Building a static website

I’ve been quite busy over the last couple of weeks revamping my blog. I had originally started with a dynamic site built upon Drupal: I wanted to learn how modern content management systems (CMS) separate content, style and functionality. I took a bit of a learning curve around topics ...

more ...

Named bitmap

Every now and then, one needs to keep track of a family of flags (boolean values), which you naturally would store in a numerical field which saves a lot of space and is database-friendly. Although the bit algrebra is straightforward, one often wishes to abstract that a little bit and ...

more ...

Shut up and measure!

You probably have heard of the term premature optimization. It refers to writing “fast” code which is more obfuscated and (more often than not) slower than a straightforward approach — before you have bothered to measure whether it really pays off to spend your cerebral CPU time (which is usually much ...

more ...

How to transpose a matrix

Python is such an expressive language. For instance, you can transpose a matrix in one line:

def transpose(matrix):
    return zip(*matrix)

>>> m = [(1, 2, 3), (4, 5, 6)]
>>> transpose(m)
[(1, 4), (2, 5), (3, 6)]
more ...

The Singleton pattern

In this post I am going to discuss the Singleton pattern in the Python context. Singleton is a design pattern which addresses the problem that one often would like to have a single instance of some class, say, of a database connection pool or a logging facility. This instance is ...

more ...