Category ArchiveCode

Code &JavaScript 19 Sep 2023 03:51 pm

Ordbogit App Mid-Mortem

I am currently in the process of developing an offline cross-platform version of Oqaasileriffik’s Greenlandic Dictionaries, ideally as an app. The concept is really simple: Take the existing 150 MiB SQLite database and bundle that as an app.

A year ago, I tried to use .NET MAUI, but that quickly proved feature anemic and buggy. I also looked at React Native and a few others. But in all of those frameworks, I ran into the same limitation: There is no way to just use a bundled read-only SQLite database. It has to be copied from the bundled resources into the app storage space, meaning it would exist on the device twice, and that was unacceptable to me.

Three weeks ago I was reminded of the project, and this time I started from scratch and tried working at it from the Progressive Web App (PWA) angle. I figured it was worth a shot to take the existing website and just let users run that offline. But again there was the quirk of how to get that 150 MiB of data to the user and persist it once and only once, ideally in a way that’s not in RAM all the time.

First I tried Dexie.js, an IndexedDB wrapper. Unfortunately this proved much too slow. Preloading files and inserting all the data into the database took 6 minutes on a beefy desktop computer. Turns out inserting into IndexedDB is really slow, even when doing bulk inserts, and when you’re inserting 3.3 million rows there is no way to overcome that. Could I reorganize the data so it’s fewer rows and differently indexed? Maybe, but that’s an absolutely last resort.

Next I tried Roy Hashimoto’s wa-sqlite. This was much faster, bringing insertion time down to 2m30s, despite still using IndexedDB as storage. But 2m30s on desktop translated to over 10 minutes on a fast mobile device, and that’s not acceptable.

I finally relented and tried caching the raw SQLite database and loading that with sql.js. I really didn’t want to do this as it requires keeping the whole 150 MiB database in RAM. Well, the result is that the PWA preloads and initializes in under 20 seconds from localhost. Naturally this will be slower over the internet, but this makes it network-bound instead of CPU-bound. It’s the same amount of data to transfer either way, and I guess 150 MiB isn’t much in this day and age.

C++ &Rants 15 Jun 2021 10:25 pm


I registered on Freenode on 2009-03-21 at 17:25:41 UTC, to participate in the Apertium channel #apertium. I also joined the C++ channel ##C++.

On 2011-06-29 at 11:06:39 UTC, I created ##C++-general with the blessing of the ##C++ operators. This quickly grew to be the 2nd largest C++ channel on Freenode, and indeed on any network at the time.

On 2015-04-15 at 13:32:10 UTC, I was granted operator status for the main ##C++ – the largest C++ channel on any IRC network at the time.

On 2021-05-19 at 07:54 UTC, this happened: ChanServ (ChanServ@services.) Quit (Killed (grumble (My fellow staff so-called 'friends' are about to hand over account data to a non-staff member. If you care about your data, drop your NickServ account NOW before that happens.)))

Immediately thereafter, I contacted my fellow Apertium PMC members so that we could prepare in case Freenode was actually taken over by non-free interests.

A few hours later, Freenode was taken over and most of the staff resigned. I got on as soon as it opened up and registered #Apertium, #C++, #C++-general, and #geordi.

On 2021-05-24, I applied for a Community Registration for the C++ channels on However, the C++ channels’ policy was to maintain both networks and not get involved with the politics of the situation.

On 2021-05-27, Apertium officially moved from Freenode to OFTC.

On 2021-06-14 at 21:37:09 UTC, Freenode intentionally split the network in two, leaving an old Freenode with existing channels and nicks, and a new Freenode with no registered channels or nicks.

On 2021-06-15 at 07:42:07 UTC, I joined the new Freenode and kicked everyone from ##C++-general with a message to go to

At 08:05:53 UTC, I kicked root and f from ##C++-general.

I was k-lined from the new Freenode on 2021-06-15 at 08:06 UTC.

At 09:13 UTC, I joined the old Freenode and kicked everyone from ##C++ and ##C++-general with a message to go to instead.

At 19:17 UTC, the remaining oper on old Freenode removed me from ##C++-general.

At 19:38 UTC, the old Freenode was shut down.

PHP 02 Feb 2018 10:02 pm

PHP Expand IPv4 to IPv6

Simple function for turning IPv6 and IPv4 into a blob that’s suitable for SQL type binary(16). This maps IPv4 to the IPv6 address space reserved for them.

function ip2binary($ip) {
	$rv = inet_pton($ip);
	if (strlen($rv) == 4) {
		$rv = inet_pton('::ffff:'.$ip);
	return $rv;

Code &Random 06 Jan 2014 03:53 pm

The Competency Matrix and Me

I recently stumbled upon the well known Programmer Competency Matrix again, so I figured this time I’d store where I think I fit on it. I’ll use the linear 0-3 scale, since that’s easier for the in-between values.

Continue Reading »

PHP 26 Apr 2012 05:00 pm

I Like PHP

While there is no doubt PHP is broken beyond repair, it does have a few virtues that keeps it as one of my first choices when writing certain kind of web frontends and minor tools.

There is a huge laundry list of how PHP is broken at “PHP a fractal of bad design“, which I almost entirely agree with. What I will do here is point out the few things on that list that I do not agree with, and why.

Continue Reading »

Next Page »