Skip to content

Instantly share code, notes, and snippets.


Niklas Hambüchen nh2

View GitHub Profile
nh2 /
Last active Aug 20, 2020
Script to scale texture coordinates
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3Packages.plyfile
import argparse
import sys
import numpy as np
from plyfile import PlyData, PlyElement
parser = argparse.ArgumentParser(description='''
nh2 / ptgui-pro.nix
Last active Jul 7, 2020
Packaging PTGui with nix
View ptgui-pro.nix
# This is for installing ptgui conveniently via nix
# or into NixOS.
# Build using e.g.:
# nix-build -E '((import <nixpkgs> {}).callPackage (import ./ptgui-pro.nix) { })'
# and then run via
# result/bin/PTGui
nh2 /
Created Jun 3, 2020
Small benchmark to deduplicate /nix/store into a bup repository
#! /usr/bin/env python3
import glob
import os
import subprocess
import sys
from itertools import zip_longest
# From
def grouper(iterable, n):
nh2 /
Created May 29, 2020
Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image. Wipes the disk!
#! /usr/bin/env bash
# Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image.
# Wipes the disk!
# Tested with Hetzner's `NixOS 20.03 (amd64/minimal)` ISO image.
# Run like:
# curl | sudo bash
nh2 /
Created May 26, 2020
Compresstion/decompression benchmark between JPEG and WebP with ImageMagick
set -e
set -x
echo "Cat"
wget --no-clobber ''
identify 'cat.png'
echo "Cat - 100%"
nh2 /
Last active Jul 19, 2020
Example script to install NixOS on a Leaseweb dedicated server via the Leaseweb GRML rescue mode
#!/usr/bin/env bash
# Installs NixOS on a Leaseweb server, wiping the server.
# This is for a specific server configuration; adjust where needed.
# Originally written for a Leaseweb HP DL120 G7 server.
# Prerequisites:
# * Update the script to adjust SSH pubkeys, hostname, NixOS version etc.
from colorama import Style, Fore, Back
components = [
'[q] Quit',
'[s] Search',
'[←↓↑→,hjkl] Navigation',
'[↵] Open bug',
'[n] New bug',
'[i] Pull',
'[o] Push',
nh2 / 18.03.txt
Last active Apr 10, 2020
LeaseWeb DL120 G7 NixOS systemd network interface naming
View 18.03.txt
# udevadm info /sys/class/net/eno1
P: /devices/pci0000:00/0000:00:1c.5/0000:03:00.0/net/eno1
E: DEVPATH=/devices/pci0000:00/0000:00:1c.5/0000:03:00.0/net/eno1
E: ID_BUS=pci
E: ID_MODEL_FROM_DATABASE=82574L Gigabit Network Connection (NC112i 1-port Ethernet Server Adapter)
E: ID_MODEL_ID=0x10d3
E: ID_NET_NAME_MAC=enxe83935edad4b
nh2 /
Last active Apr 3, 2020
`git rebase --onto` for switching target branches

git rebase --onto for switching target branches

Git rebase with --onto implements the idea:

cut and paste from start commit B to end commit E and put it "onto" commit O.

nixpkgs example

If you have a situation where somebody made a somebranch PR against master but it should have been against another branch, like this:

nh2 /
Created Feb 13, 2020
Hack to work around nix duplicate -L flags causing `argument list too long` for GCC, see
#!/usr/bin/env python3
# Script to deduplicate linker flags in nix variables.
# Workaround for:
# This is obviously a hack and it should be fixed in nixpkgs.
# Usage (from bash to update env vars in the current shell context):
# eval <(
You can’t perform that action at this time.