Skip to content

Instantly share code, notes, and snippets.

View felixhummel's full-sized avatar

Felix Hummel felixhummel

View GitHub Profile
@felixhummel
felixhummel / openapi.json
Created August 14, 2025 13:07
OpenWebUI /openapi.json (only available with ENV=dev)
{
"openapi": "3.1.0",
"info": {
"title": "Open WebUI",
"version": "0.1.0"
},
"paths": {
"/ollama/": {
"get": {
"tags": [
@felixhummel
felixhummel / nullable_but_not_null.sql
Created July 28, 2025 07:24
Nullable but not null
-- SQL-only version of
-- https://efe.me/posts/nullable-but-not-null/
CREATE OR REPLACE FUNCTION find_nullable_columns_and_count_null()
RETURNS TABLE (
table_name TEXT,
column_name TEXT,
data_type TEXT,
row_count BIGINT,
null_count BIGINT,
@felixhummel
felixhummel / hello-structlog-loglevel.py
Last active July 22, 2025 07:23
structlog config with loglevel name
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "structlog>=25.1.0",
# ]
# ///
import os
import structlog
>>> def iter_stuff():
... yield 1
... yield 2
... yield 4
...
>>> next(iter_stuff())
1
>>> next(iter_stuff())
1
>>> next(iter_stuff())
@felixhummel
felixhummel / log
Created February 20, 2024 12:50
postgres json --> array --> pgvector
postgres=# CREATE TABLE x AS SELECT '{"foo": 1, "bar": 2}'::jsonb AS payload;
SELECT 1
postgres=# SELECT * FROM x;
payload
----------------------
{"bar": 2, "foo": 1}
(1 row)
postgres=# SELECT ARRAY[payload->'foo', payload->'bar']::float[]::vector FROM x;
/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_14W0A05NFWTG:
ATA device, with non-removable media
Model Number: TOSHIBA MG08ACA16TE
Serial Number: 14W0A05NFWTG
Firmware Revision: 4305
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Used: unknown (minor revision code 0x006d)
Supported: 10 9 8 7 6 5
@felixhummel
felixhummel / systemd_user_service.sh
Created November 19, 2020 14:34
systemd user service
# first, allow user services to be started on boot
# you only need to do this once
sudo loginctl enable-linger $USER
# this must be set to "no" (the default)
grep KillUserProcesses /etc/systemd/logind.conf
# create your user service file
mkdir -p ~/.config/systemd/user
@felixhummel
felixhummel / backup.sh
Last active October 17, 2020 18:42
borg backup script
#!/bin/bash
set -euo pipefail
[[ $UID == 0 ]]
export BORG_REPO=/media/backup/borg/foo
export BORG_PASSPHRASE="TODO change this to a secret passphrase"
borg create \
--filter AME \
@felixhummel
felixhummel / configmap-and-deployment.md
Last active July 29, 2019 17:16
kubectl ConfigMap and Deployment

Problem

ConfigMap changes do not result in deployment changes (which makes sense generally)

Solution

If you change the configuration of your app, then you want the Deployment to restart your pods.

@felixhummel
felixhummel / pre-commit
Created March 10, 2019 21:30
terraform pre-commit hook to format staged .tf files
#!/bin/bash
# License: WTFPL
set -euo pipefail
# "--diff-filter d" excludes deleted files from this list
files=$(git diff --cached --diff-filter d --name-only -- "*.tf")
for f in $files; do
terraform fmt "$f"
git add "$f"