Programming Leftovers
-
Rails Form Redirect Not Rendering HTML
What I discovered was all of the problems were with three forms that were supposed to be redirecting to the page that shows a user: login, sign up, and edit profile. Each of these forms were just HTML requests, but Turbo Drive takes over and submits all of these forms as the format TURBO_STREAM. In this case I had two views for the users/show page: show.html.erb and show.turbo_stream.erb. At some point in those aforementioned upgrades to Rails/Turbo had become more strict and no longer understood these basic form-redirects as HTML formats. TURBO_STREAM in, TURBO_STREAM out.
The first step was to rediscover how to write browser tests. This is because my past self incessantly reminds me to find bugs once.
-
Why does 0.1 + 0.2 = 0.30000000000000004?
I realized that I didn’t understand exactly how it worked. I mean, I know floating point calculations are inexact, and I know that you can’t exactly represent 0.1 in binary, but: there’s a floating point number that’s closer to 0.3 than 0.30000000000000004! So why do we get the answer 0.30000000000000004?
-
Optimising an eBPF Optimiser with Prodfiler (Repost)
In this post I will walk through how we can use Prodfiler to unearth areas for optimisation in K2 (paper, video), an optimising compiler for eBPF. K2 is entirely CPU bound and uses a guided search technique that relies on the ability to create and check candidate solutions at high speed. With Prodfiler we can easily discover which components of K2 consume the most CPU cycles, allowing us to optimise them accordingly. The end result is a version of K2 that is 1.4x-1.9x faster, meaning it can explore a significantly larger search space given the same resources.
-
Index Merges vs Composite Indexes in Postgres and MySQL
Having a composite index is faster, but how much faster than the two individual indexes? Let’s do the napkin math, and then test it in PostgreSQL and MySQL.
-
Announcing avtr.dev
On Thursday, Aaron noted an idea for a service that would, given a URL, return the profile photo associated with the h-card on that URL. I found the idea intriguing, noting my interest in building it. I agreed that it would be great to have an API to call to retrieve a photo, similar to Gravatar but using h-cards.
-
Andreas Schneider: Sliced bread: git-worktree and bare repo
The git versioning system has two really nice features you might already heard about. One of them is git-worktree and the other are bare git repositories. This makes my life a lot easier working on Samba as often I have several feature branches I’m working on. Some features often take several month to finish. I don’t want to compile them again and again every time I switch branches. So the solution for this are worktrees.
-
Happy 25th birthday, XML!
Every day I interact with ODF, SVG, RSS, OPML, Atom, RDF, FOAF, XSLT, and/or (sigh) [redacted]. Even if that all sounds like alphabet soup, you probably use or benefit from it without even realising.
-
XML Is A Quarter Century Old
For those of us who have spent entire careers working with structured data, it comes as something of a surprise to be reminded that XML is now 25 years old. You probably missed the XML standard on the 10th of February 1998, but it’s almost certain that XML has touched your life in many ways even if you remain unaware of it.
-
Coding with Python Programming Language
Python is an increasingly popular programming language that offers a high degree of flexibility and power.
-
More PDF, C API and Python
Once you have the C API, though, you can do all sorts of fun things, such as using Python's ctypes module. It takes a bit of typing and drudgery, but eventually you can create a "dependencyless" Python wrapper. With it you can do this to create an empty PDF file: [...]
-
Testing shell commands in Go
TL;DR: extract exec.Command into an interface and create a mock implementation for testing. Implement it for your SSH client too, if needed. See example code here.
The code below assumes it is executed in a unix-like operating system where sh shell is available. This simplifies the whole enterprise quite a bit, but also brings some limitations.
-
A Practical Guide To Linux Echo Command
Linux is one of the most popular operating systems. It has a powerful command-line interface that allows various commands to be passed as instructions to be executed by the computer. The echo command is one of the most commonly used Linux commands.
This tutorial will introduce you to the Linux echo command, go over its options and their usage, and show you how you can use it.
-
Mike Blumenkrantz: Capped
I Hate Pipe Caps
Those of you who saw me at XDC will recall that I talked about my hatred for Gallium’s pipe caps.
I still hate them.
But mostly I hate a specific type of pipe cap: the pipe cap that gates performance.
My Driver’s Perf: Why Is It Bad?
In a nutshell:
[...]