Skip to content

Instantly share code, notes, and snippets.

emphatically trying not to use github as icq

Nick kousu

emphatically trying not to use github as icq
View GitHub Profile
kousu /
Last active Nov 28, 2021
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.

View Akai MPK Mini.midi.xml
<?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 Apr 11, 2021
dockerize for travis-ci
kousu /
Last active Apr 8, 2021
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 Apr 5, 2021
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')


mkdir -p ~/.local/bin
curl > .local/bin/showterm
chmod +x .local/bin/showterm
kousu /
Created Mar 19, 2021
Repo splitting with git filter-repo

To split the GUI plugin, spread over two branches (1 2) and two folders (shimmingtoolbox/gui/, shimmingtoolbox/fsleyes-plugin-shimming-toolbox), out from to

  1. sudo pacman -S git-filter-repo [or your local option]
kousu /
Created Nov 28, 2020
http cert pinning

Generate certificate pins for your apps.


For all of you wanting this feature there's a great option out there if you're willing to step beyond Signal: Conversations. There's no primary/secondary distinction: it does true-multi-device multi-key encryption (they adopted libsignal and built on it and I'm very grateful that OWS developed and released it so it could be built upon), as well as video chat, file attachments (encrypted, of course), and cross-device history syncing, and all that at 1/3rd the size of Signal, and without a dependency on push notifications. And you can pretty easily set up alt identities and use them on the same devices so there's no need to worry about [giving out a private number](

#!/usr/bin/env bash
# upload a file to neuropoly's wiki's filestore at
# public domain
# author:
# TODO: be fully scp compatible: we should be able to specify the target filename, disambiguating between DESTs ending in / or not
set -eo pipefail # crash on sub-errors; pipefail is a bashism, but sooo useful
set -u # crash on missing vars