Skip to content

Instantly share code, notes, and snippets.

View mibmo's full-sized avatar

mib mibmo

View GitHub Profile
@mibmo
mibmo / fix-conflicts.bash
Last active November 5, 2024 04:55
Automatically fix Syncthing conflicts via 3-way merges (requires trashbin versioning or stronger, as well as fd, ripgrep, and git)
#!/usr/bin/env bash
# syncthing share. some parent directory
targetShare="$PWD"
while true; do
if [ -d "$targetShare/.stfolder" ]; then break; fi
if [ "$targetShare" == "/" ]; then
echo "Could not find parent Syncthing share"
exit 1;
fi
@mibmo
mibmo / toPython.nix
Created April 10, 2025 22:13
Convert Nix types into Python data (probably)
let
inherit (builtins)
attrValues
concatStringsSep
foldl'
head
length
mapAttrs
tail
typeOf
@mibmo
mibmo / semver.nix
Created April 30, 2025 16:52
Semver regex via Nix
let
letter = ''[a-zA-Z]''; # unused; just from semver's spec
positive-digit = ''[1-9]'';
digit = ''[0-9]'';
non-digit = ''[a-zA-Z-]'';
identifier-character = ''[a-zA-Z0-9-]'';
numeric-identifier = ''(0|${positive-digit}${digit}*)'';
alphanumeric-identifier = ''(${non-digit}${identifier-character}*|${identifier-character}+${non-digit}${identifier-character}*)'';
build-identifier = ''(${alphanumeric-identifier}|${digit}+)'';
pre-release-identifier = ''(${alphanumeric-identifier}|${numeric-identifier})'';
@mibmo
mibmo / pwdSnapshot.sh
Created August 25, 2025 23:15
Get cwd in latest snapshot
function pwdSnapshot() {
echo "/persist/.zfs/snapshot/$(zfs list -t snapshot -o creation,name -pH data/persist | sort --stable --reverse --key=1,1 | cut -d'@' -f2- | head -1)/$PWD"
}