Skip to content

Instantly share code, notes, and snippets.

View joerx's full-sized avatar
💭
I may be slow to respond.

Jörg Henning joerx

💭
I may be slow to respond.
  • Transferwise
  • Singapore
View GitHub Profile
@joerx
joerx / config.alloy
Created September 15, 2025 04:53
Alloy Config
prometheus.exporter.self "alloy_check" { }
discovery.relabel "alloy_check" {
targets = prometheus.exporter.self.alloy_check.targets
rule {
target_label = "instance"
replacement = constants.hostname
}
@joerx
joerx / spotify.js
Created March 4, 2025 12:51
Obsidian user script for spotify API integration
const CLIENT_ID = '...';
const CLIENT_SECRET = '...';
const refreshToken = '...'
async function refreshAccessToken() {
const tokenData = `${CLIENT_ID}:${CLIENT_SECRET}`;
const base64token = btoa(tokenData);
const data = new URLSearchParams();
@joerx
joerx / main.go
Last active December 27, 2024 07:10
Go Middleware Chains
package main
// Loosely based on https://www.alexedwards.net/blog/making-and-using-middleware
// and https://blog.questionable.services/article/guide-logging-middleware-go/
// Similar to https://github.com/justinas/alice but more minimalist :)
import (
"log"
"net/http"
)
@joerx
joerx / main.go
Created November 18, 2024 04:37
Basic Golang HTTP Server
package main
import (
"log"
"net/http"
)
func main() {
handler := &myHandler{}
mux := http.NewServeMux()
@joerx
joerx / README.md
Last active December 13, 2022 16:24

Minimalistic Development Box with Libvirt

Linux only, requires KVM and QEMU. libvirt and related components need to be installed. Provisions a development VM based on Ubuntu 20.04. Current working directory will be shared with the guest. This is a PoC, not intended to be a fully functional tool. For any serious use case, use something like Vagrant

@joerx
joerx / shorten.sh
Created August 17, 2020 12:01
Shorten AWS region name using regex
echo "eu-central-1" | sed -E s'/([a-z]{2})-([a-z]{1})[a-z]+-([0-9]{1})/|\1\2\3|/' # 'euc1'
{
"[terraform]": {
"editor.formatOnSave": true,
"editor.tabSize": 2
},
"terraform.indexing": {
"enabled": false,
"liveIndexing": false,
"delay": 500,
"exclude": [
@joerx
joerx / gist:6e398bb26e5527a948647a15cb76f7f3
Last active November 30, 2019 09:18
Russian roulette, Terraform edition. Because `rm -rf /` doesn't quite cut it anymore.
RISK=5
[[ $(( ( RANDOM % 6 ) + 1 )) -gt $RISK ]] && echo "terraform destroy -target module.production_db -auto-approve"
# for discussion and alternatives, see https://unix.stackexchange.com/questions/227662/how-to-rename-multiple-files-using-find
find . -type f -name general.tf -not -path '*/.terraform/*' -exec sh -c 'x="{}"; mv "$x" "${x/general/backend}"' \;
@joerx
joerx / psql.md
Last active July 22, 2019 11:02
Postgres Cheat Sheet

List databases

\list
\l

Connect