Welcome to nickb.dev, a blog by Nick Babcock! Below are my most recent articles. You can find the history of all my writings in the archive or just find out more about me.


Simulating the EU4 map in the browser with WebGL

There are several ways one can replicate EU4’s map. The most popular methods have been to either create a bitmap image and suffer from scaling issues or derive a bitmap tracing routine to convert into vector graphics. However to create the most realstic and performant render, one should turn to the GPU. I talk about how we accomplished this in Rakaly.

Read more...


Git Rebase to Squash Commits to Most Recent Message

You’ve been working on a development branch over a couple days, testing things out and exploring solutions. You aren’t comfortable losing work, so you create superficial commits. Your final commit on this branch is a beautifully worded message. But something is wrong. The commits with superficial messages are still present. So how do you squash several commits into one and take the most recent commit message? Solution within.

Read more...


Wasm and Native Node Module Performance Comparison

Deploying code via Wasm is convenient as one can run the same code in the browser, nodejs, or via one of the several Wasm runtimes. What, if any, performance is sacrificed for this convenience? I demonstrate the tradeoffs in a real world example where I can take Rust code and benchmark the performance difference between running it as a node native module and Wasm compiled under varying configurations.

Read more...


Stumbling with WebGL Image Processing

I’ve tried to learn WebGL to reimplement an image processing pipeline that I have setup on the CPU that involves indexed colors, edge detection, pixel-art upscaling, and more but the steep learning curve combined with other life changes has caused me to temporarily abandon the effort. I thought I’d document my thoughts so that I have a point of reference when explaining to others.

Read more...


Cargo Workspace and the Feature Unification Pitfall

In Rust, workspaces help organize a project into smaller packages. The downside is if there are shared dependencies that list different features, then one will most likely see unexpected behavior when compiling just a single package. This post shows an example of when this can occur and what solutions exist.

Read more...


Leveraging Rust to Bundle Node Native Modules and Wasm into an Isomorphic NPM Package

I recently published highwayhasher as an npm package. It exposes Google’s HighwayHash to the JS world through the pure Rust reimplementation. Browsers will use the Wasm implementation while nodejs installations will use native modules built against hardware intrinsics. Both implementations expose the same API so clients don’t need to worry about which implementation is selected.

Read more...


Writing a Secure Systemd Service with Sandboxing and Dynamic Users

This post will walk one through a real world migration on how to apply the principle of minimal privilege to a systemd service. This is accomplished by extracting sensitive configuration fields into an environment file, templating the config, running the service as a dynamic user, and sandboxing the application with systemd primitives.

Read more...


A Quick Tour of Trade-offs Embedding Data in Rust

Embedding data in Rust code can be good idea so one doesn’t worry about acquiring the data at runtime. However, how one goes about bundling data in the application can have a significant impact on compile times, code size, and runtime performance.

Read more...


Designing a Decaying Leaderboard with Redis

The EU4 achievement leaderboard and save file analyzer, Rakaly, has several requirements when it comes to maintaining the leaderboard. One of these requirements is to have current leaderboard submission decay overtime as EU4 receives updates. Redis has tools builtin to cater to this use case

Read more...


Results of Authoring a JS Library with Rust and Wasm

I recently overhauled a JS parsing library to delegate to the Rust implementation via Wasm. The result to users is seamless as the small Wasm bundled is inlined in the library as base64 encoded. Along the way, I saw that parsing can be much faster than object creation.

Read more...