Skip to content

Instantly share code, notes, and snippets.

View ivan's full-sized avatar
🕸️

Ivan Kozik ivan

🕸️
View GitHub Profile
@ivan
ivan / 0003-btrfs-progs-scrub-keep-device-limits-unless-limit-is.patch
Created November 7, 2026 10:50
0003-btrfs-progs-scrub-keep-device-limits-unless-limit-is.patch
From 65a0e76b06757613c0156ee24fae2646b846e494 Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Sat, 7 Nov 2026 10:31:38 +0000
Subject: [PATCH] btrfs-progs: scrub: keep device limits unless --limit is
given
[BUG]
A `btrfs scrub start` or `btrfs scrub resume` without --limit runs
unthrottled even when the devices have a throughput limit:
@ivan
ivan / nix-serve-ng-don-t-flush-after-every-NAR-piece.patch
Created October 24, 2026 07:29
nix-serve-ng: don't flush after every NAR piece
From 782cfff08973ded7ea655c58513ebd2c0f428325 Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Sat, 24 Oct 2026 07:24:02 +0000
Subject: [PATCH] nix-serve-ng: don't flush after every NAR piece
Nix's NAR dumper hands over many tiny pieces per file (names, lengths,
padding), and nix-serve-ng flushed after each one, so Warp sent each as
its own packet. Over a ~190 ms RTT link, small-file-heavy parts of a
NAR then dropped from ~11 MB/s to ~1.4 MB/s, stalling remote Hydra
builders on "Sending inputs" for minutes.
@ivan
ivan / check-brotli-cve.sh
Created October 22, 2026 02:12
LLM-authored slop script to scan NixOS for bundled brotli
#!/usr/bin/env bash
# Model-output: Claude Opus 5.5
#
# Read-only triage for CVE-2026-111497 (brotli decoder out-of-bounds write, fixed upstream in
# google/brotli@0ed4268a): which running or installed binaries carry an unfixed decoder, and
# whether anything crashed the way a failed exploit attempt would.
#
# Usage: ssh root@HOST bash -s -- [--closure] [SINCE] < check-brotli-cve.sh
# --closure also scan the /run/current-system closure (about 1 minute per 2000 store paths)
# SINCE start of the crash search; default 2026-02-27, when the upstream fix went public
@ivan
ivan / Astra finds a kernel issue with dedupe.md
Last active September 30, 2026 07:45
Astra finds a kernel issue with dedupe.md

Codex found a kernel edge case where dedupe does update mtime and ctime.

What goes wrong:

  • btrfs dedupes in 16 MiB chunks. If the file being kept has a hole (a sparse, never-written region) at the end of a chunk, btrfs punches a matching hole in the other file. It does this through a helper call that doesn't tell the helper this is a dedupe (reflink.c:660-661, the NULL argument).
  • That helper works from a small metadata budget. If removing the other file's extents uses it up, the helper goes round a retry loop (file.c:2412, block-rsv.c:94-101).
  • The retry loop sets mtime and ctime to "now" unless it was told this is a dedupe (file.c:2496-2498). The comment right above that line says dedupe is supposed t
@ivan
ivan / CLAUDE.md for having Claude Code use Codex for code reviews after each commit.md
Created August 10, 2026 06:19
Have Claude Code use Codex for code reviews after each commit

After making changes

Automatically commit your changes with this commit template:

subsystem: short one-line description; semicolon if multiple changes

Model-output: model name e.g. Claude Fable 5
@ivan
ivan / Untested nixpkgs patch to avoid filling up boot with too many generations.patch
Last active July 28, 2026 02:25
(Claude Fable 5 + ChatGPT 5.6 Sol (Pro)) Untested nixpkgs patch to avoid filling up /boot with too many generations
diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix
index 042fd63cd254..6d319a3d3ca3 100644
--- a/nixos/modules/system/boot/loader/grub/grub.nix
+++ b/nixos/modules/system/boot/loader/grub/grub.nix
@@ -90,6 +90,9 @@ let
else
args.efiBootloaderId;
timeout = if config.boot.loader.timeout == null then -1 else config.boot.loader.timeout;
+ dynamicLimit = cfg.dynamicConfigurationLimit.enable;
+ dynamicLimitMarginMB = cfg.dynamicConfigurationLimit.marginMB;
@ivan
ivan / patch_witness_stair_speed_no_corruption_check.py
Last active July 12, 2026 20:45
Fix the walking speed in The Witness witness64_d3d11.exe (GOG, Patch 21.12.2017 from 06 March 2018) to not have sqrt(2) walking speed on stairs
#!/usr/bin/env python3
# Model-output: ChatGPT 5.6 Sol (High)
"""Patch The Witness stair movement and bypass its startup corruption guard.
The movement patch rescales a player-only walk-manifold request when traversal adds
vertical displacement. The startup patch removes the conditional jump that routes
a zero critical-asset sentinel to ``fatal_error_data_corruption``. The PE file size
and section count remain unchanged.
@ivan
ivan / Prevent ChatGPT from unloading text from the DOM when it is outside the viewport.user.js
Created July 8, 2026 04:32
Prevent ChatGPT from unloading text from the DOM when it is outside the viewport
// ==UserScript==
// @name leave my text alone (chatgpt.com)
// @namespace https://chatgpt.com/
// @version 1.0.0
// @description Keep every chat turn mounted in the DOM (defeats IntersectionObserver-driven unloading) so find-in-page and SingleFile capture whole conversations.
// @match https://chatgpt.com/*
// @match https://chat.openai.com/*
// @run-at document-start
// @grant none
// @inject-into page
@ivan
ivan / Prevent claude.ai from unloading text from the DOM when it is outside the viewport.user.js
Last active July 8, 2026 04:14
Prevent https://claude.ai from unloading text from the DOM when it is outside the viewport
// ==UserScript==
// @name leave my text alone (claude.ai)
// @namespace https://claude.ai/
// @version 1.0.0
// @description Keep every chat message mounted in the DOM (defeats list virtualization) so find-in-page and SingleFile capture whole conversations.
// @match https://claude.ai/*
// @run-at document-idle
// @grant none
// @inject-into page
// @noframes
@ivan
ivan / rsync tips.txt
Created May 31, 2026 07:20
rsync tips
rsync -av -@-1 as the baseline thing
or with --delete to remove things from DEST, and probably
--delete-excluded when using --exclude
rsync -@-1 compares timestamps by nanoseconds instead of seconds, which is important for transferring e.g. PostgreSQL data; rsync doesn't read the data inside each file if the (mtime, size) matches on both ends, unless you:
rsync -c
rsync -X to also copy xattrs (slower)
rsync -H for hard link preservation (uses memory to track all the inodes)
rsync -S to preserve sparseness in sparse file
rsync --zc=zstd
rsync --zc=zstd --compress-level=6 or maybe 8 where the link is slow and extra compression is useful