Skip to content

Instantly share code, notes, and snippets.


Ivan Kozik ivan

View GitHub Profile
ivan / use-decimal-sizes.patch
Last active May 27, 2023 04:27
qBittorrent 4.5.2 (actually fcd38a497eac275fa01cac4e04f27aa806df6d30) patch to use decimal sizes everywhere instead of binary prefix sizes
View use-decimal-sizes.patch
diff --git a/src/app/application.cpp b/src/app/application.cpp
index 5a74d27a4..09751de77 100644
--- a/src/app/application.cpp
+++ b/src/app/application.cpp
@@ -114,12 +114,12 @@ namespace
const Path DEFAULT_PORTABLE_MODE_PROFILE_DIR {u"profile"_qs};
- const int MIN_FILELOG_SIZE = 1024; // 1KiB
- const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
ivan / yt-dlp-use-deno-for-nsig.patch
Created May 13, 2023 00:41
yt-dlp: use deno for nsig extraction
View yt-dlp-use-deno-for-nsig.patch
diff --git a/yt_dlp/extractor/ b/yt_dlp/extractor/
index b9623cbf8..abe996273 100644
--- a/yt_dlp/extractor/
+++ b/yt_dlp/extractor/
@@ -19,6 +19,8 @@
import urllib.error
import urllib.parse
import urllib3
+import tempfile
+import subprocess
ivan / nixpkgs patch to build fewer kernel things.patch
Created May 12, 2023 02:37
nixpkgs patch to build fewer kernel things
View nixpkgs patch to build fewer kernel things.patch
From 283f99d20990d094d74ac60b98e082a16511389b Mon Sep 17 00:00:00 2001
From: Ivan Kozik <>
Date: Fri, 12 May 2023 02:18:33 +0000
Subject: [PATCH] linux/common-config: don't build things that we'll never use
.../linux/kernel/common-config.nix | 114 ++----------------
1 file changed, 8 insertions(+), 106 deletions(-)
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
ivan / 0001-nixos-environment-also-create-a-bin-bash.patch
Last active April 22, 2023 17:11
nixpkgs patch to make NixOS also create a /bin/bash, for compatibility with everyone's bad shebang lines
View 0001-nixos-environment-also-create-a-bin-bash.patch
From ec04e3f0df7615cd3fd05155636c52fc0e8469b7 Mon Sep 17 00:00:00 2001
From: Ivan Kozik <>
Date: Sat, 22 Apr 2023 17:06:58 +0000
Subject: [PATCH] nixos/environment: also create a /bin/bash
nixos/modules/config/shells-environment.nix | 3 +++
1 file changed, 3 insertions(+)
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix
ivan /
Last active April 13, 2023 04:25
A conversation from Discord about overclocking CPUs

<Thomas> Dude 7800x3d "overclocks" pretty decently. 4.82 ghz all core or 4.97 single core.

<Thomas> Got a much better overclock: 5.0 ghz all core stable. 5.2 single core.

<Thomas> And I'm still like 100 mv below what I could get to, but my cooler won't be able to go much higher all core load lmao.

<Thomas> tmax is 89c, and I'm at 80c right now, but I'm also running in an open case config.

<Ivan> the software and tests used to qualify CPUs at the Intel | AMD | ... factory are secret and we have no complete substitute, so there is no way to qualify a CPU yourself for any non-default voltage and speed that can be guaranteed stable under all system conditions, especially rarer or more IO-loaded states

ivan /
Last active April 11, 2023 14:41
A less naïve perception of URLs

Ordinarily, when we encounter a URL, we take just the URL by itself and do something with it; perhaps we try to load it in our browser or store it somewhere.

We can consider this to be the more naïve interpretation of a URL: we assume we're always fine with the latest version of the document, or the document is unchanging, or the changes don't really matter; we try to load the URL in our browser and if the website is gone or not the version we expect, well, tough luck for us.

But we can make our perception of URLs a little less naïve, as there is another piece of data we can take when we see a URL: the time that the URL was posted. Fortunately, we typically encounter URLs in documents or messages with some sort of timestamp.

So instead of taking URL, we take (URL, referring_document_time), which enables us to know which version of the document that author was referring to. We can then, for example, look up that website around that point in time in Wayback Machine. In other cases, when a website parti

ivan / asyncread poll_read
Last active April 7, 2023 12:22
tokio::io::AsyncRead poll_read implementation footgun
View asyncread poll_read

The tokio::io::AsyncRead documentation confusingly states:

Poll::Ready(Ok(())) means that data was immediately read and placed into the output buffer. The amount of data read can be determined by the increase in the length of the slice returned by ReadBuf::filled. If the difference is 0, EOF has been reached.

The footgun is that when poll_read is called, buf may already be partially filled. In some cases, this happens just a small fraction of the time in production, causing e.g. the last chunk of a file to be poll_read twice.

Setup code:

ivan /
Created April 7, 2023 11:08
//! BLAKE3-related helpers
use std::pin::Pin;
use std::sync::Arc;
use parking_lot::Mutex;
use pin_project::pin_project;
use futures::{ready, stream::Stream, task::{Context, Poll}};
use tokio::io::{AsyncRead, ReadBuf};
ivan / wat.txt
Created April 1, 2023 09:04
dependency tree for the NPM package "del"
View wat.txt
├─┬ del 7.0.0
│ ├─┬ globby 13.1.3
│ │ ├─┬ dir-glob 3.0.1
│ │ │ └── path-type 4.0.0
│ │ ├─┬ fast-glob 3.2.12
│ │ │ ├── @nodelib/fs.stat 2.0.5
│ │ │ ├─┬ @nodelib/fs.walk 1.2.8
│ │ │ │ ├─┬ @nodelib/fs.scandir 2.1.5
│ │ │ │ │ ├── @nodelib/fs.stat 2.0.5
│ │ │ │ │ └─┬ run-parallel 1.2.0
ivan / Cults are patronage
Last active May 2, 2023 17:29
Cults are patronage networks
View Cults are patronage

Cults are patronage networks. They distribute benefits. The benefits could be intangible, they don't have to be money. Belonging is a benefit, acceptance is a benefit, access to [partners] is a benefit, money is a benefit of course, but also power is a benefit; an internal hierarchy. It's a fantasy, it's what we call in psychology is a paracosm. A paracosm is an alternative cosmos; it's detached, it's a bubble. And so within this bubble you can create an entire universe with its own laws of physics of you wish, and then if you play by these rules, you're mightily rewarded, emotionally, materially, in other ways. And if you don't, of course, you're sanctioned, similarly. So it's what we call a reinforcement system. It's a reward-punishment system. Positive and negative. And it's fairly intermittently by the way, it's fairly intermittent in the sense that very often, the leader kind of punished you to remind you that you're still at his mercy. He demotes you, he criticizes you publicly, he does something to