February 12, 2015

I’ve recently started getting into board games and I’ve become obsessed with the excellent review site Shut Up & Sit Down. In one of their podcasts (I can’t remember which one) they talked about an interview with video game designer Sid Meier. He was asked “which comes first: the theme or the mechanics?”

It’s a good question. Games seem to work well when the theme and mechanics complement and reinforce each other, but this must be a hard balance to strike.

So what’s a topic I enjoy?

I spend quite a lot of time dancing to Swing and Hot Jazz from the 20’s and 30s. The solo dance form to that music is variously referred to as Solo Jazz, Jazz Roots, Solo Charleston or Authentic jazz.

Sometimes it’s just social, sometimes it’s for formal or informal competition. You can dance it on your own, simultaneously with other people, or one at a time showing off in a jam.

But my favourite form is one-on-one, face-to face: trading one phrase at a time – showing your own ideas about the music but also taking what the other guy did and improving on it: duplicate and elaborate.

…which I realised a few days ago sounds like a pretty interesting concept for a game.

If I took what is fun about solo jazz dancing, and expressed that in terms of game mechanics: what would that look like?

May 3, 2014

Part of what makes Settlers of Catan such a great game is how well balanced it is. Part of that balance is the way in which the importance of various resources changes throughout the game, requiring players to adapt their strategies accordingly.

September 15, 2013

I’ve recently being doing a cleanup of my dotfiles (more on that later). In the process I commented out all of the “export PATH=...” statements in the profile and rc files in my home directory, but my path was still getting set to this:

I eventually worked out that it came down to some files in my /etc directory :

#/etc/paths/bin
/usr/bin
/sbin
/usr/sbin
/usr/local/bin

#/etc/paths.d/git/usr/local/git/bin

#/etc/paths.d/x11/usr/X11/bin

The paths.d method actually makes a lot of sense for a certain kind of application: it’s a nice clean way of adding bin files to the path nice and early (before any local modifications to the path).

Here’s the full order in which my paths were getting loaded in (I’m using zshell):

