Case studies
#powershell#debugging#windows#electron#docker#pterodactyl#python#csharp#wpf#bash#security#cpp#git#performance#ci#nodejs#pyside6#react-native
37 posts
Clear filters·6 min read

A Ruby image for Pterodactyl that reads database.yml with awk to decide on db:prepare
Running db:prepare on a Rails app with no database kills the start; skipping it on one with a database breaks the first request. The start script decides from database.yml and DATABASE_URL.
In short
- The Ruby image has to start whatever the user uploads: Rails, a Rack app, a Sinatra file, or a custom command.
- Whether to run db:prepare depends on whether the current environment names a database, so the script parses config/database.yml with awk and also honours DATABASEURL.
- I ran the awk on two sample files, and it correctly ignored a commented-out production: block.
#ruby#rails#docker#bash#pterodactyl
·5 min read

DailyBrief only worked on my disk, so I split install from per-user data
The packaged exe held my own OneDrive path and the pipeline rewrote the app's HTML page. One env var, DAILYBRIEF_DATA, now separates a read-only install from each Windows user's data.
In short
- A packaged build pointed at one hardcoded project path, and the daily pipeline also rewrote the app's own HTML page with each day's plan.
- I separated an install root (read-only, shared) from a data folder under the user's app data, chosen once in main.js and passed to every script as DAILYBRIEFDATA.
- Running a script by hand without the variable still works, because the data folder falls back to the script folder.
#electron#packaging#powershell#architecture
·6 min read

My video compressor picks a GPU encoder from a list, and never asks the GPU
ffmpeg -encoders lists what the build contains, not what the machine can run. Reading my own encoder selection code, I found a silent CPU fallback, two option vocabularies and a discarded error.
In short
- Hardware encoder choice is a substring check on ffmpeg -encoders, which lists what the build contains, not what the machine can run.
- A missing encoder silently falls back to libx264 or libx265, and the encoder options differ between the software and hardware paths.
- When a hardware encode fails, the only message the user gets is FFmpeg exited with code N.
#electron#ffmpeg#nvenc#error-handling
·6 min read

DailyBrief rebuilt every project card every 30 minutes, so I added a fingerprint cache
Most projects had not changed between runs, yet git log and a TODO scan ran for all of them. The hard parts were a fingerprint git status alone could not provide, and PowerShell 5.1 array quirks.
In short
- discover-projects.ps1 rebuilt every project card from scratch on each 30 minute run, including git history and a TODO scan.
- Each card now gets a fingerprint (HEAD, branch, dirty list plus the mtimes of the dirty files). If it matches the last run, the expensive fields are reused and the cheap ones are recomputed.
- Reusing a card is only safe if it serializes exactly like a fresh one, and PowerShell 5.1 made that harder than the cache itself.
#powershell#caching#git#performance
·5 min read

In TaskPad a star is a marker, so Markdown needed a translation layer
Markdown bullets collide with TaskPad's own markers. Import respects code fences, export maps states to Markdown and turns comments into footnotes.
In short
- TaskPad has its own line syntax with markers like !, ?, and [ ], so Markdown cannot go in or out as plain text without translation.
- Import is a line-by-line pass that respects code fences and rewrites and + bullets to -; export maps every marker, turns comment threads into footnotes and forces hard line breaks.
- Export refuses to write over the note's own file, and a plain-text export exists for places where Markdown would be noise.
#csharp#wpf#markdown#parsing
·5 min read

Rust image for Pterodactyl: sizing cargo jobs from the cgroup CPU quota
Cargo counts the host's cores, not the container's quota. The Rust yolk reads cpu.max, pins the toolchain and finds the binary through cargo's JSON output.
In short
- Cargo sizes its parallelism from the host's core count, but a Pterodactyl container is capped by a cgroup CPU quota, and every extra rustc job costs memory at the peak of a build.
- The start script reads /sys/fs/cgroup/cpu.max, rounds the quota up to whole CPUs and exports it as CARGOBUILDJOBS unless the user already set it.
- Two smaller decisions made the image behave: pinning RUSTUPTOOLCHAIN against a project's rust-toolchain.toml, and asking cargo for JSON output to find the binary to run.
#docker#rust#cgroups#pterodactyl
·5 min read

A .task note is a zip: one file for text and images, saved by swapping a temp file
A TaskPad note that keeps its screenshots: a zip with note.txt and images/, a per-path cache while open, and the guards a zero-byte file and hostile entry names needed.
In short
- A .task file is a ZIP holding note.txt, an images/ folder and a one-byte format marker, so a note and its pictures travel as one file.
- While a note is open it is unpacked to a per-path cache folder; saving first copies stray images in, then writes a temp file and swaps it over the original.
- The edge cases that needed code: a zero-byte file created by Explorer, duplicate image names, and entries that try to climb out of the cache folder.
#csharp#wpf#file-format#zip
·6 min read

Removing a work folder in DailyBrief no longer triggers a full disk rescan
Saving the work-folder list used to rescan every root, even when I only removed one. The fix compares the effective root sets before and after and rescans only when a folder was gained.
In short
- Every save of the work-folder list cleared the cache and started a project discovery run plus a monitor run, including saves that only removed or switched off a folder.
- The handler now builds the effective root set before and after the save and rescans only if the new set contains a root the old one lacked.
- A removal now just saves, and the UI says its projects leave the list at the next scan, within 30 minutes.
#electron#nodejs#performance#powershell