I’m a big fan of Quora. One of the questions I came across recently concerned how files get copied from one place to another. I wrote an answer that tried to show empirically how files get copied. I thought it would make for a nice blog post, so I’ve cleaned up the original answer and extended the parts that I waffled over to be much more concrete and correct.

Prerequisite knowledge: If you’re not sure what a system call is, this post might confuse you.

Read on →

I started playing World of Warcraft (WoW) way back in 2005, shortly after it was released in February of that year. I would have been 14 at the time. I stopped playing some time in 2007, I don’t remember exactly when. During those two years my real life was put on hold while I created an entirely new life.

Read on →

Today I’ll be interrupting the usual programming to write a little something about phobias, specifically targeted at people that don’t have any. It’s probably going to come across a little killjoy and lecture-y but stick with me, it’s an important topic worth understanding.

Read on →

It’s quite easy to get scared by large systems of things that seem like magic. The Internet is pretty remarkable. It’s probably among the largest and most complicated systems ever designed by human beings. All those hundreds of web pages we view each month arrive at our computers unscathed a large percentage of the time. Some of them will have crossed the Pacific! That small percentage of the time we have a page “hang” while loading is often resolved by simply hitting the refresh button. Ace, right?

But how do those pages actually get to us? In this post (and maybe more, I might split them out, we’ll see how it goes) I want to show how these things work with practical examples and real commands that you can run to inspect what’s going on.

Prerequisite knowledge: Basic Ruby should do it. If you’ve built a simple web application with Sinatra or Rails or something similar, you should be able to follow along without much issue.

NOTE: I’m a Mac user. Some of the examples may be Mac specific. I will try, where possible, to give equivalent commands you can run on a Linux machine but I may miss something out. If you spot something that doesn’t work on your platform, get in touch. Windows users: I’m sorry.

Read on →

Over the last few weeks I’ve been grappling with a bug that just wouldn’t leave me alone. In the end, it took almost a week of pouring over TCP dumps and RFCs to figure out what was going on and, if I’m honest, the solution is a best-guess because I can’t figure out how to prove the theory.

It was a fun one, though, so I felt like writing it up :)

Read on →

A while ago, I found a pair of really useful GDB functions for debugging live Ruby processes on ThoughtBot’s blog:

ThoughtBot .gdbinit
define redirect_stdout
  call rb_eval_string("$_old_stdout, $stdout = $stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); $stdout.sync = true")

define ruby_eval

These proved really handy but they have a couple of problems relating to garbage collection and Macs, so I made a few modifications.

NOTE: If you don’t care about the explanation, scroll to the bottom of the post for the modified script.

Read on →

Many times I’ve been asked: “Why are you working on that? Is it for work?” referring to my tinkerings with kernel internals. “No, it’s not for work,” I reply, “I’m just interested in it.”

Other times this goes a bit further: “That looks horrible. Why would anyone want to work in C and assembler? No-one needs to understand that any more.” I’ll reply that I think it’s important to understand that which you rely on.

Then I’ll be told: “You don’t need to understand the internal combustion engine to drive a car.” They’re right, of course, but there is still value in understanding how an internal combustion engine works.

Then maybe someone will be telling me about the wonderful abstraction provided by the Node.js event loop, or the concurrency benefits of using a functional language. These things scare me, because I know that they eventually have to play ball with the real and terrifying world of the kernel and the processor, and only a fraction of a percentage of programmers have any interest in how either of those things run their code.

Read on →