Pulling back the veil

In Harry Potter, the veil is an arch with a tattered, black curtain that represents a barrier between life and death. It is found in the Department of Mysteries, a secretive branch of the Ministry of Magic which focuses on advanced magical research. In the books, it’s never explained what it is, or how it works.

I recently wrote about the veil on the Science Fiction & Fantasy Stack Exchange. I tried to use as much canon information as I could find, but there really isn’t much on the topic.

The questioner wanted to know more about what the Unspeakables might learn from the veil. JK Rowling has said in interview:

The Department of Mysteries is all about studying. They study the mind, the universe, death…

The topic has never been addressed in more detail, but I have some educated guesses. Rather than clutter up the thread with my speculation, I’m posting it here and I’ll link to it in the thread.

This is my take on what the Unspeakables might try to learn from the veil.

This post will contain spoilers for the Harry Potter series. Obviously, don’t read beyond this point if you don’t want to be spoiled.

The permanence of death

In the Harry Potter series, it’s taken as fact that death is permanent and irreversible. For example, in this passage from Goblet of Fire:

“Which means,” said Dumbledore slowly, his eyes upon Harry’s face, “that some form of Cedric must have reappeared.”

Harry nodded again.

“Diggory came back to life?” said Sirius sharply.

“No spell can reawaken the dead,” said Dumbledore heavily. “All that would have happened is a kind of reverse echo. A shadow of the living Cedric would have emerged from the wand.”

In Dumbledore’s notes on Babbity Rabbity and her Cackling Stump,1 this fact is repeated:

As the eminent wizarding philosopher Bertrand de Pensées-Profondes writes in his celebrated work A Study into the Possibility of Reversing the Actual and Metaphysical Effects of Natural Death, with Particular Regard to the Reintegration of Essence and Matter: ‘Give it up. It’s never going to happen.’

I think the Unspeakables would want to examine this assumption, and find out whether it really is impossible to bring somebody back from the dead. Are magical folk unable to reverse death because it’s genuinely impossible, or because they haven’t found the answer yet?

If the former, then you’d want to ask “Why?”. In proving that it really is a one-way process, you’d probably learn a lot about the nature of death itself. If the latter, then you’d want to find out how to reverse death, and what the consequences might be for somebody who tried.

One crude experiment is to tie something to a rope, and pass it through the veil. You probably wouldn’t start with a living person, but what about an inanimate object? What happens to a rock that passes through the veil? What about a partially-animate object, like a magical portait? And finally, a living person? All of these are potential ways to learn more about the veil, and the nature of death.

Communicating with the dead

If you discover that resurrection is impossible (or so difficult as to be impractical), then you might want to try talking to them instead. This is a particularly popular idea in Muggle as well as magical culture.

When we first encounter the veil in Order of the Phoenix, both Harry and Luna can hear voices “beyond” the veil.

“Can’t anyone else hear it?” Harry demanded, for the whispering and murmuring was becoming louder; without really meaning to put it there, he found his foot was on the dais.

“I can hear them too,” breathed Luna, joining them around the side of the archway and gazing at the swaying veil. “There are people in there!”

“What do you mean, ‘in there’?” demanded Hermione, jumping down from the bottom step and sounding much angrier than the occasion warranted, “there isn’t any ‘in there’, it’s just an archway, there’s no room for anybody to be there. Harry, stop it, come away—”

Notice that the different characters hear different things. In a 2008 interview with Melissa Anelli, JK Rowling elaborated on the differences:

When they surround that veil [in Order of the Phoenix], I was trying to show that depending on their degree of skepticism or belief about what lay beyond – because Luna, of course, is a very spiritual character. Luna believes firmly in an afterlife. She’s very clear on that. And she feels them speaking or hears them speaking much more clearly than Harry does. This is the idea of faith.

Harry thinks he can hear them; he’s drawn on. But Harry’s had a life that has been so imbued with death that he now has an uncharacteristically strong curiosity about the afterlife, especially for a boy of 15, as he is in Phoenix.

Ron’s just scared, as I think Ron would be – he just knows this is something he doesn’t want to dabble with.

Hermione, hyper-rational Hermione – ‘can’t hear anything, get away from the Veil.’ So if you walk through the veil, you’re dead. You’re dead.

You could explore these differences further (as long as you took appropriate precautions to avoid people walking straight through). They do a similar thing in the Love Chamber: exploring the effect it has on different people.

If you could find a particularly spiritual person like Luna, then you could listen to and interpret the whispers. (Being on the run from a pack of Death Eaters, Harry and co. don’t have time to stop and listen.) Maybe that opens a route of communication.

The Resurrection Stone and the Priori Incantatem effect in Goblet of Fire both provide evidence that this sort of magic is possible. If the Unspeakables could witness either of these first hand, then they could study them and try to replicate the effect.

If they can’t witness them directly, then the veil seems like a natural starting point for alternative investigations.

The afterlife

