Graham King: Recent Episodes

None

Recent content on Graham King

View Details

An overconfident genius personal assistant in my pocket

View Details

Don’t dismiss the statistically probable

View Details

How does Rust allocate a zeroed Vec and what does it cost?

View Details

A Rust object that survives program restart thanks to Rust allocators, systemd’s file descriptor store, and syscall memfd_create.

View Details

On Linux what can you turn into a file descriptor and then monitor with epoll?

View Details

How does Rust return values, and does it make any difference to us programmers?

View Details

When is the linear scan Two Sum solution faster than a map? What if we use AVX-512 instructions?

View Details

In Rust, what is the performance cost of using sync::Once after the initial setup?

View Details

In Rust, how does using a different primitive type (u8, i32, u64, etc) change the generated assembly?

View Details

Assembly: In all the world of the programmer, there is no more important output.

View Details

Can we make a Rust program that’s as small as it’s assembler equivalent?

View Details

Thanks to Address Space Layout Randomization you can use the address of a stack variable as a zero-cost random number.

View Details

Rust avoids memory copies by optimizing return value placement.

View Details

On x86 it doesn’t really matter what sync::atomic::Ordering you choose.

View Details

Safety is boring, let’s do pointer arithmetic.

View Details

Linux’s epoll API solved the C10K problem, enabling fast and afforable Internet services.

View Details

Minecraft has an API. If you run your own server you can program it from Python.

View Details

Is your Rust program CPU bound? Here are the very first things you can do on Linux.

View Details

An adventure in CPU out-of-order instruction execution.

View Details

Rust’s traits are a single concept that unifies interfaces, abstract classes, mix-ins, operator overloading, contraints on generics, and more.

View Details

Just a normal day reversing linked lists on the whiteboard.

View Details

It will take longer to learn than most languages, the standard library is small so you’ll need dependencies, and a lot of behavior is in traits.

View Details

… because, at every new incident, your fortitude was to be called forth, and your courage exhibited; because danger and death surrounded it, and these you were to brave and overcome. For this was it a glorious, for this was it an honourable undertaking.

View Details

In Go, what’s the simplest possible way to put all your ad-hoc tools in one place?

View Details

In Go, how do you run several operations that might return an error, and return those errors at the end? Here’s how I do it.

View Details

Two days at PDX DevOpsDays, a gathering of system administrators who use version control, and write a lot of YAML.

View Details

Javascript can now record, manipulate and play sound thanks to a whole range of audio-related API’s. One of the simpler and more useful parts of that is MediaRecorder which can record sound, typically from the user’s microphone.

``` const stream = await navigator.mediaDevices .getUserMedia({audio: true, video: false}); // Media Capture and Streams API const mediaRecorder = new MediaRecorder(stream); // MediaStream Recording API mediaRecorder.ondataavailable = (ev) => { // ev is a BlobEvent // ev.data is a Blob. Send it to the server. }; mediaRecorder.start(50); // call ondataavailable every 50ms

```

MediaRecorder on Chrome produces output with mime type audio/webm;codecs=opus.

Let me guide you through the WebM / Matroska / EBML maze.

The WebM format is a container, which can contain many things. In our case it contains audio encoded with the Opus codec. We are only going to look at the container, not the encoded audio.

View Details

This is a very common pattern in Javascript:

View Details

Gardening is my preferred metaphor for software. When I grow a new piece of software, there is a very predictable path I go through as I attempt to manage it’s complexity. It is, in fast-forward, the history of programming language design. That process is short enough to capture in about 400 characters, as two tweets.

Growing software, in two tweets:
1. Write main. Put your program in there.
2. main too big? Extract functions. Use global vars.
3. Too many functions? Group functions and their data (replacing global vars) into objects.

— grahamking (@grahamking) March 12, 2018

  1. Too many objects? Group objects into packages. Make some methods private.
  2. Too many packages? Split out a new project, either library or network service.
  3. Iterate from 2 when other functions grow too big.

— grahamking (@grahamking) March 12, 2018

View Details

What Made Maddy Run by Kate Fagan, is a book about the importance of doing what you love, of really listening to the people close to you.

View Details

Learn Better, by Ulrich Bosner is an interesting, valuable book, that is too long.

View Details

