Avoid Integer for File Sizes in Postgres

Here’s a small bug we recently encountered in production. Occasionally, PDF generation jobs would fail, and the cause turned out to be a small oversight when designing database tables.

The PDF metadata is stored in a table, and the column for file size was defined as integer, also known as int4.

Since this data type is signed in Postgres, those 4 bytes only allow for files up to 2.1 GB (2_147_483_647 bytes). You might think, 2^31 bytes ought to be enough for everybody … except apparently for our PDFs.

Code Golfing Leap Years in Ruby

A work buddy challenged me to a bit of Ruby code golfing.

Write a program to print all leap years from 1800 up to and including 2400.

The website he got the challenge from (https://code.golf/leap-years#ruby) has a neat feature: it can run your code and verify whether the output matches the expected result.

I’m usually not much of a code golfer, I generally prefer writing code that’s performant and readable rather than short and cryptic, but this turned out to be a fun little challenge and even somewhat educational.

Pimiga 4 on Raspberry Pi 5

I got myself a Raspberry Pi 5 with the intent of using it for Amiga emulation. There are several images floating around on the internet that bundle Amiga software.

The most comprehensive page I found is https://amigang.com/software-pii/ on AmigaNG.

I tried the Pimiga 4 image (PIMIGA_ARM.7z, md5sum 34ff61d2fd58e70b8109312b1a9202a9) but it turned out that the bundled kernel is too old for this board. Running this image results in the following kernel panics:

Kernel panic - not syncing: Asynchronous SError Interrupt
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rpi8-rpi-2712 #1 Debian 1:6.1.73-1+rpt1
Hardware name: Raspberry Pi 5 Model B Rev 1.1 (DT)

I copied the files from a bookworm Raspberry Pi OS to the boot partition of the Pimiga image, only preserving the cmdline.txt for booting the correct partition.

Simulating candle flickering with a simple RNG

While preparing to attach the electrical candles to the christmas tree, a question popped into my mind.

There are electrical candles that simulate the flickering of real candles. How complex would an algorithm have to be to be convincing?

I wrote a quick proof of concept in Ruby for a script running in the terminal which just randomly chooses a grey value to display.