Another aspect of death in the series is the idea of an “afterlife”. Ghosts are the most obvious example of this, but there are other hints throughout the books. The Unspeakables would want to know what form this “afterlife” takes, and how it fits into the universe as a whole.

Part of this can be learnt from interviewing the dead, but it would be preferable to study it directly. Since the veil is a barrier between life and death, this would make it a focal point of study, as the Unspeakables try to learn what goes on “behind it”. A crude experiment would be to reach forward and just pull it back with your hand, but I imagine that wouldn’t end well. You can imagine a whole class of spells being developed for seeing through the veil.

You could also ask whether it’s possible for a living person to visit the afterlife, without actually being dead. The veil might give you a starting point for trying.

As well as an afterlife, we see a “limbo” state in the books. In Chapter 35 of Deathly Hallows, Harry and Dumbledore have a conversation in limbo, which appears to Harry in the form of King’s Cross Station. This was confirmed as limbo in a 2007 interview with JK Rowling:

In the chapter of King’s Cross, are they behind the veil or in some world between the real world and the veil?

JKR: You can make up your own mind on this, but I think that Harry entered a kind of limbo between life and death.

The same phrase was used in a question on her old website.

What makes this interaction particularly unusual is that Harry seems to have a choice about where he goes next:

“I’ve got to go back, haven’t I?”

“That is up to you.”

“I’ve got a choice?”

“Oh yes.” Dumbledore smiled at him. “We are in King’s Cross, you say? I think that if you decided not to go back, you would be able to… let’s say… board a train.”

“And where would it take me?”

“On,” said Dumbledore simply.

Silence again.

He’s just been struck with Avada Kedavra, the killing curse, so by rights he should be dead. Yet here we have an instance where death can be reversed, and doing so is the individual’s choice.

This sort of event would be incredibly difficult, probably impossible, to reproduce. But I imagine the Unspeakables try to replicate them, and study their effects. Does the veil take you to the afterlife via limbo, or do you die immediately?

Closing thoughts

All of the questions I’ve posed above can be found in real-world academia. We know of at least six other rooms in the Department of Mysteries, each corresponding to different mysteries of life.

If you want to know what the Unspeakables get up to elsewhere, then I’d suggest looking at the major problems of science and philosophy.

  1. In 2008, JKR released a copy of The Tales of Beedle the Bard, based on the book of the same name in Deathly Hallows. It’s supposed to be Dumbledore’s copy, as bequeathed to Hermione, so it includes some of his notes, and other comments from JKR

TextMate 2 and Quick Look

Several people were talking about TextMate 2 again this evening, so I decided to download the alpha and give it another spin. I stopped using it about ten months ago, but I wouldn’t mind going back.

Unfortunately, I ran into an immediate problem: it broke Quick Look. It has its own QL generator, and it claims a lot of common file extensions, then applies its own syntax highlighting to them. I don’t use the word “broke” lightly. If it was just cosmetic, then perhaps I could lived with it. (I might even have grown to like it!)

TextMate has a long-lived problem of being slow at handling large files, and this carried over to the QL generator. Normally the QL preview for a text file renders instantly, even if the file is very large. With TextMate’s QL plugin, the Finder took about 15 seconds deciding not to preview a 395 byte (!) file, and then crashed. That’s just not cool.

I haven’t found a defaults write command to disable this, but there is a fairly simple fix: in the app bundle (right click on the icon, then select “Show Package Contents”), there’s a folder


which contains the offending plugin. Deleting that folder and relaunching the Finder put everything back to rights.

I stopped using TextMate when I assumed that open sourcing it meant tjay development would grind to a halt. Since then, I’ve been using Sublime Text 2. It’s perfectly functional, but it doesn’t feel like a proper Mac app. I was obviously wrong about TextMate, so I’m giving it a trial for a few weeks to see how it’s doing. If it doesn’t do anything horrible, then I might start using it again, but as the old saying goes: once bitten, twice shy.

Cleaning up Google Maps

Earlier this morning, Fraser Speirs was bemoaning the design of the new Google Maps:

I hate the new Google Maps so much. Get that stupid search box off my map.
Fraser Speirs (@fraserspeirs) Tue Aug 20 2013 8:22 AM GMT

I decided to take him at his word, and spent an hour or so finding a way to de-clutter the interface. I’ve written a short bookmarklet which toggles the offending elements (the search box, and the other map overlays).

Drag this bookmark to your bookmarks bar:

Toggle Google Maps

Simply click it once to make everything disappear, and click it again to bring it all back.

I’ve tested it on the latest versions of Safari and Chrome on OS X. It should work in any modern browser, but I don’t guarantee that it will work for you.

How it works

Since Google Maps is a web app, adding a display: none attribute to the offending elements is enough to make them vanish, and then we just need a list of classes and ids for the corresponding elements. Here it is:

  • omnibox (id) is the search box that appears in the top left-hand corner. If you just want to target the directions box below it, you can use cards (class).
  • welcome (id) is the “Help & Feedback” button in the top right-hand corner.
  • widget-viewcard (class) is everything along the bottom of the map, such as the minimap preview, and the list of highlights.
  • widget-zoom (class) is the +/- buttons in the bottom right-hand corner. Many people use a scroll wheel or trackpad to zoom in and out, so these aren’t really necessary.
  • watermark (class) is the Google watermark at the bottom of the map.

