Timur Izhbulatov — Independent Electronic Music

Source code

If not otherwise specified, all source files can be downloaded from the Subversion repository:

svn co http://timka.org/svn/timka.org/ timka.org

RSS 2.0

Avoiding leakage of passwords to log files

Sat, 04 Jun 2011 06:59:00 in Tech stuff | permalink


MaskedString still holds the actuall string data which is accessible via __getitem__ but overrides __str__ and __repr__ so that the string is presented in blinded form. This is useful for preventing leakage of sensitive data (card numbers, passwords etc.) to log files.

(Read more...)

Simple pure Python config

Sat, 23 Apr 2011 04:20:00 in Tech stuff | permalink

config python

(lambda path:
    open(path, 'w').write('path = %r' % path) or
    globals().__setitem__('__name__', None) or
        repr('config:' + path),
        (lambda d:
            execfile(path, {}, d) or d

(Read more...)

Using inline types for mocking objects

Fri, 22 Apr 2011 01:00:00 in Tech stuff | permalink


A code snippet from my recent work:

def run_cmd(cmd, pipe=True, dry_run=False):
    log.debug('%r', cmd)
    def mock_child():
        return type('dummy_child', (), dict(wait=lambda x: None))()
    if dry_run:
        return mock_child() 
    stdout = subprocess.PIPE if pipe else None
        child = subprocess.Popen(cmd, stdout=stdout, shell=True)
    except Exception:
        log.exception(cmd + ':')
        return mock_child()                                                                                                                
    return child

(Read more...)

Application components under shared namespace

Tue, 24 Aug 2010 21:50:00 in Tech stuff | permalink

paste python setuptools turbogears

It is often desirbale to decompose an application into several components. Perhaps one of the most common approaches is separating a model component that is responsible for data repesenataion and interaction with the database and then use it from other components. For instance, one of the other components can provide a sofisticated web-based UI to the model while another one implements a bare command-line interface.

In this situation each component is a subproject that is distributed as a separate package, in the setuptools' sense. And view each component has its corresponding directory in the project's VCS repository which contains a everything that is typicaly necessary to build an .egg, setup.py and whatever else the developer finds approprate.

A component, or subproject, usualy includes a number of modules which are organized inside a Python package. While it is possible to name the components' packages like yourappmodel, yourappweband yourappcli, The Zen of Python says:

Namespaces are one honking great idea -- let's do more of those!

And applying to our example that means the packages should be named like yourapp.model, yourapp.web and yourapp.cli.

Here I'm going to show how I work with a project that uses setuptools' namespace packages.

(Read more...)

Haskell is self-hosted

Mon, 09 Aug 2010 12:50:00 in Tech stuff | permalink

haskell love software

I my previous post I wrote about the technological things I love, and this time I am going to make a new addition to that, Haskell.

Cool Haskell pixel art

Haskell is a very interesting language. It even seems somewhat alien to a person with background mostly in imperative and non-functional declarative programming languages like yours truly.

(Read more...)

qooxdoo ContribLoader

Fri, 23 Jul 2010 21:28:00 in Tech stuff | permalink

python qooxdoo

Just a short note to myself. There's a bug in qooxdoo tool in generator.action.ContribLoader.getRevision(). The regular expression part should be

match = re.compile("\/viewvc\/qooxdoo-contrib\?view\=revision\&revision\=([0-9]+)").search(line)

(Read more...)

Confession of Love

Fri, 23 Jul 2010 00:12:00 in Tech stuff | permalink

brevé dsl love pylons python rudd software turbogears wsgi

It's been a long time since my previous update, and many things have changed in my life. I've changed my job, quit my job, gone crazy, fallen in love, found myself, had two trips to Crimea, had a psychedelic experience and got a real African djembe from Ghana.

But there's one thing I haven't done yet and it's confession of love. Not the kind of love we fall into, no. I'm talking about the professional kind of love.

Why do I even talk about love in such an intellectualized high-tech field as information technology? I do this because I it's very important for me. Really, I've been working in IT since 2003, not to mention my earlier programming experience in the university and at school, and only now I fully realize why I'm still here. I simply like it.

(Read more...)

Python urllib2 exceptions

Sun, 17 May 2009 11:53:00 in Tech stuff | permalink

last.fm python urllib2

Yesterday I made a working prototype of my Last.fm stream ripper written in Python. This is my second project that relatively intensively uses urllib2 from Python standard library.

One of important things that I've learned about urllib2.urlopen() from my previous project is that it does raise some other exceptions besides urllib2.URLError (e.g. http.HTTPException and socket.error) which is the only one mentioned in the documentation.

(Read more...)

How to fix font rendering in Firefox 3.5 on Ubuntu 9.04

Sat, 02 May 2009 06:32:00 in Tech stuff | permalink

firefox-3.5 font-hinting font-rendering jaunty mozilla-weave ubuntu

Yesterday I set up a fresh desktop with Ubuntu 9.04 (Jaunty Jackalope). One of the most pleasant features is Firefox 3.5 beta (Shiretoko) available out of the box, which is important for me since I use Mozilla Weave to sync my profiles. The problem is that Firefox 3.5 doesn't seem to use font hinting and therefore looks ugly while the default version (3.0) is OK.

(Read more...)

Singleton in Python

Wed, 17 Dec 2008 01:02:00 in Tech stuff | permalink

pattern python singleton

Updated 2009-03-03. Arbitrary constructor arguments (Mark's suggestion).

Updated 2008-12-30. Thread-safety.

A recent discussion has drawn my attention again to the use of the Singleton pattern in Python. Here's how and why I do this.

(Read more...)

Last.fm tag renaming utility update

Fri, 15 Aug 2008 16:35:00 in Tech stuff | permalink

last.fm python tagging

I've updated my Last.fm tag renaming utility.

(Read more...)

Release of watchdogdev

Mon, 21 Apr 2008 14:08:00 in Tech stuff | permalink

linux mplayer python watchdog watchdogdev

One of my projects is a Linux-based embedded device for playing commercials. The software part is a Python application controlling an MPlayer process in slave mode.

To make the whole system more fault-tolerant I wanted to use watchdog timer which would reboot the machine in case of software failure. Thus I needed to talk to Linux watchdog driver from my Python application. The Linux watchdog API defines a number of ioctl commands which can be sent to the driver. So, I wrote an extension module which enables Python programms to use Linux watchdog API.

(Read more...)

TurboGears behind Apache with Virtualmin

Wed, 19 Mar 2008 11:05:00 in Tech stuff | permalink

apache cherrypy debian linux python turbogears virtualmin webmin

Recently Matvey (thanks dude!) has set up a new Virtualmin hosting platform on Debian GNU/Linux. When I was migrating timka.org to this new platform I found out that Virtualmin is actually very powerful and nicely integrated with Apache in Debian. Looking at all these new features and capabilities I thought that I could try to use them for running home-based TurboGears applications on Virutalmin's virtual hosts.

(Read more...)

Home-based installation of Python libraries

Wed, 30 Jan 2008 11:38:00 in Tech stuff | permalink

linux python setuptools

Many popular Python libraries are available in various Linux distributions. However, it is not always possible and/or desirable to install them from packages. For instance, sometimes you don't have root access to the target machine or just want to have other vesrion of some library isolated under your home directory.

I've been successfully using this approach on my laptop and several development and production sites for about two years so far.

(Read more...)

Blog engine for timka.org

Sat, 26 Jan 2008 20:01:00 in Tech stuff | permalink

blog python timka.org wadcomblog

I've been looking for some simple static blog engine and stumbled upon WadcomBlog by Vlad Skvortsov.

(Read more...)

GNU Autotools tutorial

Thu, 01 Mar 2007 in Tech stuff | permalink


Have you ever installed any software from source? If you have I bet you've also noticed all that stuff like configure.in and Makefile.in. Want to know what's it for, how it works and how it can be used? I've written a brief tutorial.

(Read more...)

Editing ID3 tags with Python and Mutagen

Thu, 01 Feb 2007 in Tech stuff | permalink

id3 mutagen python tagging

Recently I've stumbled upon some MP3 files containing no tags. I tried to tag these files using Quodlibet but it appeared to be impossible. After a breif investigation of the problem I found out that it's just raw MPEG Layer III streams with no proper ID3 headers. In order to fix this I decided to write a Python script.

(Read more...)

Fixing Last.fm tags using Python standard library

Mon, 22 Jan 2007 in Tech stuff | permalink

htmlparser httplib last.fm python tagging xml-rpc

Updated 2008-08-15. Works with new Last.fm.

I've written a Python program for renaming tags on Last.fm.

(Read more...)