/etc/profile
/etc/profile.d/*
~/.zshrc (which loads in ~/.profile)

Apparently /etc/profile can come into play as well, but mine doesn’t set the path so I’m not sure what the ordering is. Indeed it looks like /etc can have it’s own set of shell-specific configs as well (mine seems to have a default bashrc), but that’s a whole other ballgame.

My solution

Now that I properly understand how my path is getting generated, I’m comfortable setting it from scratch in my local profile:

#~/.profileexportPATH=/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

I prefer to have /usr/local/bin first, because this means that I can install things in /usr/local and symlink them into /usr/local/bin without conflicting with any old versions which came bundled with the operating system (and thus live in /usr/bin)

I could have achieved the same effect by editing /etc/paths, but I’d like to try and make my dotfiles as portable as possible

I’m not sure how I got into that situation, but this duplication was an itch which had to be scratched.

Removing this from .zshrc gives the following error when trying to use rvm:

Warning! PATH is not properly set up, '/Users/duncanstuart/.rvm/gems/ruby-2.0.0-p247/bin' is not at first place,
usually this is caused by shell initialization files - check them for'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p247'.

This is fair enough: for reasons I don’t fully understand, rvm needs a bunch of paths to be at the very beginning of PATH – that’s why the lines in question need to be at the end of the .zshrc file. Looking at my path (echo $PATH), those paths are in the middle somewhere – presumably being added by .zprofile. No good.

On the other hand, removing this from .zprofile gave me a couple of errors from rvm on opening a new terminal:

A search on stackoverflow suggested the thing to do was to remove ~/.zshcompdump

As far as I can understand from the zshell docs, this is something to do with autocompletion:

To speed up the running of compinit, it can be made to produce a dumped configuration that will be read in on future invocations; […] The dumped file is .zcompdump in the same directory as the startup files

Fine – sounds very deletable. And indeed, deleting it removes the errors, so I can happily leave those lines out of my .zprofile. Also, as expected, a fresh .zcompdump got generated.

One final thing: I noticed that opening a new terminal was taking slightly longer than before. Compiling the new .zcompdump seems to shave off a couple of milliseconds and makes it feel nice and responsive again:

December 7, 2012

I just realised something: when I have copied text to paste elsewhere (as I do tens of times every day) I experience the fact that I ‘have’ text as a physical sensation, like I’m actually holding on to an object, which I then release by pasting.

Given how much and how regularly I use a computer it’s in no way surprising that it should have effects on my psychology.

May 29, 2012

I’m entering a bunch of divisions in the London Jitterbug Championships (LJC) this weekend, amongst them the Fast and Furious – danced to songs of 250bpm upwards.

A couple of people have asked if me and my awesome partner F are going to be doing swingouts in that division. Now I can swing out comfortably at maybe up to 230bpm, but when you crank it up to 260, I run into two critical problems: firstly it looks awful and secondly it’s super-uncomfortable for my follow.

Let’s have a look at what the dancers did in last year’s event:

There’s some awesome stuff in there from every couple, but essentially most of the dancers are dancing like this is just an especially fast Strictly Lindy competition (160 to 200 bpm at LJC). That’s fine if you’re super-experienced Ninjas like Fabien and Lisa (Black waistcoat, blue skirt) or Jamie and Sally (Black waistcoat, black skirt), but otherwise things start to look rushed and fall apart.

I don’t want to try and dance how I usually dance, sped up 25% – we would get through it, but it wouldn’t look great. I want to play a different game. I don’t want a pat on the back for trying: I want us to place.

The description of this division says:

This division is all about speed and style! This is NOT a Strictly Lindy event; the more Shag, Balboa and 20s Charleston dancers there are, the more interesting the event.

We plan to take this and run with it.

So no, you probably won’t see any conventional swingouts from us in the competition on Friday*.

What are you going to see? Hopefully something awesome. Hopefully something more together and smooth than the flailing sight of me swinging out at 260bpm. Hopefully some things you’ve never seen before. For any more than that, you’re going to have to watch the comp.

May 14, 2012

I’ve had a bit of trouble understanding how to get Heroku to cache pages from Swing Out London, so here’s my explanation – hopefully it’ll help someone.

The TL:DR

Varnish Caching on Heroku IS as simple as the docs state but because Heroku has multiple Varnish servers, any given request is unlikely to return a cached copy unless your site has a lot of traffic, or you set max-age to a large number.

The Basics

Some of the Heroku stacks (currently Aspen and Bamboo) support basic caching using Varnish – a service which sits in front of your application server and serves up cached content. It essentially works in the same way as your browser cache, except that when the varnish cache serves up your content, it

Telling Varnish to cache your content is the same as telling a user’s browser to cache content for a limited time:

The Problem

When I first tried this, it didn’t seem to be working at all – the response header was being set on the page, and Varnish was being used, but the request was reaching the application. Here are some example http headers:

This says “This page is 40 seconds old, and was originally cached as part of request 793811181”.

So it seemed like Varnish was caching, but only intermittently. A number of other people seemed to have the same problem.

The explanation

It looks like Heroku has multiple Varnish instances running independently, so when you request a page you could be hitting any of those instances. Here’s a likely scenario for a site with low traffic:

Let’s assume there are 3 varnish instances: A, B and C (Heroku maybe has 10) and represent the age of the cached pages on those instances as [a, b, c]. Now if the max-age is set to 25 seconds, and I make a number of repeated requests, I might see the following:

[-, -, -] On the first request I get sent to A. A doesn’t have a cached copy so requests the page from the server and caches it:

[10, -, -] Ten seconds later I make another request and get sent to B. Ditto.

[20, 10 , -] Ten seconds later I make another request and I get sent to C. Ditto.

[30, 20 , 30] Ten seconds later I make another request and I get sent to A again, it has a cached copy, but it’s older than the max-age so I discard it and request the page again from the server.

If on the other hand those requests were made every 5 seconds (i.e. if the site had higher traffic) then on the fourth request the cached copy would only be 15 seconds old so would be returned.

The solution

Increasing the max-age makes a big difference – I’ve set mine to 20 minutes for the time being. In slow periods not many pages will be served from the cache, but when traffic increases, the number of requests to the server will remain relatively similar.

The thing to understand is this: if the number of varnish instances is N and you’ve set the max age to A, then of the requests made in any period of A seconds, on average N of them will hit your server.