January 3, 2018

JavaScript asynchronous functions and error handling

Filed under: Technical — Tags: , — James Bunton @ 9:37 pm

What is asynchronous I/O?

The web services I build spend most of their time doing one of these two classes of things:

  • Processing – Burning CPU cycles calculating things. For example JSON parsing, HTML rendering, image processing, etc.
  • I/O – Waiting for some event external to the CPU/RAM system to finish. For example an HTTP request or DNS request.

(more…)

August 1, 2016

docker-cleanup to garbage collect old images

Filed under: Technical — Tags: , , , — James Bunton @ 12:00 am

Docker is a very useful containerisation platform. I use it so much that I regularly fill up /var/lib/docker with old images and get out of disk space errors. Unfortunately Docker has no automatic garbage collection mechanism to clean up unused images. I wrote a simple shell script which I run from time to time.

(more…)

July 14, 2016

Understanding ‘this’ in JavaScript

Filed under: Technical — Tags: , , — James Bunton @ 10:27 pm

I believe the behaviour of the this keyword in JavaScript is one of the most confusing and poorly thought out parts of the language. If you understand how objects and classes work in some other language, but don’t understand why JavaScript behaves weirdly, this blog aims to help you out. By the end you’ll understand how this works and how to make it work for you.

(more…)

March 18, 2016

Safe bash scripting: ‘set -e’ is not enough!

Filed under: Rants,Technical — Tags: , — James Bunton @ 10:53 pm

I know, I know, shell scripting is a bad way to write software. I’ve always had a bit of a soft spot for bash though. Sure there are plenty of gotchas in bash scripting, but isn’t that the case for every programming language?

(more…)

September 1, 2014

Don’t trust the query planner!

Filed under: Technical — Tags: , , — James Bunton @ 12:00 am

This is an experiment in cross-posting something from my internal blog with my employer Atlassian. I thought it may be be of general interest so I’ve edited it a bit and shared it here.

We recently did a regular zero downtime upgrade of our order processing system. This is a fairly routine event, we use Bamboo deployments to push from git master to our dev, staging and then production environments every day. The vast majority of these upgrades go smoothly without serious regressions or problems. On this particular day the application did not come back properly, we had an outage! We treat these very seriously because the ordering system is a big monolithic do-all-the-things type of application. An outage means customers cannot make new purchases, view their license keys, sign up for OnDemand, view prices on Marketplace and many other things.

(more…)

July 25, 2014

Introduction to the Linux Wireless Subsystem

Filed under: Technical — Tags: , , , — 7:26 pm

Guest post by lemnisca.

I’ve recently started getting into Linux wireless programming for work. I am a fairly experienced C programmer but don’t know much about kernel development so this is a new adventure for me. What I found was that while there is a lot of information available about how it all works — indeed, since it’s open source, one can at least in theory have complete information about the functioning of the system — there is not much in the way of an introduction. There’s no broad explanation of how it all works for someone completely new to the system. The documentation that does exist is largely focused on documenting individual functions, structs, etc. and is more of a reference for those already familiar with the system. I quickly found myself lost in a sea of source code, chasing down chains of function calls with no real feel for how the whole thing is put together. So I’ve decided to share what I’ve learnt, in the hopes that it might help someone else in the future.

(more…)

June 13, 2011

Challenge: Fastest ‘atoi’ Implementation

Filed under: Technical — Tags: , — James Bunton @ 6:22 pm

At work recently I was writing some code that needs to parse very large input files consisting of decimal numbers. These need to be converted to binary. My first attempt at doing this with boost::lexical_cast() was laughably slow, so I did some experiments to see how fast I could get it.

(more…)