Skip to content

Instantly share code, notes, and snippets.

View kousu's full-sized avatar

Nick Guenther kousu

  • Asymmetric Research
  • Canada
View GitHub Profile
kousu /
Created April 24, 2023 22:14
Prototype a workaround for unix domain socket length limit of 107.
#!/usr/bin/env python
# this is a tiny little clone of `nc -U -l path`
# but it creates the socket *after chdir()ing in a subprocess* to avoid ENAMETOOLONG:
# To test the difference, get openbsd-netcat and run:
# mkdir -p /tmp/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz
# nc -v -U -l /tmp/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz/abcdefhijklmnopqrstuvwxyz/ipc.sock
kousu /
Created January 12, 2023 23:50
Bridging Discord + XMPP

Just because the docs on are a little bit obscure in some parts, here's a complete record of what I did:

  1. sudo pacman -S matterbridge
  2. Set up a generic systemd service file:
$ cat /etc/systemd/system/matterbridge\@.service 
Description=%I Chat Bridge
kousu / .gitignore
Last active October 9, 2022 19:04
nifti demo
kousu / pip-integrity
Last active September 30, 2022 18:57
The missing `pip integrity` command
#!/usr/bin/env python3
# The missing 'pip integrity' command.
# This verifies the correctness of an unpacked pip package
# by examining the file hashes in the 'RECORD' file.
# spec at
import sys
import base64
kousu /
Last active November 28, 2021 18:36
Linux du(1) de-duplication bug

I've found a confusing behaviour in Linux's version of du(1). du can take a single folder to recurse into, or list of files/folders either via --files0-from or in argv. But its behaviour is inconsistent if this list contains parents and children.

  1. A child given before its parent makes the parent count as empty
  2. With -s (or equivalently -d 0), a parent given before its child (vice versa) skips the child

OpenBSD's du conversely has consistent behaviour: it always outputs one line (or block of lines, if not given -s) per input, and always counts everything as full-sized, parent and child.

<?xml version='1.0' encoding='utf-8'?>
<MixxxControllerPreset schemaVersion="1" mixxxVersion="2.3.0">
<name>Akai MPK Mini</name>
<controller id="AkaiMPKMini">
<!-- Master -->
kousu /
Created April 11, 2021 18:13
dockerize for travis-ci
kousu /
Last active April 8, 2021 22:13
extract functions

Extract an indented block from a file, starting from a given header line.

Usage: extract.awk HEADER file


$ ./extract.awk a t
   a() {
kousu /
Created April 5, 2021 09:31
Sanitize a file path against directory traversal in python
import os.path
def sanitize_path(path):
Sanitize a path against directory traversals
Based on
>>> sanitize_path('../test')
kousu /
Last active March 26, 2021 19:50 sh client, with applied


mkdir -p ~/.local/bin
curl > .local/bin/showterm
chmod +x .local/bin/showterm