Python hug with apache mod_wsgi

I found it surprisingly difficult to find a plain explanation of setting up hug and apache mod_wsgi. So here is how I did it.

Minimal hug API

Writing an API with hug is really easy. You can write a "hello world" in four lines of code:

import hug

@hug.get ...
more ...

Cloning a Linux Partition

Whenever I want to test a new release of Ubuntu I find myself cloning the root partition so I can safely upgrade and still keep my old install.

However, I usually forget some step and end up needing to debug grub boot. So this is a summary of what needs ...

more ...

New Site

After my old WordPress setup broke one time too many I finally decided to convert the site to something nicer to work with. I ended up going with Pelican, which is a static site generator using Python.

It seems quite basic at first, though I'm sure there are features ...

more ...

User-Transparent LZ77 Steganography

Recently, demand for high-speed compression has lead to new algorithms based on pure Lempel-Ziv compression without entropy coding. Examples are Snappy and LZ4, both using byte based LZ77 algorithms. This leaves significant redundancy on the table that can be used for steganography while remaining completely transparent to the users of ...

more ...

Fast Approximate Move-to-Front

Move-to-front is an algorithm for coding symbols that have been seen recently with a smaller number. It’s used as a part of some data compression algorithms, e.g. after a Burrows-Wheeler transform.

I tried to approximate it in a faster way and found an algorithm that I haven’t ...

more ...

Working With Multiple Mercurial Queues (hg mqs)

I've recently been using mercurial for revision control. I still don't like it much as git, because it tries so hard to prevent me from modifying history (modifying local history is not a bad idea) and has so many tools that do almost the same thing.

However, the ...

more ...

Remote Control Rhythmbox from Command Line

I have a mostly-headless HTPC without keyboard, so it is easier to control it remotely. VNC lets you do anything, but for simple things a command line is faster.

My media player of choice is rhythmbox, so there's an easy way to control it: rhythmbox-control. However, it requires an ...

more ...

Natural Order String Comparisons in C

I wrote a simple natural string order comparison function in C. I later found out I basically reimplemented (a part of) Martin Pool's strnatcmp, so I renamed mine that as well.

The idea is that in many cases the string "foo10bar" should sort after "foo9bar" instead of in between ...

more ...

Merging Persistence Changes in Ubuntu Live USB

When using Ubuntu Live USB there is the option of using persistence to store changes on the USB. It uses aufs to layer a read-write filesystem on top of a read-only squashfs compressed filesystem. This is great, because it fits over 2GB worth stuff into a c. 700MB default live ...

more ...

Reboot to Another Kernel (or Windows) with grub2

Update: Updated below for 11.04/Natty.

So I had some trouble getting grub-reboot to work, since it only seems to like numbers, but I figured it out. I made a script to reboot to another kernel or OS (Windows for me) once, leaving the default unchanged.

First one must ...

more ...

Why Windows is a Pain

AKA: .NET Sucks

