Computers

Strange error in Go: 'fmt.Println not used'

I had a mysterious error in a project in Go:

myproject/types.go:89: fmt.Println not used

If you declare a variable or import a package in Go, that’s a compiler error. Good thing too, in my opinion. But this one was puzzling. It wasn’t complaining about an imported package, it was complaining about a function within a package. As far as I’m aware, the syntax of Go allows only for importing a whole package (or sub-package) at a time, rather than members of that package (as Python does).

The odd thing was that the error was reported on the last line of the file. The entire contents of that line was:

}

Read more →

Mapping Live River Conditions on the Thames

I love going out on my boat and I do it as often as I possibly can. Unfortunately the recent rain has meant that I’ve been unable to as often as I’d like. If the current is too fast, it’s not sensible or safe to do it. The Environment Agency has an excellent site which gives live information. But I wanted to put it on a map. Cue an evening of hunting down coordinates of every lock on the non-tidal thames (Google data is surprisingly bad) and writing an app to take data out of the online service and put it on a map.

Read more →

Trouble with local cross-domain Django cookies

I’m working on a Django app which is able to serve content on a number of subdomains. The app has a number of sites, which appear as subdomains of the main domain. There’s some middleware to look things up from the request and do the right routing.

In the wild the subdomains will be done with DNS, but for local development, I’m creating entries in my /etc/hosts such as demosite.local, using .local as my ‘main domain’ locally.  After a colleague integrated some authentication code, I suddenly found I couldn’t log in on my development environment. It didn’t work with either the custom login screen or the Django admin. Very odd.

Read more →

Using Subversion with PIP: Cannot find command 'svn'

Came across this when deploying a Django app to a fresh VM, installing with Python PIP from a requirements file.

Read more →

Facebook JavaScript login doesn't work in Safari

I have been banging my proverbial head against a brick wall (or my actual head against a proverbial wall) for the best part of a few days, on and off, trying to find the cause of an inconsistency in behaviour between Safari and Chrome in a Facebook canvas app.

Read more →

GET parameters in Facebook Canvas applications

I’m developing a Facebook app at work and was stuck on an issue for a bit. This post is just a mental note, and to prevent this happening.

Read more →

Almost identifying the music in a BBC trailer

The BBC love their esoteric, obscure electronic music. I think it all started with Sigur Rós in Planet Earth and proliferated from there. It’s even started creeping into BBC Radio 4 trailers now. The trailer for Will Self’s ‘A Point of View: In Defence of Obscure Words’ had just such a music bed. I decided that I would very much like to know what that music was.

Read more →

Crazy high CPU usage on Snow Leopard and a surprising culprit

After coming back from a team-building trip, I started to notice things were going a bit slow on my work laptop. I took it with me for casual emailing and working on the train, but spent about 4 days not really using it and certainly not ‘working’ on it. It came out once to display the lyrics to a song about Pithivier, and once to check emails, but that was about it.

Read more →

WordPress on Apache being Reverse Proxied by Nginx in an Endless Loop

I have a couple of WordPress installations running on Apache (on a non-80) port, and I’m reverse proxying them through nginx. Somewhere along the line WordPress is getting its knickers in a twist about the port not being the same as it expects. This results in WordPress going into an infinite redirect loop. To solve this, I put this in the nginx virtual server config: proxy_set_header Host $host; Fixed.

Read more →

In Which we Discover Some Rules About Python Scoping (which we already knew)

I’ve just been bitten by scoping in Python. If you gave me this code and asked me what it did, I’d probably guess that it was a trick question and look carefully at it. What would you say? def demo(): number = 100 one = number / 100 numbers = [one, one+1, one+2] big_numbers = [number * 100 for number in numbers] bigger_numbers = [big_number * 100 for big_number in big_numbers] print number  

Read more →