Skip to content

Instantly share code, notes, and snippets.

View jenrik's full-sized avatar
🐧

Jener Rasmussen jenrik

🐧
View GitHub Profile
@jenrik
jenrik / LICENSE
Last active October 10, 2026 15:37
Immich Bulk Rotate Tampermonkey userscript
MIT License
Copyright (c) 2026 Immich Bulk Rotate contributors
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:
@jenrik
jenrik / gh-app-token.py
Created July 30, 2025 12:13
Generate signed JWT for a Github App
#!/usr/bin/env python3
import sys
import time
import jwt
# Get PEM file path
if len(sys.argv) > 1:
pem = sys.argv[1]
else:
@jenrik
jenrik / reach.sh
Last active April 7, 2025 08:31
Kubernetes netpol access analyzer
#!/usr/bin/env bash
set -e
# Description:
# Check which NetworkPolicies, if any, that block connection between to workloads in a Kubernetes cluster
# Requires: https://github.com/kubernetes-sigs/network-policy-api/tree/main/cmd/policy-assistant
# Requires: fzf
SRC_NS="$(kubectl get ns -o custom-columns='NAME:.metadata.name' --no-headers | fzf --height ~50% --prompt "SRC Namespace> " --border)"
@jenrik
jenrik / kubectl-badpdb
Last active February 6, 2025 09:31
Find PDBs guarding single pods
#!/bin/sh
set -e
if ! type jq 2>/dev/null 1>/dev/null; then
echo "jq command is required, please install it" >&2
exit 1
fi
kubectl get pdb -A -o json | \
jq -r '.items[] | {name: .metadata.name, namespace: .metadata.namespace, selector: ((.spec.selector.matchLabels // {} | to_entries | .[] |= "\(.key)=\(.value)") + (.spec.selector.matchExpressions // [] | .[] |= .key + " " + (.operator | ascii_downcase) + " (" + (.values[] | @json) + ")")) | join(",") }' -c | \
@jenrik
jenrik / kubectl-getall
Last active February 1, 2025 12:03
List all resources, including custom resources, in a Kubernetes namespace
#!/bin/sh
set -e
NAMESPACE="$1"
if [ "${NAMESPACE}x" = "x" ]; then
echo "usage: $(basename "$0") <namespace>" >&2
exit 1
fi
kubectl api-resources --namespaced -o name | while read -r resource; do
@jenrik
jenrik / spaghetti-detector.yaml
Last active January 21, 2025 23:41
AI Spaghetti detection for Bambu Lab P1 and A1 series printers using Home Assistant and Obico
blueprint:
name: 3D printer spaghetti detector
domain: automation
input:
printer_status:
name: Printer current stage entity
selector:
entity:
filter:
- domain: sensor
@jenrik
jenrik / kube-units.jq
Last active March 11, 2025 12:35
Normalize Kubernetes units to plain numbers
def k8sunits: capture("(?<num>\\d+)(?<unit>.*)") | (.num | tonumber) * {"": 1, "Ki": 1024, "K": 1000, "Mi": pow(1024; 2), "M": pow(1000; 2), "Gi": pow(1024; 3), "G": pow(1000; 3), "Ti": pow(1024; 4), "T": pow(1000; 4), "Ei": pow(1024; 5), "E": pow(1000; 5), "Pi": pow(1024; 6), "p": pow(1000; 6), "m": 0.001}[.unit];
@jenrik
jenrik / resources.yaml
Created August 19, 2024 07:15
Kubernetes iperf test
---
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: iperf-test
component: client
name: iperf-test-client
spec:
template:
sep()
{
(
if type "cowsay" > /dev/null < /dev/null; then
cowsay "separator"
cowsay "separator"
cowsay "separator"
else
echo "*-----------*"
echo "| separator |"
@jenrik
jenrik / utime.sh
Last active March 7, 2023 19:08
Multifunction timestamp tool
function utime()
{
if [ $# = 1 ] && ([ "${1:0:1}" = "+" ] || [ "${1:0:1}" = "-" ]) && [ "$1" != "--help" ]
then
# Do date math
date -d "$1" "+%s"
elif [ $# = 1 ] && (echo "$1" | grep -P "^[[:digit:]]+$" > /dev/null)
then
# Convert timestamp to human-readable date
date -d "@$1" || help