Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
emphatically trying not to use github as icq

Nick kousu

🤓
emphatically trying not to use github as icq
View GitHub Profile
@kousu
kousu / .gitignore
Last active Oct 9, 2022
nifti demo
View .gitignore
node_modules
@kousu
kousu / pip-integrity
Last active Sep 30, 2022
The missing `pip integrity` command
View pip-integrity
#!/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 https://peps.python.org/pep-0427/#the-dist-info-directory
import sys
import base64
@kousu
kousu / README.md
Last active Nov 28, 2021
Linux du(1) de-duplication bug
View README.md

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">
<info>
<name>Akai MPK Mini</name>
</info>
<controller id="AkaiMPKMini">
<scriptfiles/>
<controls>
<!-- Master -->
@kousu
kousu / README.md
Created Apr 11, 2021
dockerize for travis-ci
View README.md
@kousu
kousu / README.md
Last active Apr 8, 2021
extract functions
View README.md

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

Usage: extract.awk HEADER file

e.g.

$ ./extract.awk a t
   a() {
@kousu
kousu / sanitize.py
Created Apr 5, 2021
Sanitize a file path against directory traversal in python
View sanitize.py
import os.path
def sanitize_path(path):
"""
Sanitize a path against directory traversals
Based on https://stackoverflow.com/questions/13939120/sanitizing-a-file-path-in-python.
>>> sanitize_path('../test')
'test'
View README.md

showterm.io

Installation:

mkdir -p ~/.local/bin
curl https://gist.githubusercontent.com/kousu/855c164979af078f623fd44f0e1b5350/raw/6536924551c9de7143492c407f4e584389ba3f9f/showterm > .local/bin/showterm
chmod +x .local/bin/showterm
@kousu
kousu / README.md
Created Mar 19, 2021
Repo splitting with git filter-repo
View README.md

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

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

Generate certificate pins for your apps.