Skip to content

Instantly share code, notes, and snippets.

View suhlig's full-sized avatar
😻
Happy

Steffen Uhlig suhlig

😻
Happy
View GitHub Profile
@suhlig
suhlig / CONVENTIONS.md
Last active May 31, 2026 11:42
My Coding Conventions

Ground Rules

You are not my assistant. You are my advisor who happens to be smarter than me. Follow these rules in every reply:

  1. Never start with agreement. Your first sentence must challenge my assumption, point out what I'm missing, or ask a question that exposes a gap in my thinking.
  2. Rate your confidence. Before any claim, tag it [Certain] if you have hard evidence, [Likely] if it's a strong inference, [Guessing] if you are filling gaps. If most of your reply is guessing, say so first.
  3. Kill these phrases for good: "Great question", "You're absolutely right", "That makes a lot of sense", "Absolutely", "Definitely". If you catch yourself typing one, delete and rewrite.
  4. Disagree with structure. When I'm wrong, say: "I disagree because [reason]. Here's what I'd do instead [alternative]. The risk in your approach is [specific downside]."
  5. Give me the uncomfortable answer first. If there's a truth I probably don't want to hear, lead with it. First line, not buried in paragraph three.
  6. No warm
@suhlig
suhlig / delve.sh
Created July 15, 2025 13:52
Running delve for cli and ginkgo tests
# if there is a main.go that accepts "status" as first argument, start the debugger like this:
dlv debug --headless --log --api-version 2 --listen localhost:2345 . -- status
# if there is a Ginkgo test in the foo directory (package example.com/foo)
dlv test --headless --log --api-version 2 --listen localhost:2345 example.com/foo
@suhlig
suhlig / show-systems-json-messages.markdown
Created July 27, 2024 17:30
Systemd can print logs as JSON, making custom log formats simple. In addition, if the messages themselves are JSON, jq can unescape them.
$ journalctl -u concourse-web -f -o json | jq '.MESSAGE | fromjson'
{
  "timestamp": "2024-07-27T17:29:50.525878425Z",
  "level": "info",
  "source": "atc",
  "message": "atc.scanner.tick.start",
 "data": {
@suhlig
suhlig / fetch_file_content_at.go
Created July 24, 2024 21:35
Fetch content of a file from GitHub at a given committish
package main
import (
"context"
"encoding/base64"
"fmt"
"log"
"os"
"github.com/google/go-github/v63/github"
curl -L $(curl -L https://api.github.com/repos/derailed/k9s/releases/latest | jq --raw-output '.assets[] | select(.name == "k9s_Linux_amd64.tar.gz") | .browser_download_url') | tar xz k9s
@suhlig
suhlig / b2-buckets-by-size.sh
Last active May 5, 2024 11:07
Table of b2 buckets sorted by total size
b2 list-buckets --json \
| jq '.[].bucketName' \
| xargs -n 1 b2 get-bucket --showSize \
| jq -r --slurp '["name","size"], (.[] | [.bucketName, .totalSize]) | @csv' \
| qsv sort --numeric --reverse --select size \
| qsv table

Example for a Concourse pipeline triggered my a webhook

Assmuming this pipeline was set as

$ fly --target example set-pipeline --pipeline manual-trigger --config manual-trigger.yml

then you can trigger a new build with

@suhlig
suhlig / go-work-update-all.sh
Last active November 14, 2023 15:00
Update dependencies of all modules in a go workspace
go work edit -json \
| jq --raw-output '.Use.[].DiskPath' \
| xargs -I MODULE zsh -o errexit -c "
cd MODULE
pwd
go get -d -u -t ./...
go mod tidy
[ -d vendor ] && go mod vendor
"
@suhlig
suhlig / tasmota-discover.sh
Created June 9, 2023 10:18
Discover Tasmota devices using MQTT
timeout 2 \
mosquitto_sub \
--url 'mqtts://user:password@mqtt.example.com/tasmota/discovery/+/config' \
-F %J \
| jq -r '[ .payload.dn, .payload.ip ] | join(" => ")'
@suhlig
suhlig / concourse-fail-step.yml
Last active July 31, 2023 17:41
Make a Concourse job fail so that we can inspect it
- task: fail-for-inspection
config:
platform: linux
image_resource: { type: mock, source: { mirror_self: true } }
run: { path: sh, args: [ -c , "false" ] }