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 / LICENSE.txt
Last active February 8, 2024 21:16
openWRT automatic Wake on LAN
The MIT License (MIT)
Copyright (c) 2015 Felix Hummel
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
@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 / 418.conf
Created February 23, 2016 10:02
the last nginx config you will ever need
server {
listen 80 default_server;
location / {
default_type text/plain;
return 418 "418 I'm a teapot\n";
}
}
@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: