Skip to content

Instantly share code, notes, and snippets.

@hmenke
hmenke / local-bin.nix
Last active September 13, 2023 16:05
Build some static executables to put in ~/.local/bin on foreign machines
#{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import (fetchTarball "https://channels.nixos.org/nixos-unstable-small/nixexprs.tar.xz") {} }:
with pkgs;
let
name = "local-bin";
entries = let
goLinkStatic = drv: args:
@hmenke
hmenke / README.md
Last active May 17, 2023 11:21
Ubuntu cloud-init autoinstall

Create an Ubuntu 20.04 LTS autoinstall USB

This only works with UEFI boot.

  1. Get a USB key and format it with a GPT partition table. Using gptfdisk something like this should do it:
    sgdisk -og /dev/sdX
    sgdisk -n 0:0:0 -t 0:ef00 /dev/sdX
    

Create a FAT32 partition, mount it and extract the ISO image to that location

@hmenke
hmenke / cgit.nix
Last active January 21, 2021 21:32
cgit for nginx on NixOS
{ config, lib, pkgs, ... }:
with lib;
let
globalConfig = config;
settingsFormat = {
type = with lib.types; let
value = oneOf [ int str ] // {
description = "INI-like atom (int or string)";
};
@hmenke
hmenke / tlclosure.sh
Last active August 14, 2020 09:18
Determine the transitive closure of dependencies of a TeX document
#!/usr/bin/env bash
set -eo pipefail
program="${0##*/}"
scheme="scheme-infraonly"
opts="$(getopt -o s: -l scheme: -n "$0" -- "$@")"
err="$?"
eval set -- "$opts"
#!/usr/bin/env bash
set -eux
DEVICE="/dev/nvme0n1"
sgdisk -og "${DEVICE}"
sgdisk -n 0:0:+2048M -t 0:ef00 "${DEVICE}"
sgdisk -n 0:0:+64M -t 0:8309 "${DEVICE}"
sgdisk -n 0:0:-8192M -t 0:a504 "${DEVICE}"
@hmenke
hmenke / gravatar.tex
Created August 21, 2019 08:26
My gravatar in ConTeXt with MetaPost
\startMPpage
numeric u; u := 10pt ;
picture eighth, quarter;
path p, q;
drawoptions(withcolor(166/255,165/255,177/255)) ;
eighth := image (
fill origin -- (u,0) -- (u,u/2) -- cycle ;
fill (0,u) -- (u,u) -- (u,u/2) -- cycle ;
@hmenke
hmenke / test.lua
Last active July 1, 2019 05:01
luafontid
function token.scan_limited_int(max, name)
local cur_val = token.scan_int()
if (cur_val < 0) or (cur_val > max) then
local hlp, msg
if not name then
hlp = string.format("Since I expected to read a number between 0 and %d,", max)
msg = string.format("Bad number (%d)", cur_val)
else
hlp = string.format("A %s must be between 0 and %d.", name, max)
msg = string.format("Bad %s (%d)", name, cur_val)
@hmenke
hmenke / pdfadjustinterwordglue.tex
Last active February 2, 2023 12:20
pdfadjustinterwordglue in LuaTeX
\ifdefined\directlua
\csname newcount\endcsname\pdfadjustinterwordglue
\begingroup
\catcode`\^^M=12
\directlua{
local subtypes = node.subtypes("glue")
local knbscode = {}
@hmenke
hmenke / tag_math.lua
Last active June 13, 2019 02:02
tag_math
local unimath_symbols = require("unimath_symbols")
local convert_char = unimath_symbols.convert_char
local converters = {}
local function convert(n)
local id = n.id
local type = node.type(id)
local typeconv = converters[type]
@hmenke
hmenke / striplast.tex
Created May 9, 2019 03:42
Strip the last token from a list
\documentclass{article}
\pagestyle{empty}
\begin{document}
\makeatletter
% pgf@keys@utilifxthenelse
%
% #1 = two tokens to be compared using \ifx
%