To start a server on a port below 1024 (i.

View Details

Three years ago when I wrote The Joy of Upstart, that was the easiest way to turn your scripts into daemons.

View Details

Over 170 years ago, on Friday 21st July 1843, at 4 o’clock, Ada Lovelace was working on a mathematics problem, possibly on the first known computer program (it was written that summer).

View Details

tl;dr: It looks like Facebook is getting the textbook results of ignoring code quality.

Update: More examples, and insights from ex-employees in the reddit discussion

Facebook has a software quality problem. I’m going to try to convince you with three examples. This is important because it demonstrates the time-honored principle that quality matters. In demonstrates it, as Facebook engineers like to say, at scale. I don’t work at Facebook or any competitor, I’m just an observer.

Exhibit A: “iOS can’t handle our scale” About a month ago a Facebook engineer gave this presentation: iOS at Facebook, which was followed by a discussion on reddit.

The Facebook iOS app has over 18,000 Objective-C classes, and in a single week 429 people contributing to it. That’s 429 people working, in some way, on the Facebook iOS app. Rather than take the obvious lesson that there are too many people working on this application, the presentation goes on to blame everything from git to Xcode for those 18,000 classes.

View Details

tl;dr Use the mitmproxy doc, return here if trouble.

View Details

I attended OSCON for the first time this year in Portland.

View Details

GopherCon was in Denver again this year, and a lot of fun it was, mostly the meeting of wonderful people.

View Details

When the President of the United States of America wants to send an email, we don’t close email-space, and delay your email so his very important one can go through.

View Details

In part 1 we called a very simple Go shared library from Python.

View Details

Since 1.

View Details

tl;dr man 2 brk

View Details

tl;dr Use a map.

View Details

A selection of software engineering practices, from notes I took at an XTC meetup many years ago.

View Details

In the interests of illustrating the complicated programmer psyche for the benefit of anyone involved in recruitment, here’s the two things I look at in a job advert:

View Details

Go’s empty interface{} is the interface that everything implements.

View Details

It was a gesture meant to comfort.

View Details

The software industry is the most fashion-conscious industry I know of.

View Details

Continuing our dive into the Internet Protocol Suite from Go (See part 1 Raw sockets in Go: IP layer), we are going to the link layer, so we can see the IP headers.

View Details

Continuous Delivery, by Jez Humble and David Farley is about three big ideas to get your code into production more reliably: Make a deployment pipeline: commit -> unit test -> acceptance test -> … -> deploy -> release Automate everything.

View Details

We need to design software to run in production.

View Details

My credit card generator was recently on the front page of reddit.

View Details

For entertainment, I’m learning assembler on Linux.

View Details

Go has good support for examining and modifying Go source code.

View Details

Ever since Dropbox, I’ve been searching for a self-hosted, secure (and now Condi-free) way of keeping my machines synchronised and backed up.

View Details

My favorite talks at GopherCon 2014:

  • Peter Bourgon: Best Practices for Production Environments Soundcloud were an early Go adopter, and this talk is their distilled learnings from two years of Go: Repo structure, config, logging, testing, deployment, and lots more. The one talk you need if you’re starting (or running) a significant Go project, and you want to do it right.
  • Petar Maymounkov: The Go Circuit: Towards Elastic Computation with No Failures Stick with this one. It starts off quite academic, but gets fascinating very fast. He models whole companies as a distributed system (based on CSP), then builds a language-agnostic cluster programming library where the API is a filesystem The Circuit. One of the highlights of the conference for me was building a filesystem with Petar in the hallway.
  • John Graham-Cumming: A Channel Compendium John is the author of those great in-depth Cloudflare blog posts. Solid talk about Go channels. nil channels always block, so you can ‘disable’ a select clause by setting a channel to nil. Closed channels never block. Heartbeat is just time.Tick, timeout is time.After. Go programs are small sequential pieces joined by channels.

Those are the three talks I enjoyed most. Here are my general notes on the conference and a few of the other talks.

View Details

In the Internet protocol suite we usually work at the transport layer, with TCP or UDP.

View Details

Here are my three favorite programming books, the ones I consider most important and would most recommend.

View Details

In Go (golang) what happens to memory when you append to a slice?

View Details

Here’s my current setup, and the hardware I got, in case you were curious.

View Details

Update Nov 2021: It’s been eight years, I’m typing this on that original keyboard, it’s still my primary keyboard.

View Details

Realtime Conf 2013 just finished in Portland.

View Details

Last weekend a friend asked me why there were pharma links hidden in her GoDaddy hosted WordPress site, and that led me into the WordPress black hat SEO rabbit hole.

View Details

From the epilogue of Jon Krakauer’s “Into the Wild”:

View Details

What would happen if everyone had the freedom to work remotely?

View Details

Here’s what happens when you encrypt a message with GPG / GnuPG (and probably other OpenPGP implementations):

View Details

tl;dr Send your socket fd over a UNIX domain socket: syscall/passfd_test.

View Details

The lesson here is that it is insufficient to protect ourselves with laws; we need to protect ourselves with mathematics

View Details

OpenPGP / GnuPG From keyserver: gpg --recv-keys B3B929D2

View Details

Early in my career, I worked for a company run by two ex-military officers.

View Details

I used to know two programming languages at any one time; what I called a serious language and a what I called a scripting language.

View Details

Update 2021: DO NOT USE THIS BLOG POST TO LEARN RUST The language has changed tremendously.

View Details

PyCon is an annual gathering of Python programmers.

View Details

Starting in summer 2012, when my son was 3.5, I started reading chapter books to him, a chapter or two a night. Before we started chapter books, it was always easy to find good books to read to them (from board books upwards). Now though, I struggled finding good chapter books for this age group.

I’ve collected a list of the ones we tried, in order, with notes if appropriate. I’m linking all the books to Amazon to be clear which book it was, but we got most from our local library.

Jason’s Quest – A lovely book to start with. A wonderful adventure, which never gets too frightening, or too hard to follow, and the good folks win in a good way.

Fantastic Mr. Fox – Might have been a little too frightening at the beginning, with the mean farmers trying to kill the fox. In retrospect I would have saved it till he was a few months older.

Mr. Popper’s Penguins

View Details

First thing in the morning, I check my gmail on my Google Nexus 7 tablet, or my Nexus 4 phone, whichever is nearest.

View Details

This is valid C nowadays:

View Details

How Will You Measure Your Life?

View Details

Our house has two iOS devices (an iPad and and iPod Touch), and two Android devices (Nexus 7 tablet, Samsung Galaxy phone).

View Details

In these months of American politicians trying to influence you, I thought it interesting to look at ways of using the same tools for positive change.

View Details

David Suzuki tells of making television science programs.

View Details

Tools like top show processes using two kinds of memory:

View Details

I blogged What is WebRTC over on Lincoln Loop’s blog:

View Details

John Cleese gives a great talk on creativity (embedded below).

View Details

Lives of Promise, by Karen Arnold, is a 14 year study of achievement and life choices.

View Details

Most people reading this will be lucky enough to live in a democratic society.

View Details

I blogged an introduction to and explanation of SPDY, the next-gen HTTP.

View Details

Excited to have my first post on Lincoln Loop’s blog, about intrinsic motivation, flow, and why you don’t find cats in offices:

View Details

Problem: You’re on a i386 machine, and you need to build for amd64, or vice-versa.

View Details

Unicode maps 32-bit (4 byte) integers, also called code points or runes, to characters.

View Details

I attended Vancouver’s Polyglot Unconference, met some wonderful people, and got to present a session on Go (#golang).

View Details

There’s an excellent interview of Ward Cunningham at InfoQ (Nov 2011).

View Details

Getting unit test code coverage in python, and in django, is easy thanks to coverage:

View Details

On paternity leave for my second child, I found myself writing an in-memory hashmap (a poor-man’s memcached), in Go, Python and C.

View Details

Update Nov 2021: I spent almost a decade doing Go full time and I still love it.

View Details

A year here and he still dreamed of cyberspace, hope fading nightly.

View Details

Someone once told me that interesting stories start like this:

View Details

Is my terminal connected to the console, or to a pipe?

View Details

My current project has a realtime part, using socket.io on nodejs, and a web part using django on nginx / gunicorn. Here’s a setup to put them both on the same port, and make them both go over SSL. I’m assuming you’re on Ubuntu.

Disclaimer: I got this working last night, so no promises. You’ll certainly want to tweak haproxy’s config for performance. I also only tested it with socket.io’s web socket transport.

Overview

  • stunnel decrypts the ssl, so everything after that doesn’t know about it. It decrypts both web traffic (HTTPS to HTTP), and web socket traffic (WSS to WS).
  • haproxy sends web socket traffic to node and web traffic to nginx.
  • node runs socket.io, handling the web socket traffic.
  • nginx serves static content.
  • gunicorn runs python / django, and there’s a database out back somewhere, but that’s not relevant here.

Currently nginx doesn’t

View Details

There are lots of easy ways to improve the output of your command line scripts, without going full curses, such as single-line output, using bold text and colors, and even measuring the screen width and height.

View Details

We’ve know for over 35 years that “adding manpower to a late software project makes it later”.

View Details

Reading Machiavelli’s The Prince, his advice seems just as relevant today.

View Details

Monitoring iPad network traffic, and blocking advert download.

View Details

After a frustrating time trying to find a memory leak in my Python code with guppy / heappy hpy, I tried objgraph and, wow, it makes it so easy!

View Details

I got to do a 5min lightning talk at DjangoCon 2011 in Portland.

View Details

I recently finished Gary Noesner’s Stalling for Time: My Life as an FBI Hostage Negotiator, by the F.

View Details

After a while working with git, you end up with lots of branches, especially if you use git-flow inspired feature branches.

View Details

For most Django apps, indeed most webapps, the bottleneck is the database. The biggest gains usually come from reducing the number of queries used, and adding database indexes. django-debug-toolbar helps a lot here. After that, caching and de-normalization also help reduce database queries.

But what if your app is CPU bound? How do you find out where it’s spending it’s time? It’s easy with the runprofileserver from django-extensions – here’s how:

View Details

In Python 2 you need to convert between encoded strings and unicode.

View Details

If you get an error like this from git::

View Details

The News International phone hacking scandal is the case of a British tabloid’s staff hacking into several thousand people’s voicemail, over a period of at least six years.

They listened to voicemail of the 7/7 terrorist attack victims, politicians, a murdered schoolgirl (including erasing some messages, leading the family to think she lived), the British Royal Family, various celebrities, and other journalists.

View Details

Instructions on how to setup a development environment to work on Django core, for example to review proposed patches, and prepare your own.

View Details

Ten days ago, I received a Kobo eReader Touch for father’s day. It’s a lovely device. Here’s my impressions.

It’s a USB device. 1. Plug it in to your Ubuntu machine (or probably any modern Linux distro). It shows up as a USB storage device. 2. Drag and drop books in any supported format onto it. 3. Unplug, switch on, read books.

It’s that simple. If you had a solid-state MP3 player (before your phone played them), this will feel familiar.

View Details

Since version 1.

View Details

In the past few months, I’ve inherited two projects which used django-mptt, a toolkit for adding trees to Django models.

View Details

If you are an active user of Ubuntu’s notifications, for example via lintswitch you may of noticed that they have two key problems, which are easily solved:

View Details

These days, for most internet businesses, the number one challenge is customer acquisition and marketing — not building a website.

View Details

Updated October 2013: Minor edits.

View Details

Jason Fried at a TEDx event, 17minute video

The key concepts:

Ask people where they go to “get work done”, where they are at their most productive: They almost never say ‘the office’. Or if they do, it’s before or after hours.

Work is like sleep, it proceeds in cycles. You have to go through the light-sleep / light-work cycles to get to the meaty stuff. Every time you get woken up / interrupted, you start from scratch.

View Details

lintswitch is a small Bash script that connects:

View Details

Update 2021 Prefer tmux.

View Details

Update I also presented a 5 minute version at DjangoCon US 2011, as a lightning talk.

View Details

It’s too bad that companies are still hiding behind glitzy buildings with on-site amenities, flexibility programs and knitting clubs when what people really want are their lives back.

View Details

Perform the following thought experiment.

View Details

This directory contains research papers and reports which I intend to read.

View Details

Materialism and the behaviors that go with it – desiring and buying brand-name clothes and luxury items – are symptoms of insecurity and a coping strategy used to alleviate feelings of self-doubt or bolster a poor self-image.

View Details

As part of my work with Good Energy I have been learning why people behave the way they do, and what tools we have to help them change behavior.

View Details

Kathy Sierra at the Business Of Software conference last autumn.

View Details

I have done most of my work while anxious about whether I could do the job, and unsure that it would be enough to achieve the goal if I did.

View Details

These are my notes from O’Reilly’s Website Optimization.

View Details

A quote by Martin Seligman, from his book Authentic Happiness.

View Details

Two observations found in the literature on social psychology, which explain succinctly why, whatever you personally think about it, you would be mentally much better off without your TV.

View Details

The Brain That Changes Itself, by Norman Doidge is a fascinating book about brain plasticity, the ability of our brain to re-wire itself to cope with changing conditions.

View Details

Update: You need to know how to ban MAC addresses on your router, as you will eventually have a neighbor swamp your network with bittorrent.

View Details

Monit tells you if something goes wrong on your server, and tries to fix it.

View Details

Munin is a system monitoring tool.

View Details

If your MySQL (5.

View Details

Will Vitamin C really prevent or cure your cold?

View Details

My short notes on Predictably Irrational, by Dan Ariely.

View Details

As an Amazon reviews says, “arguably the best book ever on what is increasingly becoming the science of persuasion.

View Details

By Thomas Gilovich, social psychologist and CSI Fellow, this well written book explains some of the reasoning and deduction errors we make when trying to understand the world, and ways to avoid making those errors.

View Details

In the general case, there is no way to list all the keys that a memcached instance is storing.

View Details

Funny, practical, and well worth 1 minute 50 seconds of your life:

View Details

I am sharing my thoughts, mainly about web technologies, on identi.

View Details

I recently received an advert for an investment fund in which, as the amateur social psychologist that I am, I noticed illustrated a couple of psychological principles.

View Details

Updated Sep 13, 2011 to include redis, remove stompserver, and update beanstalkd

View Details

In response to monkeys stealing his coffee beans, an Indian farmer observes: If you start shooting monkeys, you’ll spend the rest of your life shooting monkeys.

View Details

A very interesting article in the New-York Times on the research behind the risks of being distracted by a cellphone whilst driving:

http://www.nytimes.com/2009/07/19/technology/19distracted.html

Here’s some excerpts:

in a survey of 1,506 people last year by Nationwide Mutual Insurance, 81 percent of cellphone owners acknowledged that they talk on phones while driving, and 98 percent considered themselves safe drivers. But 45 percent said they had been hit or nearly hit by a driver talking on a phone. That’s the Lake Wobegon effect, the tendency for overestimate their capabilities in relation to others.

View Details

A couple of great posts which explain Django dynamic forms and advanced formset usage very clearly:

View Details

I will be giving this talk on Friday 12th June, at Open Web Vancouver 2009.

View Details

I setup my Mercurial repository in the same way we used to do CVS, then SVN: A directory owned by a group, with the GUID bit, and all users who need to commit are in that group.

View Details

The cooking instructions for my Tandoori Chicken Breast microwave lunch, are to cook…

View Details

I have been playing Open Transport Tycoon Deluxe, or OpenTTD on and off for a while, but I confess I only understood train signals very recently.

View Details

Charlie Brooker on a television advert by the British National Party, England’s (very small) right-wing political party:

View Details

I will be speaking at Open Web Vancouver on Thursday, June 11, 2009 and Friday, June 12, 2009.

View Details

When I was 16, I wrote a computer game, called Micro Zooides.

View Details

After a desktop and server upgrade, my subversion client stopped working.

View Details

Update April 2012 Google has discontinued Picasa for Linux, so I’m going to try to do all my photo editing in GIMP. Here’s what I use most often:

Basic:

  • Colors / Auto / White-balance
  • Colors / Auto / Color enhance
  • Colors / Brightness-Contrast / Contrast up by 5 or 10

Warmify:

  • Tools / GEGL Operation / Color temperature / Raise desired by 0.5k or 1k.

Sharpen:

  • Filters / Enhance / Unsharp mask

Original post follows


I’ve been using Picasa to edit my pictures for a long time, and it’s an excellent program. Recently however I’ve started shooting RAW, and I’d like control, so I’ve started using GIMP. It’s more powerful and more complicated than Picasa, so to start myself off I went through all the features of Picasa and made notes on how to duplicate that operation in GIMP. Here are those notes.

Most of what Picasa does can be replicated with the Colors / Levels or Colors / Curves tool. It’s well worth spending a little time experimenting with both of those (the documentation is very good too).

Crop In the Toolbox, click the Rectangle select tool In its options (beneath the tools), tick ‘Fixed: Aspect Ratio’ Enter 6:4 ratio (for 1.6 sensor, most DSLRs) Tick Highlight. Draw a rectangle on the image that you want to crop to. Image menu / Crop to Selection

View Details

Update 23 Aug 2011: Finally closed my LinkedIn account. To their credit the ‘Close Account’ feature is straightforward.

Update 4 Feb 2011: Steve Pavlina, in his article about leaving Facebook writes:

I nuked my Linkedin account at the same time I left Facebook. Linkedin is supposed to be a business networking service, and I had about 350 contacts there, but I always found that service utterly useless, so it was a no-brainer to dump it. End update

I’m on LinkedIn, I’m connected to 48 people. I go there, I declare to the world that I know these people. And then what?

If that sounds familiar, you’re not alone. There’s:

  • a project to find uses for LinkedIn
  • a book on finding a point to LinkedIn
  • and the company itself had to blog about ten ways to use LinkedIn.

If it takes a blog post, a book, and a community project, to find a point to your web application, I think there may not be one.

View Details

Update (Nov 2010): I have not worked on Foxden for over a year.

View Details

Congressman Mike Honda, D-San Jose, writing about opening government databases:

View Details

Eddit is a bookmarklet for Reddit, which gives you more signal and less of the noise that makes you go Rrrr! Here’s how it improves reddit:

View Details

Most ActionScript / Flash applications have a main event loop, triggered by Event.ENTER_FRAME. This is where the animation moves along to the next frame, or the sprites of the game are re-drawn in their new places.

In the Flex framework, you are expected to call invalidateDisplayList on the framework to say you need an update, and actually do the update when the framework calls your updateDisplayList method. This is the invalidation / validation pattern.

I went searching in the Flex code to understand how this invalidation / validation step ties in with Flash’s event model. I ignored properties and sizing, and edited the code down to the bare essentials.

Here is what happens when you change the label of a button:

View Details

UPDATE March 19th: Added First Steps in Flex, and Learning Flex 3.

View Details

Los Angeles is under attack, by trigonometric functions! OMG! Trigo-what? If I wanted to do maths, I’d go to San Francisco!! You, like, totally gotta save L.A man. Enter your name, then move your tank.

Use the left and right arrow keys to rotate, the forward and back arrow keys to move.

The barrel of the tank is the little black line. That’s the front.

No, your tank can’t fire. Avoid the mathematical blobs. YEAH!

The longer you live, the more points you get. A score above 100 is, like, totally AWESOME! Good luck Bro.

Let me know in the comments how much you score.

View Details

When writing object-oriented Javascript, there are two occasions when you need to be careful that this is set correctly: In inner functions and in callbacks.

View Details

Javascript is not an opinionated language.

View Details

Have I told you that I have never owned a TV, and never watch it?

View Details

Offered with no further comment: Hackers successfully install Linux on a potato

View Details

Joshua-Michéle Ross at O’Reilly Radar writes about the money the American taxpayer (government) is giving Genera Motors, Chrysler and Ford to save them from bankruptcy:

View Details

In the prologue to The Science of Fear, by Daniel Gardner (published as ‘Risk: The Science and Politics of Fear’ in the United Kingdom, Australia and Canada), which I have just started reading, as he talks about the aftermath of the 9/11 terrorist attacks in the United States:

View Details

I have just launched Plebis.

View Details

At work we setup a Twiki, and Internet Explorer refused to send the NTLM authentication, instead it showed a login popup.

View Details

Keithnote is a presentation generator. You provide information such as the title of your presentation, and it downloads relevant images from Flickr. These are stored locally so you can run your presentation whilst offline.

Keithnote is hosted at Google Code, here: Keithnote

View Details

A concise reference / cheat-sheet / crib-sheet to MySQL’s commands.

View Details

For many months now I have been making and receiving telephone calls from my computer. There are two advantages:

  • It is very cheap. Calls within the United States are about $1/hour!
  • It makes your phone number virtual, and configurable, which means for example that my phone number will forward to my cell phone if my computer is offline. It also means you don’t have to be in the same country as your phone number.

I am running Ubuntu Linux on a Thinkpad, but most of this should apply to Ekiga on all platforms, and the principles apply to all Softphones.

View Details

Update: Five years after I wrote this, it is actually happening. Samoa Air boss defends charging passengers by weight on BBC News 2nd Apr 2013.

Update: Eight years after I wrote this, The Economist remarks In fact, on a purely economic basis, it makes sense to charge passengers by weight, since that is directly correlated with fuel usage, which goes a long way in determining flight costs in article 21st Oct 2016


When you send a parcel by air, the price depends on the volume and weight of that parcel. Volume, because you are buying a certain amount of space in the plane. Weight, because the heavier the plane’s cargo, the more fuel it takes to get it off the ground. You pay for the fuel to fly your parcel.

The pricing structure for air mail / air freight is closely linked to the costs faced by the airline.

When you travel with your parcels, a disconnect appears. You buy a certain amount of space – typically a seat for yourself, a small bag and one or two big bags. A bigger seat (‘business’, ‘premium’, etc) is more money. Extra bags is more money. But you’re not paying by weight – and I think that will have to change.

View Details

It’s hard for me to see why you’d bother having someone come all the way to an office just to sit in a cube and type.

View Details

When I first got my own server (a virtual private server with Linode which I highly recommend), I ran every Internet service I needed on it, and several for my friends.

View Details

If you really don’t want to watch it, read the transcript of Clay Shirky’s talk at Web2.

View Details

If you use Django with Apache, no doubt you have noticed lots of these lines in your log file:

View Details

As you probably know, the U.S.A. is electing itself a new president. The process is that each of the two parties elects their candidate, then they compete against each other. The four remaining Republicans vying for their parties nomination recently participated in a debate here in California. Here is the transcript of the Republican debate of January 30th 2008. It’s mostly standard political fare, until you get to the topic of immigration. Then, well, see for yourself:

View Details

Gamay, pinot noir, sangiovese, tempranillo, zinfandel, syrah, merlot, cabernet sauvignon, nebbiolo.

View Details

Debugging is twice as hard as writing the code in the first place.

View Details

I have just spent a while wrestling with this problem, so in case anyone else comes across it.

View Details

The difference between a web site and an application is that an application is more dynamic, more responsive, to the user.

View Details

I have recently moved all my photos from a Gallery 2 instance I ran myself, to Flickr. This means I don’t need to keep my Gallery2 install up to date, it frees up lots of disk space on my server, and allows me to more easily share pictures with friends and family. Here’s how I did it:

View Details

Oscar Huseyin, via JavaLobby, has an interesting post on how much unit testing is good:

Over the years, l’ve read lots of commentary, white papers, best practice papers, books on the topic of TDD. I’ve heard the rant of many TDD evangelists who preach about how total code coverage brings you closer to code quality perfection and how you’ve failed when you’ve not been able to achieve these goals. Sure, this is an extreme example of evangelical preaching, where in actual fact, most of these individuals commonly drum down their hard line views of testing by using words like “pragmatism” and statements like “do what works best”. But, why do l feel as if I’ve failed if l have not got 100% code coverage? It’s because l, to some degree, shared some of the religious views about testing.

View Details

Update Sep 2011: If you’re using Google’s Go Lang see Non blocking console read in Go. Thanks Ostsol


Heavily updated 9th January 2008: This post was originally entitled Non blocking console IO is not possible. Two helpful comments helped me see the error of my ways. Many thanks to ‘schlenk’ and ‘Bob’ for the help. Non blocking console IO is possible, it just isn’t (easily) portable. Read on to find out how.


I have been doing some programming exercises in Python, Java and ActionScript (Flex), using this list from Prashant N Mhatre. The first exercise sounds simple on the surface:

Display series of numbers (1,2,3,4, 5….etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key)

Displaying a list of numbers in an infinite loop is trivial, and stopping on Ctrl-C is trivial, but stopping on a key of your choice (let’s use ESC), makes the problem much more interesting.

By default the console on Linux and Windows is buffered. It does not send you character data until the Enter key is pressed. In Python the raw_input method will block until it gets input. In Java you can test the characters available, non blocking, using System.in.available(), but this still doesn’t fill up until Enter is pressed. There are two ways to solve this:

View Details

An entry about using the XIFF API to get your Flex application talking XMPP. If you don’t know what I’m talking about no need to read on really.

Some definitions * XMPP is an open protocol for instant messaging, that runs the Jabber network and Google talk. * Flex 2 is a programmer-friendly way of developing Flash applications, using ActionScript 3, which looks a lot like Java. * XIFF is an ActionScript 3 API for XMPP.

If you put those three items together you get, yes, a paradigm shift in web based application development. But let’s not get fancy just yet (a later blog post might wax lyrical about the future of web apps), for now here are some recipes for doing just about anything with XMPP, ActionScript 3, and XIFF.

View Details

There’s no shortage of smart people digging the wrong hole really well

View Details

The silence around here is because I have been traveling for two months.

View Details

Update 2018: The excellent Our World In Data has a Causes Of Death section.

Do you remember how we were all going to die of Ebola, then S.A.R.S., and more recently Avian flu ?

Have you got the memo that the job creation program at airports is because Terrorism is such a big threat to your life ? In England at the moment you are, according to the media, at great threat from drug dealing teenagers, and anyone younger than you in general.

And yet, here you are, reading safely. So instead of tolerating idiots pretending to be journalists, I went looking for what we should really be wary of – what really does kill people.

View Details

Last weekend I attended BarCampLondon2.

View Details

Webapps are often built and managed by single person or small teams. For example, I run 11 sites and web apps, just in my spare time, on one virtual server. I need to know if that server is up. We need a lightweight, low/zero maintenance way to monitor applications and servers. Mainly we are concerned about presence of our application. Is it there ?

Where else does presence matter ? Why, in Instant Messaging applications of course. Currently we record presence of our friends in our messenger clients. Well, servers can be our friends too !

View Details

From the 9th to the 15th May 2004, I went on the Fundamental Bushcraft course with the Ray Mears School of Bushcraft, in the Kent countryside. Here’s what happened:

View Details

Most journalists, I assume, aspire to delivering the truth on what is really going on to the reading public.

View Details

Recently I had to automate printing a whole bunch of CVs on Windows. Having successfully avoided VBA my whole programming life, it was time to think fast. Thankfully Python has some win32com bindings, which allows you to talk COM to various Windows applications, and get them to print the documents.

First you need the Python win32com bindings.

View Details

The reason new world wines use the grapes they do, is because those are the grapes from the big French wines. But which grapes from which wines ? To find out, you could go to the Institut National des Appellations d’Origine and read the text of each appelation. There are over 300. Or there’s the Wikipedia list of French wine Appelations. Or there’s the handy guide below on which grapes are in which French wines. Happy sipping !

View Details

Some notes from a talk / taster I went to on food and wine pairing. It was led by Tom Forrest – and a very interesting and knowledgeable chap he is.

View Details

Art at work This is the webgroup’s first online gallery show.

View Details

carriagereturn.org provides a daily dose of software engineering wisdom to your feed reader or e-mail client – it’s inspiring, thought provoking, and sometimes just plain dangerous.

View Details

I got the strangest email today, which I originally took to be spam. Read for yourself:

May 9, 2006 FOR IMMEDIATE RELEASE

Contact: mailto:EPDU@halliburtoncontracts.com Photos: http://www.halliburtoncontracts.com/EPDU/

HALLIBURTON SOLVES GLOBAL WARMING SurvivaBalls save managers from abrupt climate change

View Details

I use Markdown to edit this blog.

View Details

A web feed is, to quote Wikipedia:

… a document (often XML-based) which contains content items, often summaries of stories or weblog posts with web links to longer versions. Weblogs and news websites are common sources for web feeds, but feeds are also used to deliver structured information ranging from weather data to “top ten” lists of hit tunes. The two main web feed formats are RSS (which is older and far more widely used) and Atom (a newer format that has just completed the IETF standardization process.) Feeds are subscribed to directly by users with aggregators or feed readers, which combine the contents of multiple web feeds for display on a single screen or series of screens

Aggregators and feed readers are widely used, but mainly by tech-savvy individuals. It’s time your company rolled out a feed reader on every desktop PC it owns. Here’s why:

View Details

UPDATE As of February 2008 mytimestream.

View Details

A very interesting article about Amazon censoring a negative review.

View Details

I have been using Sage as my feed reader.

View Details

I’ve started using Sage as my feed reader.

View Details

Shaun Inman is the creator of Mint.

View Details

This is a write-up of my notes from Tom Coates’ presentation at the Future Of Web Apps (futureofwebapps) conference, held in London on Wednesday 8th February.

View Details

There was a mistake in the Javascript credit card generator, meaning it would not work on MS Internet Explorer or Opera.

View Details

From a Greenpeace workshop

View Details

These are the notes I took during Cal Henderson’s talk on Building Flickr at the Future of Web Applications conference in London on Wednesday 8th February.

View Details

These are the notes I took at Joshua Schachter’s talk at the Future Of Web Applications (futureofwebapps) conference, in London on Wednesday 8th February 2006.

View Details

If your live web application has more than a couple of users, and they don’t both sit right next to you, you need to cluster it.

View Details

I’ve been using Apache as a front end to a cluster of Tomcat servers for a while.

View Details

I have ported the credit card number generator to PHP and Javascript.

View Details

I went on a basic fire fighting course a long time ago.

View Details

This is sourced from Naval Strike and Air Warfare Center; ?

View Details

I’ve written a small Python program I’m calling jUse which I’m placing here in the hope that someone might find it useful.

View Details

From New Scientist, 29th October 2005:

View Details

As you can probably tell from some of the comments in the credit card section, some people don’t seem to understand that the generator just makes numbers that look like credit cards, but are IN NO WAY actual credit card numbers.

View Details

JavaWorld have published my third article.

View Details

by Jeff Elkins Interesting details are emerging regarding a wartime tiff between General Wesley Clark, former NATO Supreme Allied Commander and General Sir Michael Jackson of Britain, former commander of NATO “peacekeeping” forces in Kosovo.

View Details

CVVs, CVV2s, CVCs, and Indent CVCs are 3-digit Card Verification Values or Card Verification Codes that are all calculated using the same CVV algorithm.

View Details

A credit card number must be from 13 to 16 digits long.

View Details

Political violence, terrorism, military operations other than war (MOOTW), low-intensity conflict, people’s war, revolutionary warfare, war of national liberation, guerrilla war, partisan war, warfare in the enemy’s rear, imperial policing or small wars.

View Details

The term sea power covers the control of international trade and commerce, the operation of navies in war, and the use of navies as instruments of diplomacy, deterrence, and political influence in peacetime.

View Details

A maritime blockade, strategic bombing or guerilla warfare are coercive techniques to achieve a particular objective.

View Details

Although there is no judiciary or policing capability at the international level (aside from the limited actions and powers of the United Nations), there is a still an influential body of international law, respected almost all the time by almost all nations.

View Details

Strategy is the art of distributing and applying military means to fulfill the ends of policy – Lidell Hart

View Details

Commodities Commodities are anything that you can take physical delivery of, such as sugar, coffee, wheat, etc.

View Details

A derivative is a financial contract that is based on (derived from) something else, either another financial instrument (a bond, shares, currency, etc) or a commodity (sugar, coffee, energy, etc).

View Details

A loose collection of definitions and information concerning the financial world.

View Details

User interface design principles This is the basics to think about when designing a GUI, a website, any software with a user interface.

View Details

This section presents a system for getting things done.

View Details

This section is inspired by Software for your Head, by Jim and Michele McCarthy.

View Details

The best advice I have every been given was to take the highest paying job you can get until you figure out what you want to do.

View Details

??The term ‘Christian’ was first used in Antioch in Syria around 35-40 AD to designate a new religious community there which included both Jewish and non-Jewish adherents and was marked out by it attachment to ‘Christos’, a Greek translation of the Hebrew title ‘Messiah’, used by Jews to designate their expected national savior.

View Details

An unexpected page, dedicated to the world’s strange collection of Michael Jacksons.

View Details

Credit card numbers that conform to the Luhn formula (MOD 10 check).

View Details

If you just need a bunch of numbers use the online credit card number generator.

View Details

In England in 1388 Richard III made a law stating that all men (or only ages 10-18, versions differ) must own bows and practice archery on Sunday’s and holidays.

View Details

People grow vegetables or fruit in their gardens, and may keep chickens or other animals.

View Details

In many countries, pedestrian crossings have a button you press to signal your desire to cross.

View Details

Fact 1: Cats always land on their feet.

View Details

Cats love affection, but particularly they love being rubbed on their cheek.

View Details

If you live in the city and work all day, you probably can’t have a dog.

View Details

Mum’s, over the course of being Mums, develop an extraordinary ability to manage a house, put up with squealing brats, multitask, remember a range of important unconnected information, and generally get things done under duress.

View Details

This site is maintained by Graham King.

View Details

Everyone that runs a website probably gets some amusing e-mails, and because of the credit card numbers I probably get more than my fair share.