I just had to reinstall a Windows XP virtual machine. To make all my programs run I had to manually hunt down and install four versions of the .NET runtime (1.1, 2.0, 3.0 and 3.5. Soon it will be five with 4.0 ...

more ...


Encrypted Google Search for Chrome

I recently moved to Chromium - the open source version of Google's Chrome browser - after I grew tired with Firefox crashing and bloating my system.

Chrome defaults to searching with auto suggestions through the omnibar (location/search bar) using an unencrypted connection, but it is easy to use Google's ...

more ...


Radeon Power Management in Ubuntu 10.10 (Maverick)

One of the changes in the recent Ubuntu 10.10 (Maverick) is the upgrade of Linux kernel from version 2.6.32 (in Lucid) to 2.6.35. The change introduces several new features of which I especially like Radeon power management (for use with open drivers).

Unfortunately the default ...

more ...

Hash Prioritized Treaps

In looking for a data structure for a memory management problem I tried to find a self-balancing tree that would use as little space as possible. The only one I found from Wikipedia that didn't require any additional information at nodes was the scapegoat tree.

Unfortunately, it's not ...

more ...

Asus Eee PC 1001PX and Ubuntu Linux

To make the wireless of my 1001PX work in Ubuntu Lucid I had to install the 2.6.35 kernel from Kernel team PPA. The package name is linux-meta-lts-backport-maverick and it should eventually become available in the Lucid package archives.

Unfortunately, the touchpad didn't support multi-touch OOTB and the ...

more ...


Disabling the WordPress Maintenance Lock

I just got bitten by the automatic maintenance lock with WordPress updates. My internet connection failed in the middle of a plugin update and left the blog in maintenance mode. Google answers to disabling it were unhelpful, so here goes:

Just delete the .maintenance file is the WordPress directory.

Additionally ...

more ...

Aliasing Hostnames on Linux (Ubuntu)

When Googling for hostname aliasing on Linux, the most prominent answers were for SSH hostname aliasing, which is simple. For a general purpose solution the common answer was "install a DNS server", which is way over the top. Here's what I managed to figure out.

The objective is to ...

more ...

Splitting Files in-Place on Linux

Ok, so I have a 160GB disk image I need to split to small pieces (so I can compress those individually in the background later), but I only have a few GB free on the disk containing the image. Unfortunately, split isn't in place. Here's what I managed ...

more ...

Otus.mod Now on Google Code

I have finally moved to using Google Code and Mercurial distributed VCS for my "Otus.mod" BlitzMax module collection.

The modules are currently only available through the source repository. I'm unsure if I will bother with separate downloads at all. Getting the whole set is as easy as hg ...

more ...


Trust Slimline Sketch Tablet on Ubuntu Karmic

Update: See the bottom for Ubuntu Lucid

I just installed my new Trust Slimline Sketch graphics tablet on Ubuntu Karmic 9.10. It was reported as "UC-LOGIC Tablet WP8060U" by xinput. Here's how I made in work, (based on Ubuntu wiki and some Googling):

1. Install wizardpen from Michael ...

more ...





Increasing Display Resolution in Virtual Machine Manager

With KVM you can use a high resolution by passing kvm the -vga std parameter (or -std-vga before KVM-77). When using virt-manager to manage virtual machine guests, there is no option to change display resolution. However, it is possible to work around it as follows.

First, create a bash script ...

more ...

Remote Actors for BlitzMax (Experimental)

This is an experimental version of a threaded remote actor module for BlitzMax. It extends the features of my actor module with server and client actors, which pass messages through a network socket. It should allow increased parallelism for an actor based program with very little added complexity.

Included are ...

more ...

Actor Model for BlitzMax v.1.20

Implementation of the actor model for BlitzMax, updated version 1.20 with better thread management and more robust locking. Works both threaded and non-threaded, though there are obviously some differences. Methods and types state when they are threaded-only. Requires a fairly recent version of BlitzMax.

Included are three simple sample ...

more ...

Actor Model for BlitzMax v.1.10

Implementation of the actor model for BlitzMax, updated version 1.10 with better thread management. Works both threaded and non-threaded, though there are obviously some differences. Methods and types state when they are threaded-only. Requires a fairly recent version of BlitzMax.

Uncomment the Module lines and save to mod/otus ...

more ...

Object Oriented File System Interface (BMX)

Here's an object oriented file system interface I've been using for my own projects. It's a module with source and Windows binaries. It is complete with TStream support, including OpenStream interface. It should be pretty intuitive and also includes docs.

Download: Otus.FS.zip (60 KB)
Install ...

more ...

Synchronized Data Structures for BlitzMax

Synchronized list and map data structure modules for BlitzMax. Just a simple mutex-locked wrapper over the BRL types to make operations atomic. Should be compatible with old code.

Prebuilt for Windows with source. Built using 1.33rc5, but 1.32 should also work. Linux and Mac versions of BRL.Threading ...

more ...

Simple Data Description Language

I threw together a parser for a simple data description language in BlitzMax.  The syntax is something like that in Python or Lua, but not quite. Whitespace is always insignificant and there are no fatal syntax errors: the whole file is always parsed, and non-conforming markup is ignored (silently by ...

more ...

Python Raytracer in 50 Lines of Code

I've come to like the expressiveness of the Python language, though I dislike some of the other features. Here's a 50 line raytracer that renders scenes of colored spheres to a PNG file:

import math
from PIL import Image

def sub(v1, v2): return [x-y for x ...
more ...

C for Blitzers

This tutorial attempts to show the basics of working with C in your BlitzMax programs. BlitzMax manual/help has a section titled "Interfacing with C and other languages", but I find it short and confusing. A PDF version (PDF, 142KB) of this tutorial is available, as are sources for samples ...

more ...


LZMA Streams for BlitzMax

As promised, here is a BlitzMax module based on my LZMA module that handles automatic compression of streams. By using it reading and writing compressed files is as easy as using "lzma::" as a prefix to OpenStream.

It should also work fine with other types of streams, eg. IncBin streams ...

more ...

LZMA BlitzMax Module

I wrapped together a BlitzMax module for LZMA compression. It is based on LZMA SDK (version 4.62) and only has a BlitzMax wrapper written by me - the rest is someone else's work. It is completely in the public domain.

There are two releases for this. The source only ...

more ...

Ray-Sphere Intersection

I'm writing a small raytracer to familiarize myself with Java. Obviously many of the main algorithms need to be as fast as possible in order to eventually get to real time speeds.

Here's my optimized version of a ray-sphere intersect check. It can probably be tweaked further: 9 ...

more ...

Solving Vista Networking

My first impressions after using Windows Vista extensively are somewhat positive. The only major problem that remains is that I'm completely unable to have Windows Network work between the Vista machine and another desktop with XP. However, there were other problems, one of which had to do with "limited ...

more ...

MaxPre Alpha Prerelease

I've pulled together a first alpha release of MaxPre - a preprocessor for BlitzMax.

It should support most syntax, but may well throw many random looking errors. It has a simple support for properties, like those in the .NET languages, through the new keyword Property. the test file will show ...

more ...

Speed Up Firefox 3 Places

I've been using Firefox 3 since the first beta and it's a very good and quite stable browser. However, there's one "enhancement" that bugs me a lot. And that is the history+bookmarks combination that they call "Places".

Someone on a modern computer will probably not mind ...

more ...

BlitzMax Object Loader Module

In connection with another project of mine, I produced a BlitzMax module that allows writing and reading arbitrary objects to streams. It can also be seen as a generalization of ReadInt, WriteString and the rest. It should be useful for saving game states or creating an undo feature.

It uses ...

more ...