Sometimes it’s useful to represent all the odd keys on a Mac OS keyboard with their proper glyphs in a textual conversation. There’s various ways to do that but honestly the easiest for me is just to search for a web page that contains the right glyphs and copy-paste them into the chat. Recently I’ve found that becoming less effective, requiring several different searches before finally finding a good page, so I’m recording them here where I can find them more easily.| David Turner says…
Bisection is a mightily effective technique for debugging those tricky issues that were quietly introduced into a codebase and not noticed for an extended period of time. You can find the first bad commit from a range of thousands (or more) in a logarithmic number of steps via a binary search, halving the range of possible bad commits on each step.| David Turner says…
The Doomsday rule is an algorithm for working out the day of the week of a given date. It’s based on John Conway’s observation that certain memorable dates called doomsdays (4/4, 6/6, 8/8, 10/10, 12/12, 9/5, 5/9, 7/11, 11/7, …) always occur on the same day of the week in any given year. This day is known as the year’s anchor day. To compute an arbitary day of week you work out the anchor day for the given year and the offset between the target date and an appropriate doomsday. It’s ...| David Turner says…
Back in August 2014 a user reported they couldn’t run Elasticsearch: it would immediately crash with a segmentation fault. Elasticsearch is almost entirely written in Java which as a managed language is supposed to protect us from low-level issues like segmentation faults. The “almost” in the previous sentence is the problem: Elasticsearch calls out to native code in a few places, and it was one of these places that was triggering the crash.| David Turner says…
If you are suffering from more than your fair share of silent corruption then you might have a buggy storage system. Here’s a couple of tools that exercise your storage with workloads that are simple and transparent whilst also being quite effective at triggering corruption bugs.| David Turner says…
100% reliable data storage is fundamentally impossible, but we can get pretty close with layers of protection against something going wrong at the physical level. Databases are typically agnostic to the specific protections that any given installation is using and mostly just assume that the data they read from disk is the data they wrote there previously. The protections might be in the filesystem itself but it’s more usual to push them down to the lower layers of RAID controllers and driv...| David Turner says…
I sometimes have a need to collect a packet capture for an extended period of time. On a busy host this can generate enough data that it needs some special handling. In particular it’s useful to roll over to a new file every now and then, and to offload the completed files somewhere else so they don’t fill up the disk.| David Turner says…
I recently came across a video from Zach Star which posed the question of telling the time on a clock whose two hands are identical lengths. This seems like a fairly well-known puzzle and it’s kinda entertaining to work out when you can and cannot tell the time on such a clock. Then I wondered what would happen if you added a second (i.e. third) hand which is also indistinguishable from the other two hands.| David Turner says…
Here’s an example of the sort of thing you can do with local-universal time diagrams. Suppose you have some data about events that occurred at particular times in a system, such as log messages. You want to calculate some aggregate statistics about its behaviour over time. For instance you might want to aggregate all the events from 00:00 to 03:00 together, and then all the events from 03:00 until 06:00, and so on for every 3-hour window in the day.| David Turner says…
The AVR series of microcontrollers are wonderful little devices with surprisingly many features built-in. The ATMega328P model sits at the heart of the famous Arduino Uno boards, and much of the useful functionality available on an Arduino actually comes directly from the microcontroller. The Arduino board adds handy things like USB support and compatibility with lots of add-on peripherals, but they’re expensive enough to make me think twice before hard-wiring them into something that just ...| David Turner says…
Github Pages| David Turner says…
One of my colleagues was recently looking at some date-based calculations that needed to know whether a year is a leap year or not, on the hot path, and he found an 8% speed improvement by reworking the leap year predicate a bit. The JVM compiles this down to a few fast integer operations, avoiding slow things like division entirely. I thought it’d be interesting to dig into how to calculate the leap year predicate without division.| David Turner says…