Welcome ! This is the personal site / blog of Graham King. Most people come for the credit card generator, but I think the Categories (top right) are more interesting.

September 11, 2013

Quote: Look well to each step

Posted in Misc at 03:08 by graham

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

Still, the last sad memory hovers round, and sometimes drifts across like floating mist, cutting off sunshine and chilling the remembrance of happier times.

There have been joys too great to be described in words, and there have been griefs upon which I have not dared to dwell; and with these in mind I say: Climb if you will, but remember that courage and strength are nought without prudence, and that a momentary negligence may destroy the happiness of a lifetime.

Do nothing in haste; look well to each step; and from the beginning think what may be the end

Edward Whymper, Scrambles Amongst the Alps

One of my favorite quotes.

September 2, 2013

What if everyone worked remotely?

Posted in Behaviour at 16:49 by graham

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

Many companies such as Lincoln Loop, Mozilla, Automattic, and MySQL AB are already distributed organizations. Central to that philosophy is that only what you do matters, not where or when. Obviously some work, like fishing and truck driving, can’t be done remotely, but in modern economies, a large number of people spend the bulk of their day sitting at a desk. What if they all felt free to work remotely? It’s a fun though experiment, so here goes – what changes might we see?

Less commuting. Commuting, for most people, is a reliable and persistent source of unhappiness (because it reduces the control you have over your own life). Less commuting also means less car miles driven, which means less death on the road. Less commuting means less pollution and lower demand for oil, with attendant geo-political consequences.

More community. Instead of just sleeping in our homes, we now live there, and become part of the community, indeed we create that community. You can pick up your kids from school at 4pm. You can attend the town hall meeting. You’re supporting the businesses near you. You actually meet and talk to your neighbours. You move somewhere where you like your neighbours :-)

Read the rest of this entry »

July 30, 2013

How GPG works: Encrypt

Posted in Software at 22:02 by graham

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

  1. Generate session key

    When you encrypt a file to someone (-r person on the command line), GPG generates a session key, which is a large random number. You can see it when you decrypt a message:

    gpg --show-session-key myfile.gpg
    
  2. Choose a symmetric cipher

    GPG then looks at the recipients public key to find their preferred symmetric cipher. If you have my key on your ring (get it by doing gpg --recv-keys 0x127CFCD9B3B929D2) you can see my preferred symmetric cipher by typing:

    gpg -r graham -e --verbose test.txt
    

    It should be AES256.

  3. Encrypt using chosen cipher and generated session key

    Next it compresses then encrypts the file using the session key and the preferred cipher. So until now we’re still all symmetric encryption.

  4. Encrypt session key with public key

    Finally it encrypts that session key using the recipients public key (using RSA), and prepends the result to the front of the message. If there are several recipients, this step is repeated once for each person.

The passphrase GPG asks for when decrypting or signing a message, has nothing to do with message encryption. It is only used to symmetric encrypt your private key (default is CAST5 cipher). That’s in case someone steals your private key file. In terms of how GPG works, you can ignore the passphrase. If you just encrypt a message (without signing it) you won’t need to enter your passphrase at all (but in practice your should always sign your messages).

July 21, 2013

Online upgrades in Go

Posted in Software at 05:40 by graham

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

When your server holds long running connections (WebSocket, long-running HTTP, IRC, XMPP, etc) you often want to be able to upgrade the server without dropping the connections (zero downtime upgrade). In UNIX there are at least two ways to do this:

  1. Inherit the file descriptor
  2. Send the file descriptor over a domain socket

The first one is straightforward, because a UNIX process automatically inherits the file descriptors of it’s parent, except if they have the close-on-exec flag set. Go complicates things a bit by always setting that flag on it’s sockets (in net/sock_cloexec.go). For a child process to inherit it’s parent’s file descriptors, you have to manually add them to ExtraFiles in os/exec/Cmd. There’s an example in TestExtraFiles in os/exec/exec_test.go.

Usually you need to send more that just the connections to the child process. There will be some state, and probably a communication where the child tells the parents it’s ready to take over (after priming it’s cache, for example). Hence the second approach, unix domain sockets, is more interesting.

Read the rest of this entry »

June 14, 2013

Quote of the day: Bruce Schneier

Posted in Society at 04:02 by graham

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

He’s talking about lessons from the Clipper Chip (bet you’d forgotten that one!), but he could just as easily be talking about current events.

May 27, 2013

Co-located teams are a business risk

Posted in Behaviour at 23:53 by graham

Early in my career, I worked for a company run by two ex-military officers. When they attended a distant meeting, they would take separate flights, because surely the company would not survive if they were both hurt in a crash. They never got injured in a plane, but they did get sick at the same time (the company survived). Shared offices turned out more dangerous than shared aeroplanes.

There’s a risk to placing your most valuable people within sneezing distance of each other.

You probably know and talk of your team’s “bus number”, but sickness strikes far more often than buses. We’ve all seen co-located teams drop one by one, and you’ve probably wished a sick colleague had stayed home rather than share his germs with you.

The biggest risk to humanity in the next 50 years is an influenza outbreak, according to Vaclav Smil in Global Catastrophes and Trends: The Next Fifty Years. Influenza doesn’t spread through IRC.

If we’re to build resilient companies, we need to think about what actually takes us away from our work, and structure our environment to mitigate that.

How many people can you afford to lose to sickness? For how long?

May 2, 2013

We are all polyglots

Posted in Software at 17:24 by graham

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. My initial serious language was C, my scripting language was Perl. The serious language was for client work, it paid the bills. The scripting language was for tools and toys (which is why many early web-apps were Perl CGI scripts).

We’ve been replacing C as our serious language since the 70s. C++ mostly succeeded, and became the official language of Microsoft Windows. Objective-C got a solid niche when Apple chose it for OSX, and later iOS. Java, became the serious language of web apps, and is now the language of Android. The two recent exciting developments here are Go and Rust.

In scripting-language world, Perl was largely replaced by Python and Ruby, and for web-app work by PHP.

So by now my serious language was Java, and my scripting language Python. But then three interesting things happened.

Read the rest of this entry »

April 26, 2013

Rust: What I learnt so far

Posted in Software at 22:58 by graham

This applies to 0.7pre, many things have changed in 0.8. Particularly core was renamed to std, and std renamed to extra.

Rust is an open-source programming language being developed mostly by Mozilla. It’s goal is the type of applications currently written in C++ (such as Firefox). Details at the Rust Wikipedia page.

I’ve been learning bits of it the past few days, and whilst Rust is still rough around the edges there’s a lot to enjoy. Rust is only at v0.7pre and changing daily, so you may have to adjust some of the code here.

Rust is a big language, and unless you come from C++ it will probably make your head hurt. In a good way :-)

The two most helpful introductions I have found so far are:

I’d encourage you to run through both of those, starting with Rust for Rubyists. When you get stuck reading one of them (and you will), switch back here.

Contents:

Install

At time of writing Rust is v0.7pre:

Read the rest of this entry »

March 26, 2013

PyCon 2013: My two favorite talks

Posted in Software at 16:41 by graham

PyCon is an annual gathering of Python programmers. All the talks are recorded and distributed freely on the web. My two favorite talks were:

March 5, 2013

Chapter books for a three / four year old

Posted in Misc at 23:32 by graham

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

Read the rest of this entry »

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »