Skip to content

Instantly share code, notes, and snippets.

View felixhummel's full-sized avatar

Felix Hummel felixhummel

View GitHub Profile
>>> 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"
@felixhummel
felixhummel / lulz.sh
Created January 24, 2019 16:51
Docker Compose Lulz
LULZ=/tmp/compose-lulz
foolulz=$LULZ/foo/lulz
barlulz=$LULZ/bar/lulz
mkdir -p $foolulz $barlulz
cat <<'EOF' > $foolulz/docker-compose.yml
version: '3.7'
services:
app:
@felixhummel
felixhummel / disk-inspect.sh
Created March 22, 2018 22:21
list physical disks and their partitions
#!/bin/bash
set -euo pipefail
# major device number 7 is loop
# grep loop /proc/devices
#disks=$(lsblk --raw --noheadings -o type,name | grep ^disk | awk '{ print "/dev/"$2 }')
# weird though: "--exclude 252" (device-mapper) does not work...
lsblk -o MAJ:MIN,UUID,SIZE,LABEL,NAME,MOUNTPOINT,FSTYPE --exclude 7 | grep -v ^252
@felixhummel
felixhummel / README.md
Created February 18, 2018 03:53
opendkim salt

Generate the key-pair:

salt-call state.apply postfix.opendkim_genkey

Get the public key and set it on your DNS server:

salt-call file.read /etc/opendkim/keys/felixhummel.de/mail.txt