So the following CSS is all we need:

#omnibox #welcome .widget-viewcard .widget-zoom .watermark {
    display: none;

However, that might not be exactly what we want. The search box is a useful feature; we just don’t want it all the time. What we really want is a toggle: we can use the search box when we need to, and hide it once we’re done. The following JavaScript is sufficient:

var ids = ["omnibox", "cards", "welcome"];
var classes = ["widget-viewcard", "widget-zoom", "watermark"];
var hidden = (window.getComputedStyle(document.getElementById(ids[0]))).getPropertyValue("display");

if (hidden !== "none") {
  var disp = "none";
} else {
  var disp = "";

for (var i = 0; i < ids.length; i++) {
  document.getElementById(ids[i]).style.display = disp;

for (var i = 0; i < classes.length; i++) {
  var div = document.getElementsByClassName(classes[i]);
  for (var j = 0; j < div.length; j++) {
    div[j].style.display = disp;

We can then bind this to a bookmarklet, and make that our toggle. (John Gruber’s JavaScript bookmarklet builder made this very easy.)

It’s a fairly simple script. The list of elements to toggle is specified in lines 2 and 3, and line 4 checks if the first element in the ids list is already hidden. This is used to determine whether to hide or unhide the elements. Then we loop through all of the elements with matching ids or classes, and set the appropriate display attribute.

Of course, there’s nothing about any of this which is unique to Google Maps. You could use exactly the same bookmarklet to toggle elements on any website, if you gave it the appropriate list of elements. (Comments, for example.)

In an ideal world, I’d wake up tomorrow to find that Google had made this obsolete by adding their own toggle to Maps, but this should act as a stopgap until they do. If nothing else, it was a fun way to spend an hour.

Finding untagged posts on Tumblr

Yesterday one of my friends was going through her old Tumblr posts, trying to add tags to every post. If you have any more than a handful of posts, then this becomes tedious and difficult, and you’ve no guarantee that you tagged them all when you’re done. Tumblr doesn’t have a built-in way to list all of your untagged posts, so I wrote a script to poll the Tumblr API, and get a list of post URLs which didn’t have tags.

Doing a Google search for this topic, it seems that this is a fairly common problem, so I thought I’d post the script here for other people to use.

It’s fairly simple:


import urllib2
import json

hostname = "example.tumblr.com"
api_key = "abcdefg"

url = "http://api.tumblr.com/v2/blog/" + hostname + "/posts?api_key=" + api_key

def api_response(url):
    req = urllib2.urlopen(url)
    return json.loads(req.read())

jsonresponse = api_response(url)
post_count = jsonresponse["response"]["total_posts"]
increments = (post_count + 20) / 20

for i in range(0, increments):
    jsonresponse = api_response(url + "&offset=" + str((i * 20)))
    posts = jsonresponse["response"]["posts"]

    for i in range (0, len(posts)):
        if not posts[i]["tags"]:
            print posts[i]["post_url"]

print("All finished!")

The only notable feature of the script is that it gets posts in batches of 20, because the Tumblr API only returns up to 20 posts at a time. Everything else is either standard Python or follows from the way that Tumblr structure their API responses.

To use the script, you need to download it and change the parameters in lines 6 and 7. The hostname is the URL of your Tumblr site. Quoting directly from the Tumblr API documentation:

Each blog has a unique hostname. The hostname can be standard or custom.

  • Standard hostname: the blog short name + .tumblr.com.
    Example: greentype.tumblr.com
  • Custom hostname: Anything at all, as determined by a DNS CNAME entry.
    Example: www.davidslog.com

Make sure you type it in exactly, and wrap it in quote marks.

Then you need to add an API key. This is what authenticates you to Tumblr, and lets you download your post data. To get an API key, first make sure you’re logged into Tumblr, then go to the OAuth registration page on Tumblr. Click Register Application, and fill in the following details:

  • Application name: Untagged post finder
  • Application description: Finds untagged posts on a blog
  • Default callback URL: /

Once you click Register, you’ll be taken back to the previous page, and you’ll see something like this:

Copy and paste the OAuth Consumer Key into line 7 of the script, and remember to wrap it in quote marks.

Once that’s done, you just run the Python script (if you haven’t done that before, then there are plenty of helpful guides on Google), and you will shortly have a list of all your posts which don’t have tags. This isn’t quite a “one-click” solution to the problem, but I think it’s better than searching through your posts by hand.

RSS feeds for podcasts on Tumblr" >RSS feeds for podcasts on Tumblr

On the latest episode of the Accidental Tech Podcast, Marco, Casey and John were discussing podcasts. They were comparing them to blogging, the way more people wanted to have their own podcast, and how the tools for making your own podcast compare to those for making your own blog. A little over an hour in, Marco mentioned a useful Easter egg in Tumblr for podcasters.

Marco was the co-founder and lead developer at Tumblr for about three and a half years. Every so often, he drops a nugget like this on one of his podcasts, telling you about an undocumented feature of Tumblr that turns out to be really useful. Since I haven’t read this one mentioned anywhere else, I decided to break it out into a nice, Google-searchable blog post.

Skip to the 1:03 mark for the relevant segment. Marco:

Tumblr also supports podcast hosting if you host the files elsewhere. I believe if you go to any Tumblr site /podcast, or maybe /podcast/RSS, it will give you an iTunes compatible podcast feed of any audio posts that are externally hosted.

I went to have a play, and this feature still works. You want the first, rather than the second, extension. Adding /podcast to a Tumblr site gives you an RSS feed for the podcast. If you a Tumblr site under your own domain name, then adding /podcast to that works just as well.


A disclaimer: I haven’t tested any of this extensively, and I don’t know anybody at Tumblr who’d be able to explain exactly how this feature works, but I thought it was useful enough to share with other people.


I tested this in iTunes, Instacast and Reeder, and all three seemed to load the file without problems. Show notes seem to come from the text included in the post.

For reasons that aren’t immediately obvious, loading the feed in Chrome throws up the following error:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

In this case, Chrome doesn’t pass the RSS feed out to a feed reading application, such as Reeder. However, copying and pasting the URL seems to work just fine.

Indeed, this Chrome bug seems to occur in lots (all?) of Tumblr’s RSS feeds. However, all of the feeds I’ve tried parse correctly for me, so I’m not sure how much of a problem it is.

On the subject of RSS feeds, here are two more handy tips:

  • If you add /tagged/mygreattag to a Tumblr URL, then you get all of the posts from that Tumblr site that have been tagged with “mygreattag”. I find that pretty useful.

    For example, http://natgeofound.tumblr.com/tagged/africa takes you to all the posts on the National Geographic Tumblr site with the tag “Africa”. (There are some really stunning photos on that site. Definitely worth checking out.)

  • You can then add /rss to that URL to get a nice RSS feed of all the posts with that tag.

Some Googling showed up this second tip as another way to get podcast RSS feeds from Tumblr: tag all your episodes with “podcast”, then get the RSS feed associated with that tag. I haven’t tried that myself, so I don’t know how it compares to the method above, but it’s always nice to have options.

Automatic Pinboard backups

I’ve been using Pinboard to store my bookmarks for nearly two years, and it’s a wonderful site.

Before I joined, I kept all of my bookmarks as .webarchive files stored in a folder on my computer, with a hideously complicated text document holding all of my comments and tags. Pinboard has been a breath of fresh air: it’s fast, simple, handles all of the archiving for me and has generally been very reliable.

Unfortunately, two years had taken their toll on my account, and the whole thing was a bit of a mess. Rather than try to restore some sense of order to an unsustainable tagging and annotation system, I decided to blow all of my bookmarks away, and start from scratch. I’ve exported all of my old bookmarks, and perhaps I’ll add them all back as time allows. Or perhaps not.

When I exported them all, I suddenly realised how fragile my system was. Although I’m sure Pinboard keeps excellent backups, I didn’t actually have a local backup of my bookmarks. I’d make a half-hearted visit to the export page every so often, but I didn’t have it automated. This time round, I wanted to change that. So I wrote my own system for doing Pinboard backups.

Several scripts have already been written to do this (such as Marcelo Somers and Drew Schuster). I wrote my own because I wanted one written in a language that I’m familiar with (in this case, Python), and so that it provided exactly what I wanted: saving a copy of the XML file to my local drive.

Also, the scripts I’ve seen before all use username and password authentication to access the API. But about eight months ago, Pinboard introduced API authentication tokens that mean you don’t have to do this. This seems like a better method, so I wanted to use that in my backups.

Finally, I drew inspiration from Dr. Drang’s series of posts on archiving tweets. I use a fork of his Twitter archiving scripts to back up my tweets, and my Pinboard script was modelled on the same.

So without further ado, here’s the script:


import os
import pytz
from datetime import datetime

import urllib2

# Parameters.
bookmarkdir = os.environ['HOME'] + '/Dropbox/Personal/pinboard/'
pinboard_api = 'https://api.pinboard.in/v1/'
yearfmt = '%Y'
datefmt = '%m-%d'
homeTZ = pytz.timezone('GMT')
y = datetime.now(pytz.utc).strftime(yearfmt)
t = datetime.now(pytz.utc).strftime(datefmt)

# Get the user's authentication token
with open(os.environ['HOME'] + '/.pinboard-credentials') as credentials:
    for line in credentials:
        me, token = line.split(':')

if not os.path.exists(bookmarkdir + y):
    os.makedirs(bookmarkdir + y)

# Set up a new bookmarks file
bookmarkfile = open(bookmarkdir + y + '/pinboard-backup.' + t + '.xml', 'w')

# Get all the posts from Pinboard
u = urllib2.urlopen(pinboard_api + 'posts/all?auth_token=' + me + ':' + token)

The first section defines the parameters for the script: where the bookmarks are stored and the version of the Pinboard API that I’m using. The datetime code to get strings of the date are used later to set up the particular structure I wanted for my backups.

The second section gets my username and authentication token, which and stored in a file called .pinboard-credentials, that lives in my home directory. This file contains a single line, which is my API token, copied and pasted verbatim from my Password settings page:


With this structure, there’s no reason you couldn’t then extend the script to back up multiple accounts (even if I can’t think of a scenario where you’d have multiple Pinboard accounts).

Next we set up a directory for the backups. I just have a folder called pinboard, and I’ll keep a separate folder for each year. These are created by line 22, which looks for the folder for the current year, and creates one if it doesn’t already exist. Within that folder, I then name the bookmark files pinboard-backup.%M-%d.xml, which matches the structure I use for my IRC logs. I don’t think I’ll ever be saving a copy of my bookmarks more than once a day.

Finally, lines 30-33 call the Pinboard API, download a copy of all of my posts and save it to the appropriate file. It gets the authentication token which was extracted from .pinboard-credentials previously. Each new backup is saved to a new file. Since the files involved are so small, I didn’t see the point in throwing away old backups unnecessarily.

Of course, I don’t want to run this script by hand, so I used Lingon to create a Launch Agent that runs the script once a week, every Sunday morning. My laptop is usually switched on at this time, and if I miss a week, then it’s not a great disaster. But this seems regular enough for me.

I also keep both the script and the archive files in Dropbox, so I could always set it to run on a different computer as well, and there shouldn’t be any problems (in theory!).

(The “What” field is slightly truncated in the image; it ends archive-bookmarks.py.)

This should continue to run indefinitely and keep a copy of my bookmarks stored on my local drive. Unless I’ve made a mistake somewhere, I can now use Pinboard without ever having to worry about a backup.

The script can be downloaded from my GitHub page.

Edit (1 April 2013). Thanks to Stephen Hügel for tidying up some of the script; his changes have been merged with the repo at GitHub. The basic functionality is unchanged, so most of what I wrote above still stands. The GitHub repo will have the most up-to-date copy of the script.

Second edit. Andrew Jones has a much faster way of doing this, which does everything I did, but in a single line. I’m still glad I did this, because it was a fun morning project and I enjoyed writing it up, but other people might prefer his method.

OS X" >Strange clock bug in OS X

Tomorrow’s switch to British Summer Time seems to have uncovered quite an unusual bug in my mum’s MacBook Pro. I haven’t been able to reproduce it, but it was so strange that I thought it worth briefly documenting here (in addition to filing a bug report, of course). I haven’t managed to find anybody else who’s had this problem, although I’m really not sure what to type into Google for this.

For reasons that remain unknown, the clock in the menu bar got stuck whenever the machine was put to sleep. Minutes would continue to increment once you woke the laptop up, but anything that had elapsed in the sleep period seemed to get lost.

My mum had put the laptop away at around half past five, and when she reopened it at ten to eight, the clock in the menu bar read 17:30. As she used the laptop, this steadily ticked away, minute-by-minute, but remained stuck at a time nearly three hours previously.

She called me downstairs to take a look at it (since it’s an utterly bizarre behaviour). A quick trip to the Date & Time pane of System Preferences seemed to fix the problem, just by opening the pane. As I opened it, the menu bar clock snapped back to the correct time.

Presumably when you open that part of System Preferences, OS X looks up what the current timezone setting is, and in doing so, it reset whatever had got stuck in the menu bar clock. Unfortunately I have no idea where the blockage actually was.

I’m probably never going to find out what caused this bug. It may be a complete coincidence that this occurred just before the switch to BST, or there might be an obvious connection.

It’s hard to extrapolate the cause of a bug from a single data point, but it feeds into my general perception that working with dates is incredibly hard. Implementing them in code, accounting for clock changes, leap years and other oddities of the calendar, even more so. As I’ve said before, I find this really quite fascinating, and I hope to learn more about this in the future.

Candybar and icon recommendations

For several years, I’ve used a piece of software called Candybar to customise the icons on my Mac. About six months ago, the developers of Candybar, Panic, made the app free. As OS X changes, it’s plausible that one day, you might be unable to change your icons. Although I’ve had a license for several years, and so I’m not affected monetarily, I still appreciate the gesture.

Earlier tonight, I was recommending Candybar and a list of my favourite icon sets in a comment on Dreamwidth. Since this might be of interest to other people, I’m posting it here for everyone to read.

Instructions for downloading Candybar are in the Panic announcement. Links to the various icon sets are embedded below.


You might ask why you’d want to customise your icons. Good question. I’m by no means a UI expert, but here’s a brief explanation of why I like to do it:

One of the big changes in OS X Leopard was to remove all semblance of colour from folder icons. A similar trend has continued throughout OS X: the sidebar icons in iTunes, iPhoto and Mail have become similarly monochrome. This has generally been seen as a bad move, because colour is an easy way to pick out different icons, and removing it makes it harder to pick out something at a glance.

If you customise your icons, you can make them visually distinctive, and easy to find at a glance. You can also use colour to denote significance (for example, I pick out folders for projects with an imminent deadline in a bright red). It also looks nice.


So here’s the list (originally written for somebody who is both fannishly active and a big Avengers fan). I use almost all of these somewhere on my Mac, and I really like all of them.

I’ve mentioned Louie Mantia several times in the links above. He’s one of my favourite designers, and as well as icons, he’s designed a lot of wallpapers (http://mantia.me/wallpaper/). They’re definitely worth checking out. Themes include Harry Potter, Alice in Wonderland, Brave, a SHIELD wallpaper, and lots of other things that I’m not fannishly aware enough to recognise.

Of course, there are lots of other places to find good icon sets. I’ve mentioned The Iconfactory above; I’ve also picked up gems from Dribbble and the icons section of deviantART before. Icon designers often post freebies on their personal sites too. And there’s nothing to stop you breaking out Photoshop and trying your hand at making one yourself.


Darwin, pancakes and birthdays

I was browsing Twitter yesterday, and I happened to see a fun tweet about Darwin.

It’s Darwin’s birthday apparently. Do you think he was ever like “can I have a birthday cake?” and everyone else was like NO ONLY PANCAKES.
she-hulk. (@milkbutnotsugar) Tue Feb 12 2013 10:36 AM GMT

I quite like the idea of this, but I was a bit dubious about the plausibility. The tradition of pancakes on Shrove Tuesday is fairly well established, with pancake races dating back to at least 1445, so we can be reasonably sure that Darwin was at least familiar with eating pancakes on the day.

Birthday cakes are a little fuzzier. The earliest reference to a birthday cake that I could find was in Germany, 1746, and there really aren’t many mentions of cakes in Europe before 1850. Since Darwin was born in 1809, I don’t know how many birthday cakes he would actually have had. Poor Darwin.

But that wasn’t what piqued my interest. Let’s suppose that Darwin definitely had pancakes and birthday cakes. As was correctly pointed out a few moments after the original tweet, Shrove Tuesday moves around every day with Easter. I wanted to know: did Darwin’s birthday ever overlap with Shrove Tuesday while he was alive?

This gave me an opportunity to do a bit of playing with the datetime library in Python. Nothing here is particularly complicated, but it was fun to write nonetheless.

First we need to calculate the date of Easter. At face value, this might seem quite hard, since Easter moves around based on the cycles of the Moon. As it turns out, there’s a really easy way to do this, called Butcher’s algorithm. This is very easy to implement in Python, which gives us a way to find Easter:


import datetime

def easter_date(year):
    a = year % 19
    b = year // 100
    c = year % 100
    d = b // 4
    e = b % 4
    f = (b + 8) // 25
    g = (b - f + 1) // 3
    h = (19 * a + b - d - g + 15) % 30
    i = c // 4
    k = c % 4
    l = (32 + 2 * e + 2 * i - h - k) % 7
    m = (a + 11 * h + 22 * l) // 451
    p = h + l - 7 * m + 114

    month = p // 31 
    # Here 3=March, 4=April

    day = p % 31 + 1
    # Since dates count from zero

    return datetime.date(year,month,day)

Once we’ve found Easter, getting to Shrove Tuesday is easy: we just jump back 47 days, and datetime contains a handy timedelta function that does just that:

def shrove_tuesday_date(year):
    easter = easter_date(year)
    shrove = easter - datetime.timedelta(days=47)
    return shrove

Finally, a simple for loop is enough to go through and find the years in Darwin’s life when his birthday was coincident with Shrove Tuesday:

for i in range (1809,1883):
    if shrove_tuesday_date(i) == datetime.date(i,02,12):
        print i, i-1809

which returns the following:

1839 30
1850 41
1861 52

So Darwin might have gone without birthday cakes because of Pancake Day at most three times in his life.

Looking at the years above, we notice that they’re separated by eleven years each. It turns out, this isn’t entirely coincidence. Let’s look at a wider range of years. Butcher’s algorithm runs from the start of the Gregorian calendar (in 1543) until, well, indefinitely.

So we can easily reuse the function above to find lots of years where Shrove Tuesday fell (or will fall) on February 12th. Running from 1543 to 2500:

1619 1630 1641
1771 1782 1793
1839 1850 1861
1907 1918 1929
1991 2002 2013
2143 2154 2165
2211 2222 2233
2363 2374 2385

So we have lots of clusters of three cropping up. And in the two areas where it breaks, the differences between years are still the same (6 and 5). And since Easter and Shrove Tuesday are separated by 47 days every year, this means that Easter is moving in the same pattern.

There’s clearly a feature of the Gregorian calendar that causes it to fall out this way. If we looked at different dates, we’d probably find similar patterns. I’m not going to go into it here, because it probably takes quite a lot of work, but I’ve included a link in the further reading section on Easter intervals.

Date maths can be really hard, and this is just one example of that. It’s not at all obvious why this pattern should appear, simply by looking at the calendar. I find all the exceptions and special rules really interesting, and I want to learn more about this. Even writing this simple stuff was quite fun, and I’d like to do more of it in the future.

And after all that, we still don’t know if Darwin got his cake.

Further reading

  • And now it’s all this is the blog of Dr. Drang. A good mix of engineering, maths and programming; I always enjoy reading it. He’s written quite a few good posts on date maths in the past, and I had those in mind as I was writing this post. I also used his fork of blackbird.py to embed the tweet at the top of the post.
  • Birthday Cakes: History and Recipes is a detailed history of the birthday cake in Western culture. If you’re interested in where our modern traditions came from, and what birthday cake etiquette used to be in the past, then you should read this. Lots of stuff that I didn’t know before. Fascinating read.
  • Easter Intervals is a journal article about the days on which Easter falls, which I briefly mentioned above. It looks at the days on which Easter is most likely to fall, and how the calendar structure sets that up. There’s some very interesting stuff in there.


At my Sixth Form, there was a discussion group called the Stride—Darnley Society, named after a former English and Drama teacher who was a major advocate of public speaking and debating. The group was set up in her name for Sixth Formers to present and discuss essays on topics that they enjoyed. This is an essay I wrote for the society, on the number zero.

I presented two essays: one on the number zero, and one on electoral politics (specifically, the mathematics of voting systems). Hardly surprising, since I’d eventually go on to study maths at university, and I try to attend regular History of Maths lectures, which touch on similar topics to my essay on zero. I enjoyed writing both of the essays, and since I now have a writing outlet on the web, I thought I’d post one of them. It’s mostly unedited, except to check that it’s made the conversion to HTML okay.

I last opened this in March 2010, so I hope it’s still interesting, several years later.

The importance of measuring nothing

What is 7 minus 7? The answer seems obvious to us, living in the twenty—first century. But odd as it sounds, ’zero’ had to be invented, and it took millennia to catch on. What I want to explain today is why zero took so long to be accepted, and why it’s so fundamental to modern mathematics.

Historians believe the idea of a number to represent nothing arose with the Indian mathematician Brahmagupta in 620 AD, who also developed the Hindu—Arabic numerals 0 to 9 we use today. The system reached Europe in the eleventh century, from Spanish Muslims travelling from the Iberian peninsula. The Italian mathematician, Leonardo of Pisa, better known as Fibonacci, saw the Arabic numerals while working with his father in the customs house of the North African town of Bugia. He introduced them to European mathematicians, and they were quickly adopted as the standard for mathematics, including the digit 0. Before then, Europe had used an amalgamation of number systems — including Greek, Egyptian, Babylonian and Roman.

I want to highlight here how important 0 is to a number system, with the example of the Romans. Their system was in use for centuries, but it had no proper concept of nothing as a number. They only gave it a name, nulla, or nothing. And other cultures at the same time, although they used other methods to indicate the absence of a value, not one called it a bona fide number in itself.

Now let’s take a relatively simple sum, say 43 + 24. With our decimal system, we can easily line the numbers up, do the addition, and get the answer 67. But the Romans had to carry out the sum XLIII + XXIV. No amount of lining up will ever give the answer LXVII. Even representing large numbers is daunting. Take a year, like 1999:

  • M – 1000, then
  • MCM – 100 before 1000, or 900, then
  • MCMXC – 10 before 100, so 90, then
  • MCMXCIX – 1 before 10, or 9

Working with these numbers is just daunting. Imagine trying to subtract, multiply or divide with this counting system. Abaci and tally systems helped alleviate the problem, but otherwise Roman mathematicians faced some pretty demanding sums.

And to see how much this held the Romans back, let’s count the number of influential Roman mathematicians. There were none. Despite close contact with the Greeks, a highly mathematical society, the Romans have made very little contribution to mathematics. Perhaps the mathematical historian, Morris Kline, put it best when he said:

The first disaster in mathematical history was the advent of the Romans, whose entire role in the history of mathematics was that of an agent of destruction.

The Romans borrowed a great deal of mathematics from ancient Greek society — this is how they built their roads, bridges, temples, houses for which they are famed — all based upon the foundations of engineering laid down by the Greeks. But in terms of innovation, they contributed nothing. The use of such cumbersome numerals stifled the dawn of new mathematics in what was otherwise a very technically advanced culture.

So clearly a decimal system like that of the Arabs is more practical than that of the Romans. But it still took many years for them to catch on. While mathematicians used them predominantly since Fibonacci’s time, merchants still preferred to use Roman numerals. It wasn’t until the sixteenth century that Arabic numbers, and hence the number zero, became commonly used in Europe.

But perhaps it’s understandable that the Romans and merchants weren’t keen to embrace the idea of a number for nothing. For them, maths was a very practical subject — architecture, engineering and accounting. In these areas, actual, physical things are being measured and counted, so they had no need to ever quantify nothingness. After all, if an engineer is designing a building and ends up with a length of nothing, chances are that somewhere he’s made a dodgy calculation.

To these earlier people, zero didn’t have any practical use. In fact, the idea of a zero being considered a number sent the ancient Greeks into a fit of philosophical, and even religious, arguments and disputes over what exactly constitutes a number, and whether numerical status can really be applied to a representation of nothingness.

But like it or not, zero eventually made its way into European number systems. I’ve already shown how Roman numerals made heavy calculation cumbersome? But beyond this, is it really necessary to use zero? I mean, can’t we just do with digits 1 to 9?

Absolutely not. Zero is fundamental to a number system, because it acts as a placeholder to hold the place of empty values. For example, 100 in the decimal notation tells us that there are no values in the ones or tens, but there is a 1 in the hundreds. So we read it as one hundred, but no one ever says, one hundred no tens and no ones. If we cross over to the other side of the decimal point, .001 becomes one thousandth. There are no tenths and no hundredths. It’s a very useful digit.

But once we put zero in our number system, we have to face how it interacts with other numbers. With addition, subtraction and multiplication, it plays quite nicely. But there was one operation that played havoc with zero: division.

Division by zero is one of the Gordian knots of mathematics. Ancient mathematicians like Brahmagupta grappled with the problem, but got nowhere. Today, if you ask a mathematician “What happens if I divide by zero?” you’ll simply get the answer, “You can’t. It’s against the rules.” Today, division by zero is never allowed.

Some people think dividing by zero is infinity. But this isn’t true. Division is defined as the inverse of multiplication: if you divide by zero, and then multiply by zero, you should get back to the number you started with. However, multiplying infinity by zero produces only zero, not any other number. There isn’t anything which can be multiplied by zero to get a nonzero result, so the result of division by zero is, literally, “undefined.”

But it took many years for this results to be accepted. And this isn’t the whole story. What, for example, might you get if you divide zero by zero? Or zero to the power zero? As you can see, there are a lot of problems with this “unnumber” — which is what zero is, a problem to represent something that doesn’t exist — you can see why the number took so long to catch on.

Once accepted though, from this Pandora’s Box of a number sprang a whole new world of mathematics. Let’s look at a few of them.

Perhaps one of the simplest benefits we can see is by drawing a number line. Zero as a number does not have a polarity: that is to say, it is neither positive nor negative. Before zero, we only knew about the numbers on the right hand side of the number line: the positive numbers. But until mathematicians accepted zero as a valid number, we couldn’t unlock the negative numbers, and the vast quantity of new mathematics that comes from them.

Because it divides the number line in two like this, it’s incredibly important for scales. It’s the pivotal point for thermometers, and the Kelvin temperature scale dictates a point called absolute zero: the coldest temperature an object can reach. An when dealing with limits, velocity and acceleration, the direction that movement has in relation to zero dictates whether it is positive or negative.

Another mathematical concept that arises from negative numbers is that of the imaginary number. The square root of a number is the number which, when multiplied by itself, produces a specified quantity. For example, 7 is the square root of 49. If you try and square root a negative number though, you hit a problem. A positive number squared is positive; a negative number squared is also positive — is any number squared negative? Well, yes. These are called imaginary numbers, based around i, the square root of minus one. Imaginary numbers have very important real—world applications. Perhaps one of the most practical lives in our televisions. We?re used to getting dozens of channels, but with a single input signal. Each channel has its own unique frequency in the signal, and the TV has to filter out all the other channels and display only the frequency you want.

The design of this incredibly complex mechanism is done by computer, but at the heart of these computations are imaginary numbers. If you have anything more than a few channels, the only humanly way possible to manage the output is with imaginary numbers. Otherwise, you?re stuck trying to solve something called a tenth order differential equation, and just trust me here, it?s as difficult as it sounds. So when you go home this evening, put the telly on, watch Sky or whatever, you can thank imaginary numbers, and so you can thank zero.

And if we treat 0 as a value, a quantity of nothing, we open up an entirely different world of applications. Have you ever wondered how computer generated imagery, or CGI works? A computer has to produce and solve countless mathematical equations. For example, a doughnut shape (in mathematical terms, a torus), uses something called a quartic equation. And these equations rely on some terms being equal to zero; the computer can then crank out the algebra and draw the shape. But without a zero, solving this equation becomes impossible, and so does drawing these complex shapes.

So, to wrap up. Zero has caused mathematicians no end of grief and discomfort, but it’s a key part of mathematical history. It took centuries to reach universal acceptance, but today zero would be impossible to live without. Modern computers might still exist without zero, but they would be far less efficient. Large numbers can exist without zero, but they would be more cumbersome to manage. Higher mathematics could still exist without zero, but the proofs would be far less elegant and need much more work.

One of the most important values in number theory, with its myriad of uses, it’s safe to say that zero is worth far more than the sum of its parts.

Copyright © 2014 Alex Chan. Built using Pelican.