Skip to content

Instantly share code, notes, and snippets.

View cfstras's full-sized avatar

Claus F. Strasburger cfstras

  • Düsseldorf, Germany
  • 21:01 - 2h ahead
View GitHub Profile
@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

@cfstras
cfstras / 1_Using_Go_from_Rust.md
Last active December 3, 2023 22:01
Building & Calling go code from rust.

Using Go code from within Rust

This example, mostly stolen adapted from arranfrance.com, shows how to easily call into some go code from Rust.

Disclaimer: I have not used this in production, and would advise cautiosly reviewing ABI guarantees and threading considerations before doing so. For toy programs, and fun stuff such as solving half of an Advent-of-Code day in a second language, it seems to work without issues.

Main actors:

  1. main.go: Your Go code, with at least one exported CGo function. You can also import other go library as you wish.

The script below is a rough outline to start using bpf tools on a WSL installation.

Sadly, WSL kernels don't ship with kernel headers, and there are also no pre-built perf packages available in the standard debian&ubuntu package repositories. They also do not seem to be built with bpf support enabled. So, in order to run both perf and any bpf tools from the great BPF Compiler Collection (bcc), we have to build all these things ourselves.

Hopefully you have a reasonably fast computer. This takes about half an hour total on a 32-core threadripper.

@cfstras
cfstras / _lima-on-m1.md
Last active January 30, 2024 17:11
Lima M1

Note (2024): I've used this for a while to get a reasonably workable Docker installation on my M1 MacBook. For simplicity I use colima nowadays. The setup below should still work though.


  1. Install lima
    brew install lima

Summary: This is a short how-to in German on using Google Compute Engine to host a Windows machine for Cloud Gaming with Parsec. I wrote it in April 2021, so it might be outdated and broken by now.


Hallo zusammen! Da ich sehr erfreut darüber bin, möchte ich dieses howto teilen, wie ich in einer Google-Cloud-Maschine zocken kann.

  1. GCP account erstellen: console.cloud.google.com
  2. Quota increase request für Compute Engine GPU (All Regions) auf 1 machen. nur 1! alles andere wird abgelehnt! Der Request sollte innerhalb von 5min per mail approved werden.