Skip to content

Instantly share code, notes, and snippets.

View bash POST

One-liner to accept incoming http POST data and then relay it to some number of POST endpoints.

while true; do printf 'HTTP/1.0 200 OK\r\nContent-Length: 0\r\n' | { nc -q1 -l 8080; echo; } | sed '0,/^[[:space:]]*$/d' | tee >(http POST http://localhost:8081/path1) >(http POST http://localhost:8081/path2); done

With some linebreaks so it's readable:

while true
dannysauer /
Last active Dec 1, 2021
misc kubernetes / k8s junk
function kubectlgetall {
kubectl -n ${1:?usage: ${FUNCNAME[0]} <namespace>} get --ignore-not-found $( \
kubectl api-resources --verbs=list --namespaced -o name \
| grep -v --line-regexp -e "" -e "events" \
| sort -u \
| paste -sd, \

Upgrade Hassbian installation to Debian Bullseye in order to get python 3.9

Update OS. Follow another guide, except also remember to update all of the other /etc/apt/sources.list.d/ files too. :) Note that there is no hassbian-scripts repo for bullseye, so just leave that one at buster.

Update hassbian-scripts, which likely got removed at the automremove step - removing your systemd unit and all sorts of other things. The scripts package available on gitlab is broken, but there's a fork with a few fixes (primarily python package deps).

git clone
cd hassbian-scripts
dannysauer / gitconfig.ini
Created Mar 10, 2021
git tag promotion aliases
View gitconfig.ini
✔ /tmp/testrepo [main L|✔]
10:04 $ sed -n '/alias/,$p' .git/config
show-tag-date = tag --list --format "%(taggerdate:unix)"
flux-latest-stage-tag = describe --abbrev=0 --tags --match 'stage/*' main
flux-latest-prod-tag = describe --abbrev=0 --tags --match 'prod/*' main
flux-state = show --oneline --no-patch main stage prod
# git flux-rollback [stage|prod]
flux-rollback = "!git branch -f $1 $( git describe --abbrev=0 --tags --match="$1/*" ${1}^ ) && git tag -m \"rollback $1\" ${1}/$(date +'%F-%H-%M-%S')/rollback $1 #"
flux-stage = !git tag -m 'promote to stage' stage/$(date +'%F-%H-%M-%S') refs/heads/main && git branch -f stage $( git flux-latest-stage-tag )
#!/usr/bin/env python3
import random
from base64 import b64encode
from kubernetes import client, config
from string import ascii_letters
from timeit import timeit
v1 = client.CoreV1Api()
dannysauer /
Last active Mar 1, 2021
K8S secret storage "benchmark"
set -o errexit
apiVersion: v1
kind: Secret
name: secret$I

Keybase proof

I hereby claim:

  • I am dannysauer on github.
  • I am dannysauer ( on keybase.
  • I have a public key ASB_nYLw_XvDJ7TQ9OQQDjxS5QMqfCd_UL8z_jbXKWpFwAo

To claim this, I am signing this object:

dannysauer /
Created Dec 28, 2020
windows Linux setup
View importscannerdisk.service
# /etc/systemd/system/importscannerdisk.service
Description=Import images from scanner SSD card
dannysauer /
Created Jul 30, 2020
Script to sync fork's head branch with upstream

When I fork a repo, I checkout out my fork as origin and add a remote for the upstream repo as upstream. I hate having a fork where the default (usually called master) branch is way out of date, though. So this gets run from a scheduler to walk through checked out repos under a couple of directories in $HOME/dev, figure out the default branch, and sync that with the same-name branch in my fork.

The main interesting thing it does is to use a worktree. So it doesn't need to check out the whole repo again, but also doesn't disturb my main working repository. It also uses a unique temporary directory and a branch with the same name to do the sync, as I couldn't get it to work properly without creating a branch. I could swear I had made that work before (completely avoiding a branch name), but I can't for the life of me remember how. :D The tempname should be unique enough.