Posts
Zig and wasm on the command line
Having just read a short post on compiling zig into WASM, I figured I’d attempt the same. Alas, I didn’t find the instructions particularly clear.
First, write a function in zig.
// main.zig export fn addInc(a: i32, b: i32) i32 { return a + inc(b); } extern fn inc(a: i32) i32; now, we compile it:
zig build-lib main.zig -target wasm32-freestanding -dynamic -OReleaseSafe to produce main.wasm.
Let’s wrap this in a script to run it with node:
Posts
Litestream, sqlite3 and Rails
Using litestream to deliver robust web app hosting with the performance of embedded sqlite3 seems to be the hot thing right now. It makes sense: for most apps we build today sqlite with backups will perform as well or better than an isolated database like mysql or postgres. The secret is in the fact that the network overhead for each sql query is zero. With sqlite, the database is accesses directly in process.
Posts
Simulating bingo for fun
The other day, I was playing bingo with the family. The rules are simple, each person has a 5x5 card with the center number “free”. You pick numbers from 1 to 75 without replacement until some matches 5 in a row on their card (diagonal matches are allowed).
Playing with young kids, I knew there was a clock ticking on how long their attention would last. We had three bingo cards going.
Posts
fzf and jq for fun and profit
I'm a casual vim user (mainly nvim these days). One plugin for vim I find essential is fzf to quickly find any file in my current project.
Recently, I was debugging a graphql query and I needed to search a JSON file for a snippet of text. Alas, the JSON was on a single line and on a remote server. After a quick search, I found this magic command line to format the JSON file and preview the result:
Posts
One day in Paris
Solution to visit metro stations Here is a quick look at my solution to visit all the metro stations in Paris in one day. The trip start with Château de Vincennes on the east side of the map (start of the line 1). Route time: 830 minutes. For now, this does not display the route with backtracing. Instead, it assumes you'll choose your own shortest path back to the next step on the journey.
Posts
Grouping javascript files with Rails 7 Import Maps
Rails 7 introduced import maps as the new default way to manager javascript. To quote the readme from importmap-rails: Import maps let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. So you can build modern JavaScript applications using JavaScript libraries made for ES modules (ESM) without the need for transpiling or bundling. This frees you from needing Webpack, Yarn, npm, or any other part of the JavaScript toolchain.
Posts
Rails Active Storage with Backblaze B2
I wanted to use Blackblaze's B2 service to host uploads for this site using Active Storage. I wrote this up when I couldn't find a guide to configure the two to work together. B2 advertises itself as the most affordable cloud bucket storage. 🤞 here's to hoping it remains competitively priced. Rails 5.2 introduced Active Storage, a simple way to add attachments in your Rails applications. Rails 6 introduce Action Text with simple built-in rich text editing experience.