More from Making software better without sacrificing user experience.
Bringing dwm Shortcuts to GNOME 2023-11-02 The dwm window manager is my standard "go-to" for most of my personal laptop environments. For desktops with larger, higher resolution monitors I tend to lean towards using GNOME. The GNOME DE is fairly solid for my own purposes. This article isn't going to deep dive into GNOME itself, but instead highlight some minor configuration changes I make to mimic a few dwm shortcuts. For reference, I'm running GNOME 45.0 on Ubuntu 23.10 Setting Up Fixed Workspaces When I use dwm I tend to have a hard-set amount of tags to cycle through (normally 4-5). Unfortunately, dynamic rendering is the default for workspaces (ie. tags) in GNOME. For my personal preference I set this setting to fixed. We can achieve this by opening Settings > Multitasking and selecting "Fixed number of workspaces". Screenshot of GNOME's Multitasking Settings GUI Setting Our Keybindings Now all that is left is to mimic dwm keyboard shortcuts, in this case: ALT + $num for switching between workspaces and ALT + SHIFT + $num for moving windows across workspaces. These keyboard shortcuts can be altered under Settings > Keyboard > View and Customize Shortcuts > Navigation. You'll want to make edits to both the "Switch to workspace n" and "Move window to workspace n". Screenshot of GNOME's keyboard shortcut GUI: switch to workspace Screenshot of GNOME's keyboard shortcut GUI: move window to workspace That's it. You're free to include even more custom keyboard shortcuts (open web browser, lock screen, hibernate, etc.) but this is a solid starting point. Enjoy tweaking GNOME!
Installing Older Versions of MongoDB on Arch Linux 2023-09-11 I've recently been using Arch Linux for my main work environment on my ThinkPad X260. It's been great. As someone who is constantly drawn to minimalist operating systems such as Alpine or OpenBSD, it's nice to use something like Arch that boasts that same minimalist approach but with greater documentation/support. Another major reason for the switch was the need to run older versions of "services" locally. Most people would simply suggest using Docker or vmm, but I personally run projects in self-contained, personalized directories on my system itself. I am aware of the irony in that statement... but that's just my personal preference. So I thought I would share my process of setting up an older version of MongoDB (3.4 to be precise) on Arch Linux. AUR to the Rescue You will need to target the specific version of MongoDB using the very awesome AUR packages: yay -S mongodb34-bin Follow the instructions and you'll be good to go. Don't forget to create the /data/db directory and give it proper permissions: mkdir -p /data/db/ chmod -R 777 /date/db What About My "Tools"? If you plan to use MongoDB, then you most likely want to utilize the core database tools (restore, dump, etc). The problem is you can't use the default mongodb-tools package when trying to work with older versions of MongoDB itself. The package will complain about conflicts and ask you to override your existing version. This is not what we want. So, you'll have to build from source locally: git clone https://github.com/mongodb/mongo-tools cd mongodb-tools ./make build Then you'll need to copy the built executables into the proper directory in order to use them from the terminal: cp bin/* /usr/local/bin/ And that's it! Now you can run mongod directly or use systemctl to enable it by default. Hopefully this helps anyone else curious about running older (or even outdated!) versions of MongoDB.
Converting HEIF Images with macOS Automator 2023-07-21 Often times when you save or export photos from iOS to iCloud they often render themselves into heif or heic formats. Both macOS and iOS have no problem working with these formats, but a lot of software programs will not even recognize these filetypes. The obvious step would just be to convert them via an application or online service, right? Not so fast! Wouldn't it be much cleaner if we could simply right-click our heif or heic files and convert them directly in Finder? Well, I've got some good news for you... Basic Requirements You will need to have Homebrew installed You will need to install the libheif package through Homebrew: brew install libheif Creating our custom Automator script For this example script we are going to convert the image to JPG format. You can freely change this to whatever format you wish (PNG, TIFF, etc.). We're just keeping things basic for this tutorial. Don't worry if you've never worked with Automator before because setting things up is incredibly simple. Open the macOS Automator from the Applications folder Select Quick Option from the first prompt Set "Workflow receives current" to image files Set the label "in" to Finder From the left pane, select "Library > Utilities" From the presented choices in the next pane, drag and drop Run Shell Script into the far right pane Set the area "Pass input" to as arguments Enter the following code below as your script and type ⌘-S to save (name it something like "Convert HEIC/HEIF to JPG") for f in "$@" do /opt/homebrew/bin/heif-convert "$f" "${f%.*}.jpg" done Making Edits If you ever have the need to edit this script (for example, changing the default format to png), you will need to navigate to your ~/Library/Services folder and open your custom heif Quick Action in the Automator application. Simple as that. Happy converting! If you're interested, I also have some other Automator scripts available: Batch Converting Images to webp with macOS Automator Convert Files to HTML with macOS Automator Quick Actions
Running VSCode in Chromium on OpenBSD 2023-06-05 VSCode and its many variations are not available on OpenBSD. This doesn't cause issue with many OpenBSD users, but those making the jump from Linux might miss access to such a popular editor. Lucky for us, there is a hacky workaround to solve this problem. VSCode in the Browser I tried my best to build something like code-server locally and run that directly in my browser - but I failed miserably. Instead, I fell back on vscode.dev which is essentially a remote version of code-server. Getting things to work seamlessly proved a little more challenging. I found the best performance was running everything through Chromium with special parameters enabled on launch. Note: The following assumes you have already installed chromium First we need to disable unveil for Chromium. This will allow us to access our system files through vscode.dev using the "Open folder..." or "Open file..." commands without issue: chrome --disable-unveil Everything should work pretty solid right out the box now - except it doesn't. Syntax highlighting does not work without enabling WASM/WebAssembly. Your experience might be different, but I had to include the following when launching Chromium from the terminal: ENABLE_WASM=1 chrome --enable-wasm Success! We can avoid typing out these complex commands everytime we want to launch our editor by setting up an alias (in my case via .zshrc): alias vscode="ENABLE_WASM=1 chrome --enable-wasm --disable-unveil" That's it! Now I can just pop open VSCode on OpenBSD by simply running vscode in my terminal. Hopefully this can help others slowly transition over to OpenBSD - which you should do because it is amazing!
Converting My X201 ThinkPad into a Slabtop 2023-05-01 I recently wrote about physically disabling the WiFi toggle switch on my X201 which was a fun "hack" to an annoying issue I was running into. Since then, the laptop has been running flawlessly. The only other minor issue I had was the poor display quality. The screen works perfectly fine but the X201's age prevents it from being the best possible display for day-to-day tasks. Both the resolution and viewing angles are quite poor. So, what were my options to remedy this problem? Swap out and upgrade the laptop's display (not many options for this though) Connect an external display, keyboard, mouse and dock the X201 Something else? Looking into "Something Else" I found that the possible replacement screens weren't worth the cost/hassle to swap out. And setting the laptop aside, docked with external peripherals sounded fine in theory - but then I would be missing out on the X201's amazing classic keyboard... Then I thought to myself, "Why not just remove the display entirely?" So that's what I did. The X201 display (still inside the top lid) disconnected from the body of the laptop. Removing the entire top lid was easier than I initially thought it would be. The beautiful thing about these older, classic ThinkPads is the ability to completely dissemble them. I won't go into heavy details on how to take one of these machines apart, since great documentation already exists. But once you have the keyboard and hinge screws removed it is essentially as easy as lifting the lid out of the chassis. (After disconnecting the small display connectors, of course) Ditching Alpine for Debian I love Alpine Linux. It's normally my go-to distro (paired with dwm) for most of my laptop devices. Unfortunately, I find tiling window managers a slight pain to use on larger, 4K displays. I also wanted this slabtop to "just work", instead of needing to fiddle around with WiFi, xrandr, audio etc. Not to mention that Debian is rock solid stable. Defaulting to the XFCE DE was a no-brainer as well since this device is somewhat old. The X201 "slabtop" connected to my 27" 4K monitor via the ThinkPad UltraDock. Closing Thoughts This slabtop gives me those old-school "Commodore64" vibes (or more recent devices like the Raspberry Pi 400). This setup certainly isn't for everyone but for my use case it's working well. Traveling with a machine like this might prove a little more challenging - although you could simply pair it with a smaller travel monitor (I'm sure the overall carrying weight would be similar to the standard X201). If nothing else, it is good to keep this option in mind if you ever break your laptop's display and don't feel like spending the money to fix it. Just grab an external monitor you have laying around and make a slabtop!
More in programming
Last week, I released version 5.2.0 of RestAssured.Net. It contains fixes for no less than 23 issues, the largest number of bug fixes in a single release by a long margin. All 23 bugs were found and fixed by Claude, under my strict supervision. I will describe the process I used to find and fix the issues in more detail in an upcoming newsletter issue, but I think it could be useful to give a short overview of all the fixes in 5.2.0 beyond what’s in the CHANGELOG, so here goes. Sending requests Requests without a body no longer send a JSON content type (#161) GET, DELETE and HEAD requests (and any other request without a body) used to be sent with Content-Type: application/json and an empty body, which some servers, gateways and firewalls reject. Requests without a body are now sent without one, so what goes over the wire is what you wrote in your test. Values in the request now take precedence over the request specification (#153, #179) When a header, content type or other setting was set both in a RequestSpecification and in the request itself, the specification won. It’s now the other way around: a specification provides defaults, and the request can always override them. The path in a base URI is no longer dropped (#160) WithBaseUri("http://host/api") silently ignored the /api part, so requests went to the wrong path. The path is now included, and the BaseUri property of the specification shows the URI you configured. Relative endpoints with a query string are sent to the right path (#159) With a request specification, Get("/users?id=1") was sent to /users%3Fid=1, because the question mark was encoded as part of the path. The query string is now sent as a query string. Trailing slashes in endpoints are kept (#172) With a request specification, Get("/users/") was sent to /users. Some APIs treat these as different resources, so the slash is now kept. Collections in query parameters send their values (#167) Passing a list as a query parameter value sent the name of the collection type (System.Collections.Generic.List...) instead of its contents. Each value is now sent as a separate parameter, for example ?id=1&id=2. Square brackets that aren’t path parameters are left alone (#154) Any text between square brackets in an endpoint, such as filter[name]=x, was treated as a path parameter placeholder. Only placeholders for path parameters you actually supplied are replaced now, and their values are no longer HTML-encoded. Basic authentication supports non-ASCII characters (#168) Credentials were encoded as ASCII, so characters like ü or € were sent as ? and authentication failed. Credentials are now encoded as UTF-8. Your own cookies are no longer modified (#175, #183) A Cookie object passed to a request was changed while the request was sent: its domain was set to the request host. A cookie reused for another host then silently wasn’t sent. RestAssured.Net now works on a copy, and request cookies are logged with the domain they’re actually sent for. Using your own HttpClient Timeouts, cookies and other settings now work with your own HttpClient (#156) When you passed your own HttpClient, timeouts and cookies were silently ignored, and setting a timeout could even crash on a client that had already been used. Timeouts and cookies now work without changing your client. Proxy, SSL and NTLM settings can’t be applied to a client you created yourself, so setting them on the request now throws a clear exception instead of being ignored; settings from a specification or the global configuration log a warning. Verifying and extracting responses Cookie checks only pass for cookies the server actually set (#155) The cookies you sent with the request were mixed with the cookies in the response, so verifying or extracting a cookie could pass even when the server never set it. Only cookies set by the server are seen as response cookies now. All response headers can be verified and extracted (#162) Headers that describe the body, such as Content-Disposition, Content-Type and Last-Modified, couldn’t be found with Header(), because .NET stores them separately. Header() now finds every header in the response. XML and HTML assertions work the same on every machine (#163) A value like 1.5 in an XML or HTML body was read using the language settings of the machine, so on a Dutch or German machine it became 15 and assertions failed. Values are now always read the same way, regardless of the machine’s culture. Response body length is measured in bytes (#169) ResponseBodyLength() was documented as counting bytes, but counted characters, which differs for bodies with non-ASCII characters. It now counts bytes, so the value matches the Content-Length header. Square brackets in custom error messages are kept (#170) Custom error messages treated any text in square brackets as a template tag, so a message like [TICKET-123] status was [actual] lost its ticket reference. Only [expected] and [actual] are replaced now; all other text stays as you wrote it. Errors keep their original cause (#165) When a request failed, for example because the connection was refused or the certificate was invalid, the original exception was thrown away and every error was reported as “Unhandled exception”. The original exception is now kept as the inner exception, which makes failures in CI much easier to diagnose. Logging Masking sensitive data can no longer be bypassed (#158) Headers and cookies configured as sensitive could still end up in the logs, for example when the casing of the header name differed, or as part of a Cookie or Set-Cookie header. Sensitive values are now masked in all of these cases. Logging no longer crashes on invalid JSON or XML (#157) With body logging enabled, a response labeled as JSON or XML that wasn’t valid (an HTML error page from a gateway, for example) made the request fail. Bodies that can’t be parsed are now logged as they are. All content headers are logged (#185) Only Content-Type and Content-Length were logged from the headers that describe the body, so headers like Content-Disposition and Content-Encoding were missing from the log. All of them are logged now, and they can be masked like any other header. Response times are logged the same way everywhere (#182) The response time in the log used the decimal separator of the machine’s culture, for example 3,75 ms on a Dutch machine. It’s now always logged with a period, so logs look the same on every machine. The logger is only called when there’s something to log (#174) With logging switched off, a custom logger was still called twice per request, with empty messages. It’s now only called when there is actually something to log. As you can see from the list above, RestAssured.Net just got a lot better and/or more consistent and/or more compliant with documented HTTP behaviour with version 5.2.0. There are still quite a few open issues, but I decided to leave those for the next release, which hopefully sees the light of day in the next few weeks.
A former Amazon engineer sees signs that the ‘six-pager’ documents used to promote good decision making are increasingly AI-generated and AI-read, and warns it’s not a positive development.
In October 2026 Jenni was acquired by Digital Science. A personal reflection on four years as founding designer, from $4k to $730k in monthly revenue.
In 1978, the ACM published an algorithm by Robert Morris for counting large numbers of events in small registers. It uses one byte to keep track of the approximate logarithm of the count, and randomly increments the logarithm with a probability that scales with the value of the count. You can tune the range and precision of the counter by adjusting the base of the logarithm. Morris suggests pre-calculating a table of probabilities so that no difficult calculations are needed at runtime. Recently I learned from emsenn about a 2009 paper by Miklós Csűrös titled approximate counting with a floating-point counter. It changes Morris’s algorithm to use a binary log-linear counter instead of a pure logarithm. It reminded me of my hg64 log-linear histograms, so I thought it would be fun to implement, especially since the algorithm can be made shorter and faster. representing a counter We need to choose the number of bits to use for the exponent and mantissa of each approximate floating point counter. Typically the exponent will be 5 or 6 bits, corresponding to an unpacked exact counter of 32 or 64 bits. The mantissa will typically be the rest of an 8 or 16 bit integer (though languages such as Zig and C23 allow more adventurous integer sizes). I’ll call the approximate counter type usmol and the unpacked counter type ubig. #define EXPBITS 5 #define SIGBITS 3 typedef unsigned _BitInt(EXPBITS+SIGBITS) usmol; typedef uint32_t ubig; static_assert(sizeof(ubig) * 8 == 1 << EXPBITS, "ubig must match EXPBITS"); It’s straightforward to extract the exponent and mantissa from a usmol counter. Unpacking a usmol into a ubig is slightly tricky. Like hg64 and IEEE754, normal numbers (with a nonzero exponent) have an implicit leading bit, and denormal numbers (exponent is zero) do not. The effect is that small counts are represented exactly in a usmol (up to 2*MANTISSA, covering denormal numbers and exponent == 1), and larger counts are shifted by the exponent. (I don’t need the inverse conversion here, but it is used by hg64 to map a sample to a histogram bucket, truncating the value by shifting right.) #define MANTISSA (1 << SIGBITS) static inline ubig exponent(usmol approx) { return(ubig)(approx / MANTISSA); } static inline ubig mantissa(usmol approx) { return(ubig)(approx % MANTISSA); } static inline ubig unpack(usmol approx) { ubig e = exponent(approx) - 1; ubig m = mantissa(approx) | MANTISSA; return(approx < MANTISSA ? approx : m << e); } bumping a counter Because binary floating point uses logarithms in base 2, we need the probability of incrementing the counter to scale with 2^-e. Specifically, we want the probability of increasing the counter to be 100% when its exponent is 0 or 1, 50% when the exponent is 2, 25% when it is 3, etc. Csűrös does this by getting a random bit e times in a loop and incrementing the counter if they are all zero. A more efficient way to do this on a computer is to get a ubig word full of random bits and count the leading or trailing zeroes. There are a variety of bit scan functions that differ in how they number bits and what they do when the word is entirely zero. The POSIX ffs() family has the advantage of no undefined behaviour, but it weirdly counts from one. However this oddity turns out to match the way denormal numbers give our exponent an off-by-one bias. So for instance, when our exponent is 2 and we want a 50% probability, we want ffs() to return 2 or more. OK, that determines when to increment the mantissa given a particular exponent. But how does the exponent get incremented? Like Csűrös, we put the exponent immediately to the left of the mantissa; when the mantissa overflows, it rolls over to zero and the exponent ticks up. No special cases are needed. The resulting code is short: usmol bump(rng_t *rng, usmol approx) { ubig r = ubig_random(rng); ubig z = (ubig)ffsll((long long)r); ubig e = exponent(approx); return(approx + (z >= e)); } considerations Morris allows you to smoothly tune the allowable range and precision of a counter by adjusting the base of the logarithm. By contrast, Csűrös has very lumpy 2^2^n choice of ranges; that isn’t necessarily bad because it’s normal for programmers to have to choose between uint32_t and uint64_t. Morris uses a lookup table to determine the probability of incrementing, which is tolerable for an 8 bit counter, but it can get large for wider counters. Csűrös just uses a few instructions and bigger counters don’t need much more. So I don’t think either algorithm is clearly better than the other, except that Csűrös has the winning fun factor of bithacking a bespoke floating point format.
Parallelize discovery and execution, but serialize judgement.