Skip to content

Instantly share code, notes, and snippets.

View theking2's full-sized avatar
🎯
contemplating the odds

Johannes Kingma theking2

🎯
contemplating the odds
View GitHub Profile
@theking2
theking2 / ppn.php
Created December 1, 2026 20:03
reverse polish notation in php
<?php
function ppn(string $expression, mixed ...$param) {
$operators = "+-*/%";
$delimiter = " ";
$expression_tokens = explode($delimiter, $expression);
$stack = [];
// Process tokens from right to left (using array_pop)
@theking2
theking2 / npm-step-proxy.sh
Last active November 24, 2026 19:11
Register a new host with step and proxy
#!/usr/bin/env bash
#
# npm-step-proxy.sh
# 1. Issues a certificate from step-ca (`step ca certificate`)
# 2. Uploads it to Nginx Proxy Manager as a custom certificate (API)
# 3. Creates a proxy host that uses that certificate
#
# Every parameter can be given as env var, as flag, or is asked interactively
# (with a default in brackets). Use -y to accept all defaults non-interactively.
#
@theking2
theking2 / README.md
Created November 22, 2026 18:38
KDE Plasma 6: Ctrl+Meta shortcuts to switch display refresh rate (24/25/30/50/60 Hz)

KDE Plasma refresh-rate shortcuts

Global shortcuts to switch display refresh rate (KDE Plasma 6, Wayland, via kscreen-doctor).

Shortcut Rate
Ctrl+Meta+2 25 Hz
Ctrl+Meta+3 30 Hz
Ctrl+Meta+4 24 Hz
Ctrl+Meta+5 50 Hz
#!/bin/bash
# Script: decode_throttled.sh
# Description: Decodes the output of 'vcgencmd get_throttled' on a Raspberry Pi
# Usage: ./decode_throttled.sh
# Run vcgencmd and capture the output
THROTTLED_HEX=$(vcgencmd get_throttled | cut -d'=' -f2)
# Remove '0x' prefix if present
#!/usr/bin/env python3
"""
Docker Container and Volume Explorer
Interactive script to list containers and their associated volumes
"""
import subprocess
import json
import sys
from typing import List, Dict, Any
@theking2
theking2 / create_signed_security_txt.sh
Created May 30, 2026 18:57
Create a signed security.txt file
# Basic usage
./create_signed_security_txt.sh -d example.com -c "mailto:security@example.com" -k ABC12345
# Full example with all options
./create_signed_security_txt.sh \
-d example.com \
-c "mailto:security@example.com" \
-k ABC12345 \
-e "https://example.com/pgp-key.asc" \
-a "https://example.com/thanks" \
@theking2
theking2 / compress.bash
Last active May 23, 2026 14:38
qcow2 Compression
#!/usr/bin/bash
# Function to get file size in human-readable format
get_size() {
du -h "$1" | cut -f1
}
# Function to get file size in bytes for calculation
get_size_bytes() {
stat -c %s "$1" 2>/dev/null || stat -f %z "$1" 2>/dev/null
@theking2
theking2 / vacuum-systemd-journal
Created May 20, 2026 14:18
Vacuum systemd journal
#!/usr/bin/env python3
"""
Interactive System Journal Vacuum Tool
This script allows you to safely clean systemd journal logs interactively.
"""
import subprocess
import sys
import os
from datetime import datetime, timedelta
@theking2
theking2 / prompt-creator.html
Created May 14, 2026 07:33
App Prompt creator
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prompt Creator</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css">
<style>
*{box-sizing:border-box;margin:0;padding:0}
:root{
@theking2
theking2 / docker_logs
Created May 3, 2026 06:41
Docker Log sizes
#!/usr/bin/env python3
"""
Docker Container Log Size Calculator
Lists all Docker containers with their log sizes and total log usage.
"""
import subprocess
import json
import sys
from typing import Dict, List, Tuple