Skip to content

Instantly share code, notes, and snippets.

View bjornpagen's full-sized avatar
🍇

Bjorn Pagen bjornpagen

🍇
View GitHub Profile
@bjornpagen
bjornpagen / RECOVERY-LOGS.md
Created September 6, 2026 15:37
rclone VFS recovery: reproducible read/delete failures on release, current master, and PR 9531

rclone recovered VFS write: captured test logs

Captured 2026-09-06 on Darwin arm64. Local disposable backend only. The checkout parent path has been replaced with /path/to/checkouts; diagnostic output is otherwise unchanged. Expected failing baselines are intentionally retained.

Current master

Revision: 3d7b101c7f4bc3ebdcfc882c063fffd1c16bf196. Command: go test -v ./vfs -run '^TestVFSRecoveredWrite$' -count=1 -args -verbose.

@bjornpagen
bjornpagen / gist:c6a432bfa62644118e68c47e7fb91a1a
Created August 23, 2026 20:23
bjorns-opinionated-postgres-audit.SKILL.md
---
name: bjorns-opinionated-postgres-audit
description: Apply when creating or modifying ANY drizzle table schema under src/db/schemas OR writing/modifying/reviewing ANY drizzle query under src/db/queries. One skill, two halves — schema law (strict BCNF, the monomorphic-DU ban with header + typed sidecars, uuidv7-only no-timestamp law, constraint conventions, generate-via-skill migrations) and query law (the seven query laws, DU sidecar read discipline, int8 decode). Invoke standalone to sweep the current diff on either side; each half's audit procedure cross-checks the other.
---
# Bjorn's Opinionated Postgres Audit
One skill, two halves. Schema law governs how tables get SHAPED; query law
governs how they get READ AND WRITTEN. They share one philosophy —
`docs/design/representation-first.md`: push the proof into the type/relation
@bjornpagen
bjornpagen / battery.lua
Created November 7, 2025 16:37
Get battery on Asahi Linux
#!/usr/bin/env lua
local function read_file(path)
local file = io.open(path, "rb") -- r read mode and b binary mode
if not file then return nil end
local content = file:read "*a" -- *a or *all reads the whole file
file:close()
return content
end
@bjornpagen
bjornpagen / errors.ts
Last active April 25, 2025 02:39
Good error handling in Typescript
export type Success<T> = {
data: T
error: undefined
}
export type Failure<E> = {
data: undefined
error: E
}
@bjornpagen
bjornpagen / img.sh
Last active February 17, 2023 07:37
A Really Terrible Image Randomizer - uses exiftool and imgmagick
#!/bin/bash
mkdir imgs
res=()
for lhs in -1 1
do
for rhs in $(seq -w 0 99)
do
res+=("${lhs}.${rhs}")
@bjornpagen
bjornpagen / deleteNotionToggleElements.js
Created January 31, 2023 20:32
A JavaScript function to delete all elements with the class notion-toggle from the DOM.
function deleteNotionToggleElements() {
const elements = document.getElementsByClassName("notion-toggle");
while (elements.length > 0) {
elements[0].parentNode.removeChild(elements[0]);
}
}
document.addEventListener("DOMContentLoaded", function() {
deleteNotionToggleElements();
});
@bjornpagen
bjornpagen / ga4-utm-parameters-event.js
Created January 31, 2023 03:20
A JavaScript code snippet for logging UTM parameters as a GA4 event, only including parameters that are set in the URL and omitting any parameters that are not set.
// Get the UTM parameters from the URL
var search = window.location.search;
var params = new URLSearchParams(search);
// Keep track of if an event has already been logged
var eventLogged = false;
// Loop through each UTM parameter
for (var [key, value] of params.entries()) {
// Check if the parameter is "utm_source", "utm_medium", "utm_campaign", "utm_term", or "utm_content"
@bjornpagen
bjornpagen / append-utm-params.js
Last active January 31, 2023 03:00
Append UTM parameters to specific domains in a webpage using JavaScript. The function loops through all the links on a page and checks if the link is part of the specified domains. If it is, the UTM parameters from the URL are added to the link.
function appendUTMParams(domains) {
// Get all the links on the page
var links = document.getElementsByTagName("a");
// Get the UTM parameters from the URL
var search = window.location.search;
var params = new URLSearchParams(search);
// Array of allowed UTM parameters
var allowedUTMs = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];