Skip to content

Instantly share code, notes, and snippets.

View cfstras's full-sized avatar

Claus F. Strasburger cfstras

  • Düsseldorf, Germany
  • 19:52 (UTC +01:00)
View GitHub Profile
@cfstras
cfstras / usb-ether.sh
Last active January 25, 2026 14:44 — forked from dafta/usb-ether.sh
Steam Deck USB Ethernet
#!/bin/bash
set -euo pipefail
if [[ "$UID" -ne 0 ]]; then
echo "This script needs to be executed as root"
exit 1
fi
vendor_id="0x3000" # Valve
@cfstras
cfstras / -bsd-tar.md
Created December 18, 2025 08:43
BSD Tar with zstd (macOS)
tar -cv --zstd --options zstd:compression-level=22 --options zstd:threads=0 -f archive.tar.zstd files_to_compress/

Tested with bsdtar 3.5.3 (macOS 15.7.1)

@cfstras
cfstras / -terraform-import-existing-kubectl-manifests.sh
Last active October 14, 2025 10:42
Hack to manually re-import kubectl manifests that are already existing in the cluster
#!/bin/bash
set -euo pipefail
backup() {
terraform state pull > state-$(gdate -Iseconds)
}
plan() {
backup
terraform plan -out=tfplan && terraform show -json tfplan | jq . > tfplan.json
@cfstras
cfstras / -cardinality-of-prometheus-metrics
Created June 30, 2025 11:56
Cardinality overview of prometheus metrics
#!/bin/bash -euo pipefail
## Gives you a nice overview over the total timeseries cardinality of a prometheus endpoint.
curl -fsSL http://localhost:9100/metrics | grep -v '^#' | cut -d'{' -f 1 | cut -d' ' -f 1 | sort | uniq -c | sort -gr
public class DateTimeInsanityTests
{
[Fact]
public void YourDateTimeIsInsane()
{
var t = new DateTime();
// Does not throw
Console.WriteLine(new DateTimeOffset(t.ToUniversalTime()));
@cfstras
cfstras / -python-uv-project-shebang.py
Created April 14, 2025 15:34
A special shebang header for python scripts that want to use uv with a pyproject.toml, but be called from any directory.
#!/usr/bin/env sh
# Special shebang: almost the same as just `uv run`, but always use the script directory to search for pyproject.toml.
# The following lines are ignored by python, and executed by bash
# Use `set -x` if you want to see what's happening
""":"
set -eu
exec uv run --project=$(dirname "$0") "$0" "$@"
"""
###
@cfstras
cfstras / -often-used-package-manager-aliases.md
Created July 12, 2024 13:55
Often-used aliases for common package managers. Add them to your bashrc/zshrc! Never think about which OS you're currently using!

Often-used aliases for common package managers.

Add them to your bashrc/zshrc! Never think about which OS you're currently using!

Usage:

sea some key words
@cfstras
cfstras / -Custom styles for SevDesk.md
Last active April 2, 2024 09:38
Custom Styling for SevDesk on laptop screens

SevDesk is a useful tool, but on my 13" MacBook, I find it wastes too much whitespace on menu elements and such, which makes it hard to keep an overview.

These styles can easily be applied using StyleBot or your CSS-tweaking tool of choice.

Some aspect ratios will look yanky with this applied, so YMMV.

Firefox userChrome.css for macOS & Tree Style Tab

  • for use with Tree Style Tab
  • high space utilization on small displays by reducing the height of the title bar

I like it this way.

image

Parsing SML Energy Meter Values for Loxone Miniservers

This is a custom PicoC program to parse the SML energy readings in a tibber+Loxone setup.

Our system runs a [tibber Pulse], connected to a [EMH ED300L][ED300L] energy meter. We run this code on a [Loxone Miniserver][loxone], which can run custom PicoC code.

We use the TCP stream method to read the current SML data packet from the tibber bridge

Getting started