Skip to content

Instantly share code, notes, and snippets.

@jk
jk / README.md
Last active February 22, 2025 07:40
Use an internal

To use your internal docker hub pull cache, you need to change the config of your docker clients.

In /etc/daemon.json:

{
    "registry-mirrors": [
        "https://dockerhub-cache.example.tld"
    ]
}
@jk
jk / install.sh
Created February 15, 2025 15:53
RWTH USGerman Keyboard Layout via Homebrew
brew create "https://hci.rwth-aachen.de/get-attachment/2764?fallback=/files/migrated/files/USGerman-Keyboard-Layout-0.98-Retina.zip&filename=USGerman%20Keyboard%20Layout%200.98%20Retina.zip" --set-name usgerman-keyboard-layout
brew uninstall usgerman-keyboard-layout
brew install --build-from-source /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/u/usgerman-keyboard-layout.rb
@jk
jk / docker-compose.yml
Created January 9, 2025 14:30
IPv64 provider and secrets handling
version: "3.8"
services:
traefik:
image: traefik:v3.1
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
@jk
jk / klbs.bash
Created December 19, 2024 14:11
Kubernetes: Show all load balancer object types with it external IP and ports for a given or all namespaces
klbs() {
local namespace_flag
if [ -n "$1" ]; then
namespace_flag="-n $1" # Set -n <namespace>, if a namespace was given
else
namespace_flag="--all-namespaces" # Default: Show all namespaces
fi
{
printf "NAMESPACE\tNAME\tEXTERNAL-IP\tPORT(S)\n"
@jk
jk / update-mqtt.sh
Created December 10, 2024 08:11
Update MQTT server on multiple shelly relays at once
#!/bin/bash
# Liste der Shelly-IP-Adressen
shelly_ips=("172.19.2.6" "172.19.1.3" "172.19.1.5" "172.19.0.5" "172.19.3.3" "172.19.0.15" "172.19.0.13" "172.19.0.14")
# Neue MQTT-Konfiguration
mqtt_server="mqtt.example.tld:1883"
for ip in "${shelly_ips[@]}"; do
server=$(curl -s -X POST -d '{"id":1, "method":"Mqtt.GetConfig"}' http://$ip/rpc | jq .result.server)
@jk
jk / kubectl-get-shortnames.sh
Created June 12, 2024 08:53
Get a sorted list of kubectl get shortnames
kubectl api-resources --no-headers | awk -F' ' '{if (NF == 5) {shortname=$2; name=$1; kind=$5} else if (NF == 4) {shortname=""; name=$1; kind=$4} else {shortname=$2; name=$1; kind=$4} if (shortname != "") print shortname "\t" name "\t" kind}' | sort | uniq | column -t
@jk
jk / check_etchosts.sh
Last active May 24, 2024 08:59
Shell script to check syntax of /etc/hosts
#!/bin/zsh
# Function to validate each line of /etc/hosts
validate_line() {
local line="$1"
# Regular expression to match valid IP address and hostname entries, including comments
if [[ "$line" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}([[:space:]]+([a-zA-Z0-9.-]+,?)+)+$ ]] || [[ "$line" =~ ^::1([[:space:]]+([a-zA-Z0-9.-]+,?)+)+$ ]] || [[ "$line" =~ ^#.* ]]; then
echo "Valid: $line"
else
echo "Invalid: $line"
@jk
jk / !README.md
Created April 22, 2024 09:02
Generate IPv6 address from IPv6 prefix and interface's MAC address

Generate IPv6 address from IPv6 prefix and interface's MAC address

More or less like what SLAAC is doing, but without relying on the router advertisment.

Installation

pip install netifaces
@jk
jk / keybase.md
Created July 5, 2023 19:09
keybase.md

Keybase proof

I hereby claim:

  • I am jk on github.
  • I am jenskohl (https://keybase.io/jenskohl) on keybase.
  • I have a public key ASCJQngNFVFpJ0E9EF6huIW-XMK7ylP7mUlcTa0jMKgpbAo

To claim this, I am signing this object:

@jk
jk / kagi-summarizer-bookmarklet.js
Created February 12, 2023 12:23
Kagi Universal Summarizer Bookmarklet for every Browser that supports it
javascript:q=location.href;if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;void(open('https://labs.kagi.com/ai/sum?url='+encodeURIComponent(q),'Kagi Universal Summarizer','toolbar=no,width=710,height=685'));