The Sinclair Spectrum font simulator

This one goes out on a whole new axis of pointlessness, but here it is:

I wrote a PHP version of this a long time ago, but it was kind of limited (and PHP sucks). So I've now rewritten it in python to be much more flexible. So what can it do?

Console version

./console_spectrum.py 1982 will generate this:

                                                                        
              OOOO          OOOOOOOO        OOOOOOOO        OOOOOOOO    

Reflection

On the road back to El Calafate

Push an iTunes playlist onto an Android phone

So here's the thing: iTunes will let you export a playlist as plain(ish) text. This script will:

  • Parse that playlist file
  • Remove from it any tracks that are already on your Android *
  • Work out if your Android has enough free space to accommodate the new tracks
  • Push the tracks to the Android

Permutations

We want to work out all the possible arrangements of a list of n items. Why? We don't know. But we do know how to do it: seed with a list containing a single list containing a single item: [['a']]. Then step through each of the lists in our list, and make copies, inserting the next item ('b') at each index, so we get [['b', 'a'], ['a', 'b']]. Then we take this list as our seed and go round again, inserting the next item ('c'), so we get [['c', 'b', 'a'], ['b', 'c', 'a'], ['b', 'a', 'c'], ['c', 'a', 'b'], ['a', 'c', 'b'], ['a', 'b', 'c']]. And so on and so on, until we've permuted all of our items. These lists get pretty big pretty quickly (the length of the list is n! so 10 items generates 3628800 combinations, and doing this may bring your computer to its knees).

Ladybird

Ladybird

Avoid being kicked in the head when configuring anonymous Subversion access

Granting anonymous read-only access to a single repository in a site with multiple repos led to much swearing. But I've now cracked it. Here's how...

What was I trying to do?

I'm running SVN via Apache, authenticating with basic HTTP auth. I have a few repositories in my SVN, and I wanted to grant anonymous read-only access to just one of them. So let us begin with

The naive solution

The first thing I tried was using something like this in my apache vhost:

   <Location />
      DAV                  svn
      SVNPath              /home/svn/

Calculate π by throwing darts

We can approximate pi using nothing more than random numbers and some simple geometry: in essence, we randomly throw darts at a square board of side r; within the square we inscribe a quadrant of a circle of radius r with its centre at (0, 0). We count all of the 'throws'; if a dart lands within the quadrant, we also count a 'hit'.

For a large number of throws, we see that:

        hits    area_of_quadrant
       ------ = ----------------
       throws    area_of_square

Some half-remembered geometry tells us that:

       area_of_quadrant   (1 / 4) * pi * r^2   pi
       ---------------- = ------------------ = --
        area_of_square           r^2            4

Or:

     
                area_of_quadrant        hits
       pi = 4 * ---------------- = 4 * ------
                 area_of_square        throws

Flowers

Flowers

CCC 2011

It's on

August 10th-14th at the same awesome place as the 2007 event.

I reckon we should aim to travel there over two days, stopping at a hotel along the way, to avoid the mad dash for the good camping spots.

Hello

Param3.com is born...

Syndicate content