Things I've written over the years

Display mode


Explorations of various software development topics, as standalone articles.

DeviantArt Community Guest Feature: When Art Meets Code (Jul 2024)
First written for the DeviantArt Community group journal, Jun 2024. A short exploration of the connection between Piet Mondrian's abstract art and esoteric programming languages.
(Almost) Pure CSS Tooltips (Jun 2024)
Tooltips are the leading cause of hair loss for frontend developers: many hours have been lost fighting JavaScript frameworks to get their positioning just so. This article looks at how simple tooltips can be achieved with CSS, and the limits of the approach.
Implementing HTTP Signatures with PHP and OpenSSL (May 2024)
Part of a series on implementing ActivityPub support for this blog. A core tenet of ActivityPub is the generation and verification of signatures for messages, and this article looks at how that works in PHP.
Slow-Roll Livecoding: Proxying a REST API with PHP (Apr 2024)
Sometimes you need to proxy an API, and you may not necessarily have the resources or wherewithal to install dedicated proxying infrastructure. Let's try to write a proxy in PHP, and see what troubles we run into.
Building a Solitaire "AI" in JavaScript (Mar 2024)
Ever wondered if it's possible to automatically solve a game of Solitaire? It's something I got to thinking about a little while ago, and this article looks into one way you could go about it.
The Curious Case of Debian 12 and the SSH Failure (Jan 2024)
A dive into the perils of running your own mailserver, when something terrible goes wrong with an upgrade.
Nested Threads and the Mastodon Context API (Dec 2023)
Like many microblogging platforms, Mastodon displays posts and replies in a flat list; this can get confusing when conversations get deeply nested and branched. The Mastodon Context API offers a way to retrieve parent-child relationships between replies; this article looks at how those can be converted into a traversable tree.
Seven Snippets of Modern CSS I Used To Rebuild My Site (Nov 2023)
A few months ago, I refreshed the design of my personal site; here's a list of a few bits of modern CSS that were used in the rebuild.
Binary Golfing in Commodore BASIC (Oct 2023)
This year's Binary Golf Grand Prix recently closed for submissions, and I only just found about it. This article covers a couple of approaches for this particular code golf problem on the Commodore 64.
Preprocessor Definitions in WebAssembly (Sep 2023)
When hand-writing WebAssembly it can get problematic to refer to particular constants by their value instead of being able to put a name to them. I put together a simple preprocessor to allow for constants to be handled by name, and in this article I look at how the preprocessor works with the WebAssembly Text format.
RFC 7168 (Apr 2014)
An update to HTCPCP (RFC 2324) to allow for the connection of networked tea-brewing devices. Published under the RFC Informational series.
Steganography with Brainfuck (Nov 2011)
There are a number of techniques for encrypting or hiding information within an image, including the concept of hiding a program within the image which itself prints the secret information. This article explores the feasibility of encoding a Brainfuck program within the bitmap data of an image, with a detailed run-through of a simple example.
Printable Opcodes in x86 Real Mode (Jun 2011)
Procedures for transmission of files over ASCII-text networks generally involve some form of encoding such as uuencode. When program executable files are being encoded for transmission, extra steps are required at the receiver before the program can be run. This article explores the concept of a program which has been encoded for an ASCII-text network, but can also be run directly without decoding; in this case, the article is limited to MS-DOS programs.
Android NDK Edge Detection (May 2011)
Concluding an introduction to the development of augmented reality software, this part looks at implementing an edge detection algorithm overlaid on an Android smartphone's camera preview, and how the process can be optimised through use of the Android Native Development Kit.
Android NDK Camera Overlays (Apr 2011)
One of the major current trends in smartphone applications is augmented reality: a view of reality with information laid on top. This can be as simple as a view of what the camera is currently seeing, with calculations based on position and direction. In the first of a two-part article series on Android development, this article looks at how to set up a camera view and access a canvas for the rendering of overlay information.
Memory Usage of Constants in PHP (Jun 2010)
PHP provides two methods of defining constants: global-scope constants and class constants. A friend of mine, while discussing the issue with Derick Rethans, was informed that class constants are more memory efficient; this article documents my investigation into the reasons behind that assertion.
Venn Diagrams in PHP with imagick (May 2010)
Visualising the overlap between two sets of data is often achieved through Venn diagrams, but such diagrams can be difficult to render in a web development environment. This article covers the mathematics and geometry behind the Venn diagram, and a simple implementation of the algorithms involved in calculating the appropriate dimensions.
Discordian Dates in Java (Mar 2010)
Date handling, and especially conversion between different calendars, can be a complex issue to deal with. This article introduces the concept of calendar conversion in Java, and the issues that need to be dealt with when performing such conversions, by building a handler for the Discordian calendar and investigating the mappings between months in the Gregorian calendar and the Discordian seasons.
Audio Captchas in PHP (Jan 2010)
The major compromise made when a website uses Captcha images is that between accessibility and security; those with bad eyesight or colour-blindness may have trouble viewing a Captcha image. One way around that is to provide an MP3 download option for the Captcha text, which gives another path of accessibility to the process. This article looks at how an audio Captcha can be generated, using common tools.
BCD Addition on Atmel AVR (Dec 2009)
The AVR instruction set manual mentions binary-coded decimal exactly once, and provides no instructions for easily working with BCD values, despite the utility of BCD in embedded applications. This article explores the issues involved in working with BCD values, especially in incrementing and adding such values, and introduces an algorithm for resolving the discrepancies that arise.
Gameboy Z80 Opcode Map (Nov 2009)
The CPU used by the Nintendo GameBoy is a specially modified version of the Z80, with various functions removed to make the CPU cheaper to manufacture. Documentation for this CPU is often lacking; the most common opcode maps are written down as a standard Z80 map with addenda for the Nintendo modifications. This opcode map collates the references into a coherent opcode map for the Nintendo GB-Z80.
PayPal Website Payments Pro in PHP (Sep 2009)
PayPal is used across the world to authorise payments online, and a seamless credit card payment service is available through Website Payments Pro. Unfortunately, the documentation for implementing this can be confusing and contradictory, and getting your code working can take some time. In this article I've brought together the documentation and my experience with it, to provide a coherent source of information on Website Payments Pro.
Parsing the DIME Message Format (Jul 2009)
If a SOAP web service requests in a complex response, where more than one file has to be returned, an encoding format has to be used to fit the files into one message. One of the more common formats is Microsoft DIME, used by Jasper Reports and other services. This article looks into how a DIME message can be parsed, and the files pulled out to work with.
Rebuilding Your Leg After Shooting Yourself in the Foot (Jun 2009)
At some point, most developers have come across 'Shooting yourself in the foot', the comparison of how different programming languages would implement the process of firing a gun at your foot. This article assumes success, and the lack of a significant portion of your leg; Part Two looks at how to rebuild your leg, in various languages.
Vanilla JavaScript Slideshows (Jun 2009)
Many developers state that modern JavaScript effects, such as slide-shows and news tickers, can only be viably achieved using frameworks such as jQuery and Dojo. This article sets out to demonstrate that it is in fact a simple affair to construct a slideshow using JavaScript and DOM manipulation, without the need for such frameworks.
Vanilla JavaScript Tab Controls (Mar 2009)
Tabs have always been one of the most useful elements of a user interface, allowing an interface designer to pack a lot of information into a small space by only showing a section at a time. This article explores the implementation of a tabbing interface using HTML and JavaScript, and goes on to look at pages where more than one set of tabs is used at the same time.
Modified Preorder Tree Traversal (Feb 2009)
Exploring the MPTT algorithm, and how it can be used for hierarchical data storage. Includes algorithms for addition to and removal from the tree.
Asynchronous JavaScript and JSON (Dec 2008)
The most common problem that people encounter when using AJAX is that they can't update more than one region of a Web page at the same time, since the request only comes back to fill one region. Using JSON, it's possible to update multiple regions at once, and it's even possible to run inline JavaScript in the AJAX response, automatically. The magic behind it is explained here.
Using Pointers in C# (Nov 2008)
The current crop of programming languages tend to frown upon the use of pointers, deeming them to be unsafe for everyday work; indeed, many languages ban their use altogether. C# is different: it is possible for a C# program to delve into pointers, but there are caveats. An example is given in this article, using a graphical bitmap effect driven by pointer arithmetic.
Automated Deployment with Subversion (Oct 2008)
Version control systems and development testing servers go hand in hand; you work on your local working copy, and test on the development server. But what happens when you want to take your work live: to deploy the developments you've completed? This article presents one way to solve that problem, by using the scripting facilities provided by Subversion.
Building Complex Emails with PHP (Aug 2008)
The first script that a budding PHP developer builds is often a tool to send simple email messages from a website, with a couple of paragraphs of text inside. What these scripts lack is the ability to send HTML-formatted emails, or to attach documents and other files to the message. In this article, I cover the MIME standard for building complex emails, and how to format and send a MIME-compliant email message in PHP.
Extended Text Mode on the C64 (Aug 2008)
When you mention the Commodore 64, most people think that it's an obsolete computer from the 80s which no-one could ever use nowadays. One of the major problems is that you can't fit enough information onto a C64's screen: the standard size of a work terminal is 80 characters by 25 lines, and 40x25 just isn't enough. In the first part of a series (which may take some time to complete), I look into rendering an 80x25 text screen on the Commodore 64, and how it can be done.
The Structure Pattern in PHP (Jul 2008)
Reading and manipulating binary files can be troublesome in PHP, primarily because the language doesn't have a native type to represent structures of encoded data. Using the Structure pattern allows PHP to load and work with these files, by providing a method of decoding the data into a class and performing calculations. Examples are given in this article of the Windows BMP and TrueType file formats.
Intranet DNS Resolution with BIND Views (Jun 2008)
When you're working on a web site that's hosted in the same office, it can be a problem to see the fruits of your labour: the web site's domain resolves to the external IP of the office, and can't be routed from inside. It's quite easy to overcome this problem, by using the 'view' facility of BIND to provide two different views of the domain: one for the office LAN, and one for the outside world.
An Introduction to Compression (May 2008)
An exploration of the different types of compression, looking at the workings of lossless compression methods such as RLE and Huffman encoding, and taking an overview of perceptive compression and why it works. If you've ever wondered how a CD can be shrunk down from 650MB of sound to 65MB, this article tells you how it's done.
Whitelisting SSH Access with OpenWRT (May 2008)
If you're tired of constant login attacks against your SSH server, you can use your OpenWRT router to implement a whitelisting firewall, allowing the people you know and trust to connect to your shell, and blocking everything else. It's even possible to automatically modify the whitelist from an intranet Web page, through the use of extensions to PHP; this article will show you how it's done.
Booting Linux from a USB Flash Drive (Oct 2007)
For those who build home theatre PCs and other computers which need to be quiet in operation, most of the noise from computer hardware can be eliminated: fans can be removed, heatsinks and smaller power supplies can be used. The largest remaining source of noise is the hard disk containing the operating system. If the HTPC is running Linux, it's possible to move that operating system from hard disk to a USB flash drive, and boot it from there; this article shows you how.
ARMv4/5 Opcode Map (Oct 2007)
There are many places in which you can look if you want an explanation of the instructions available on the ARM series of processor cores. However, there is no overview of the instruction set in the form of a table or map; not even the official ARM instruction reference provides this anywhere in its 811 pages. I produced an opcode map in 2006, in an attempt to rectify this problem: it provides a mapping of all the instructions and addressing modes for cores up to ARM version 4, with version 5 extensions highlighted in blue and the DSP extensions in green.
Tetris in Vanilla JavaScript (Oct 2007)
It's often said by some that JavaScript isn't a real programming language, that it can't provide the full range of development possibilities that a more complex language would be able to give. It's quite easy to prove this argument wrong: JavaScript is a full-blown language, with some very interesting features that conventional languages fail to bring to the table. It's also quite easy to write programs with, and I put this example together to prove the point: an implementation of Tetris in HTML and JavaScript, playable right in your browser.
Running a Windows Partition in VMWare (Jan 2007)
Virtualisation of operating systems is a big trend at the moment: running multiple servers on one physical box allows a hosting company to save space and power costs, and running different operating systems lets a Web developer test their work on various browsers and hosts. The problem with setting up a virtual machine is the loss of disk space on the host, to hold a disk image for the guest; what if you've already got an installation on another partition? This article shows how to use that physical installation in VMware, using the example of Linux as the host and Windows XP as the guest.
Trainfuck (Sep 2006)
One of the most widely-known esoteric programming languages is Brainf*ck, which attempts to break computing operations down into the simplest possible steps: just eight operations are provided, along with a small buffer of memory to work with. The problem with Brainf*ck is that it only provides the most basic I/O, interfacing with the console. Trainf*ck is an extension of the language, which endeavours to provide the ability to read and write files, and communicate over a TCP/IP network.
Collapsible Nested Lists in Vanilla JavaScript (Sep 2006)
Details regarding the implementation of a collapsible tree-style nested list using standards-compliant HTML and CSS, utilising JavaScript and the Document Object Model.
An Introduction to Bitwise Operators (Sep 2006)
For almost as long as the computer has existed, programmers and developers have had to deal with the computer's representation of numbers, the binary numbering system. The unique properties of binary allow the application of Boolean mathematics to common manipulations. This article provides a run-down of the common Boolean operations, including their syntax in C-derived programming languages, and provides examples of where such operations might be used in everyday development.
The Smallest Nintendo DS ROM (Sep 2006)
Embedded development is often focused on the size of the resultant binary, especially on platforms where this factor is important. On the Nintendo GBA and DS, the homebrew toolchain is able to generate well-optimised binaries, but programs with equivalent functionality tend to have very different sizes. This article looks into why that is the case, and explores the format of a Nintendo DS binary file in an attempt to make the smallest DS binary possible.


