Skip to content

Instantly share code, notes, and snippets.

@xenophonf
xenophonf / irc.log
Last active November 4, 2025 04:43
On using small classes with Python match-case statements
19:49 < dcb> so, I'm looking for opinions on a pattern I often end up using with python that I borrowed from erlang and haskell. The gist is to wrap some object inside a
small class just so I can use it in a match-case statement. Here's a snippet should give you an idea: https://bpa.st/C6LQ
19:50 < dcb> others often react in one of two ways: (╭ರ_•́) or ¯\_(ツ)_/¯
20:00 < phy1729> IMO Python's typing isn't algebraic enough for that to feel natural. Though TIL __match_args__ so maybe that'll change in my head.
20:03 < phy1729> dcb: though I'd be inclined to make Field generic https://mypy-play.net/?mypy=latest&python=3.12&gist=b4aa6967a03c0ac147130af73f8942db
20:17 < dcb> XenophonF: these patterns often end up appearing when I'm debugging branching logic early on development. Good call for making the base generic. And
`__match_args__` is something I've started to use quite a bit recently
20:17 < dcb> phy1729 ^
@xenophonf
xenophonf / docker-compose.yml
Created September 4, 2025 00:36 — forked from jonas-merkle/docker-compose.yml
Docker Compose configuration for setting up a PostgreSQL container with a health check
# Docker Compose configuration for setting up a PostgreSQL container with a health check
#
# This configuration pulls the latest PostgreSQL image and sets up a health check
# to monitor if the PostgreSQL service is ready to accept connections. The health check
# uses the 'pg_isready' command to check database readiness.
#
# Environment variables are used to configure PostgreSQL credentials and database settings.
services:
postgres:
@xenophonf
xenophonf / GNUMakefile
Created August 11, 2025 01:39
An unfinished idea I had to generate documentation for tagged releases and extant feature branches
# This was inspired by https://www.codingwiththomas.com/blog/my-sphinx-best-practice-for-a-multiversion-documentation-in-different-languages.
# However, I'm taking a different approach.
# Generate documentation for tagged releases and extant feature
# branches. Take care to handle remote branches, too, not just local
# branches or local remote-tracking branches. However, do not alter
# the working directory in any way.
docs: $(LOCALES) | $(PYPACKAGE_NAME).egg-info
# Create missing remote-tracking branches.
LOCAL_BRANCHES=$$(git branch \
@xenophonf
xenophonf / weird-trick-to-map-github-actions-secrets-variables-to-opentofu-input-variables.md
Last active July 5, 2025 15:27
Use this ONE SECRET HACK to map GitHub Actions secrets/variables to OpenTofu input variables LIKE A PRO (site reliability engineers HATE THIS!)

TL;DR—Continue using lowercase OpenTofu input variable names, but prefix the corresponding GitHub Actions secret/variable names with an underscore. Then add the following step to your continuous delivery workflow:

      - uses: easyware-io/export-to-env@v1
        with:
          secrets: ${{ toJSON(secrets) }}
          vars: ${{ toJSON(vars) }}
          only: ^_.*
          prefix: TF_VAR
 transform: lowercase
@xenophonf
xenophonf / swap-lctrl-caps-lalt-lwin.reg
Created November 13, 2024 14:35
Swap Left Control/Caps Lock and Left Alt/Left Win in Windows (e.g., when using Apple keyboards)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:\
00,00,00,00,\
00,00,00,00,\
05,00,00,00,\
1d,00,3a,00,\
3a,00,1d,00,\
38,00,5b,e0,\
@xenophonf
xenophonf / nvm
Created October 18, 2024 13:48
A wrapper for nvm that makes it work in other shells (specifically, csh and tcsh)
#!/usr/bin/env bash
# load nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] || exit 0
\. "$NVM_DIR/nvm.sh"
# configure csh
if [ "$1" = "csh-env" ]; then
# use the 'default' version by default
@xenophonf
xenophonf / Every Angle.4.2.binds
Last active November 18, 2025 01:12
Every Angle (Beta)
<?xml version="1.0" encoding="UTF-8" ?>
<Root PresetName="Every Angle" MajorVersion="4" MinorVersion="2">
<KeyboardLayout>en-US</KeyboardLayout>
<MouseXMode Value="Bindings_MouseYaw" />
<MouseXDecay Value="1" />
<MouseYMode Value="Bindings_MousePitch" />
<MouseYDecay Value="1" />
<MouseReset>
<Primary Device="{NoDevice}" Key="" />
<Secondary Device="Keyboard" Key="Key_Grave" />
@xenophonf
xenophonf / certbot
Created March 13, 2023 03:10
All-in-one certbot wrapper for CentOS 7—make executable and copy to /usr/local/bin; alter plugins on line 29 to taste
#!/usr/bin/env bash
# stop immediately if the script fails
set -Eeuo pipefail
# use chronic if installed
export LANG=C
CHRONIC=$(command -v chronic)
# install required packages
#!/bin/bash
if [ "$_" = "${BASH_SOURCE}" ]
then
printf 'source this script, do not execute.\n' >&2
exit 1
fi
eval $(minikube docker-env --shell bash)
if [ -n "${DOCKER_CERT_PATH}" ] && [ "${DOCKER_CERT_PATH:0:1}" != '/' ]
@xenophonf
xenophonf / Angular Flight Standard Pro (modified).3.0.binds
Last active March 25, 2023 16:15
My modified Angular Flight Standard Pro Steam Controller bindings for Elite Dangerous
<?xml version="1.0" encoding="UTF-8" ?>
<Root PresetName="Angular Flight Standard Pro (modified)" MajorVersion="3" MinorVersion="0">
<KeyboardLayout>en-US</KeyboardLayout>
<MouseXMode Value="Bindings_MouseYaw" />
<MouseXDecay Value="0" />
<MouseYMode Value="Bindings_MousePitch" />
<MouseYDecay Value="0" />
<MouseReset>
<Primary Device="Keyboard" Key="Key_Grave" />
<Secondary Device="{NoDevice}" Key="" />