How-tos

Multiple IP uplinks with Gentoo

When your computer or server has access to multiple LAN segments with different address spaces and different gateways to the Internet, there’s a nice feature called policy routing that allows you to use all of them simultaneously without having to re-configure your network topology. This is especially useful when you want to increase the bandwidth and resilience of a single computer or server without the burden of being an Autonomous System (BGP peering, Internet Registry bureaucracy, etc.).

Here are the steps to setup multiple uplinks through policy routing on Gentoo:

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Integrate Tornado in Django

Tornado is a nice python WSGI-compliant web server developed by guys at FriendFeed. It’s primarily thought as application server for python web frameworks and according to FriendFeed benchmarks, it’s blazing fast thanks to its non-blocking connections.

UPDATE: For more performance info, James Abley pointed me to a very complete benchmark of available Python asynchronous webservers. It looks like Tornado is a real monster of concurrency.

There are already some how-to’s on the web on plugging Django web framework into Tornado webserver. A quick recap:

  1. A tutorial on Tornado, Django and nginx by Jeremy Bowers.
  2. How to import django framework inside a Tornado project by Lincoln Loop.
  3. A snippet by lawgon.

My approach is slightly different as I wanted to run Tornado using Django management command-line interface.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Pre-processing Audio and Video capture to Flash in Mac OS X

Web streaming services like UStream.tv and Livestream (previously known as Mogulus) use a Flash applet to capture audio and video signals on source computer. Media stream is encoded by Flash and sent over to broadcasting server. Currently this approach has two shortcomings:

  1. Flash applet audio capture is very limited: only one device a time, only one stereo channel pair and doesn’t support devices without volume level mixer. It doesn’t allow any advanced setup like multi-channel digital mixers.
  2. Audio and video are encoded on the fly and no local copy is recorded. Streaming services offer server-side recording, but after downsampling and packet loss, quality is very low. Even worse: any connection fault will interrupt your recording.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

.gitignore for Django buildout

If you’re keeping your django buildout installation under git, you may find the following .gitignore list useful to prevent your commits from cluttering with ugly temporary files (of course it also applies to other revision control system ignore files). You may need to adapt folder names to your buildout.cfg setup.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Gentooize Part 1: colorize console

One of the best lessons you can learn from Gentoo is you can export most of its juice to other OSes. I’ve been using Gentoo as main Linux distro since 2001. Currently I have a few setups where drawbacks of migrating to Gentoo would exceed benefits, so I decided to increase affinity by adding some Gentoo look’n'feel. This week I will post some tips to setup Gentoo console colors on other operating systems.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Django dynamic template paths

Several add-on applications for Django bring in their own templates and expect user to hardcopy those files into project’s template directory. The problem raises when add-on egg is updated and its hardcopied templates are not. Another approach could be to add add-on template directory path to TEMPLATE_DIRS variable in project’s settings.py. However, once add-on application is updated, hardcoded path may not be up-to-date.

UPDATE: Vinicius Mendes commented on using django.template.loaders.app_directories.Loader to solve the problem (a similar module exists for eggs, which is named django.template.loaders.eggs.Loader). It’s definitely the easiest way if you don’t mind importing all of your applications templates. Instead, if you need to pick only selected directories or non-standard directory names, keep on reading.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Exim ldap lookup multiple DNs

Exim is one of the most flexible MTAs on the market. Its optional modules for database connectivity and its extensive config syntax allow full customization and use of external data sources. Provided LDAP backend allows three kinds of database query lookups:

ldap: This does an LDAP lookup using a query in the form of a URL, and returns attributes from a single entry. There is a variant called ldapm that permits values from multiple entries to be returned. A third variant called ldapdn returns the Distinguished Name of a single entry instead of any attribute values.

In some situations, it would be interesting to have a fourth query type: a lookup type that returned multiple DNs.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Django and mysql names

Using django 1.1.1 framework with dmigrations tool, I’ve discovered that they don’t honour mysql naming conventions correctly. In fact, mysql has a limit of 64 characters on table names, index names and column names, but django doesn’t take it into account when generating tables and indices from models.

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!     

Install wxPython in buildout

While completing setup of this blog with Wordpress, I’ve also been working on another task: adding wxPython dependency to a pythonic project of mine. The deployment of this project is done through buildout, a nice piece of software that handles a sandboxed environment for python projects.

You can find download and install instructions to start a buildout barebone here, however I will do a small recap:

Read the rest of this entry »

Add to StumbleUpon Add to del.icio.us Add to Mixx!