Longer-form articles released in serial format, as and when parts are completed.

GameBoy Emulation in JavaScript (Feb 2011)
JavaScript is often perceived as a Web scripting language, with a specialist purpose of manipulating HTML pages. JavaScript is, however, a general-purpose Turing-complete language: the best way to illustrate this is to emulate another system through JavaScript. In this series I explore how to build an interpretive emulator in JS, with the example of the GameBoy.
Let's Build a JPEG Decoder (May 2013)
The JPEG image format is a bit of a black box for many: files go in and images come out. Looking inside the box reveals a bunch of interesting algorithms and ideas, so writing a JPEG decoder makes for an interesting exercise.

Quick Hacks

Things which didn't make it to article length, or that don't need detailed exposition.

Wildcard Email Addresses with Self-Hosted Postfix (Feb 2024)
I've found it very useful over the years to be able to receive email to any address at my domain. This is a quick look at how Postfix can be configured to provide routing for wildcard addresses, so it all lands in the same inbox.
That Time My Encrypted RAID Failed (May 2015)
A short postmortem of the time my LUKS volume failed, what I did wrong at the time, and how I got the data back.
svn branchlist (Oct 2012)
Ever run into a codebase with multiple Subversion repositories, where you just wanted to find out which branch they were all on without tediously cd'ing into each working copy?
How Emulators Work (Jun 2012)
At deviantART's technology team meetup in France ('Breadlands 2012'), I gave a short Ignite talk distilling the first three articles in the Gameboy Emulation in Javascript. The slides from that talk are now available here. for irssi (Feb 2010)
The irssi IRC client has a built-in capability for rule-based highlighting of nicknames, but does not allow for the full line to be highlighted; nor does irssi allow arbitrary colours to be set against different rules. linecolor is an extension script for irssi that allows for this functionality to be added, in an intuitive fashion.
NotPDO for PHP (Feb 2009)
It doesn't happen very often, but it does happen: you're deploying a PDO-based PHP application to a shared host, and they don't run PDO. If you can't reconfigure the server, you can always wrap MySQL to look like PDO; that's what NotPDO does.
CRC32 Calculation in 256 Bytes (Feb 2009)
A quick look at a 256-byte program capable of calculating the CRC32 checksum of a file.
Countries and Dependent Territories (Dec 2008)
If you've ever needed to know which country is at UTC+3.5 (it's Iran), or who is responsible for administrating the Western Sahara (that's Morocco), it's all in here. List is also available in SQL, for such situations as a 'select your country' dropdown on an e-commerce Website.
Making PDO Look Like ADODB (Apr 2008)
Many developers who come to PHP from ASP bring their experience of using ActiveX Data Objects (ADO) to interface with databases; however, existing solutions to allow ADO usage from PHP suffer from performance and support issues. Using PHP's native Data Objects (PDO) library can be infeasible for legacy applications: with the code provided here, PDO can be used with no redevelopment of the application.
Virus Detection with Message Digests (Sep 2006)
One day in 2006, I was set a short challenge: write an article of around 500 words on the topic of MD5 digests. This article was the result: an explanation of what it means when a computer generates a digest of a message, and a look at where message digests can be used. In particular, focus is given to automatic generation of digests for executable files, and how this can be used to detect possible manipulations of the files by viruses.

Science Fiction

Short stories and flash fiction I've written in the sci-fi genre.

Ticketed (Mar 2017)
A long-awaited sequel to Prime Point, in which our brave protagonist finally jumps into a hyperspace-capable ship and ends up... somewhere.
Behind the Mirror (Jan 2012)
The day after the night before, a hungover flatmate notices that the wall mirror looks a bit strange. Speculative flash fiction.
Betel (Aug 2011)
Written on the theme of "thirty". On the far edge of the galaxy, a planet where only thirty stars are visible notices that one of the thirty has disappeared. Flash sci-fi.
The Harness (Feb 2011)
The tide of an interplanetary war is turned when a rogue black hole enters the solar system, and is captured by Earth forces. First published in IFWG Story Quest magazine, hard sci-fi.
Power (Nov 2010)
A spaceship crewman is faced with a Catch-22 while maintaining the engines. Flash sci-fi.
Light (May 2010)
A curious trespasser investigates the nuclear fallout zone around Cheyenne Mountain. First published in the My Writers Circle "Rascals" anthology; flash fiction.
New Science (Mar 2010)
Winning entry for a writing contest, with the length stipulation of exactly 100 words. First published by My Writers Circle; flash fiction.
Prime Point (Aug 2009)
A spacecraft is sent to the Earth-Sun L5 Lagrange point, where it undergoes testing. Vignette, sci-fi.
Highrise (Apr 2009)
A man is sealed into an apartment for four days. Short story, science-fiction.
Go Northeast (Apr 2009)
A man finds himself standing in an open field west of a white house, with a boarded front door. (There is a small mailbox here.) First published by; flash sci-fi.
Hideout (Sep 2006)
Two hackers must destroy their evidence when a team of armed police show up outside their apartment. Screenplay.
Thirteen (Sep 2006)
Terrorists use a distributed computer system to model the destruction of a continent by multiple warhead detonations. Book prologue.
Tau (Sep 2006)
A physics researcher is alerted to a contact who can help him realise his theories. Book prologue.
Microwave (Sep 2006)
Description of a system for generation and distribution of electrical power from orbiting nuclear power plants. Novel introduction.
Sand (Sep 2006)
A man reflects on the detonation of a compressed antimatter bomb in his city. Short story.
A Change of Clothing (Sep 2006)
A chase and murder by a trained serial killer, as described from the killer's point of view. Short story.