Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View suhlig's full-sized avatar
😻
Happy

Steffen Uhlig suhlig

😻
Happy
View GitHub Profile

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 / install-tmux
Last active October 12, 2023 21:25 — forked from philipsd6/install-tmux
Install tmux on rhel/centos
# Install tmux on rhel/centos 7
# What do we want?
libeventversion=2.1.11
tmuxversion=3.1
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
@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" ] }
@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 / build-and-launch-dlv.bash
Created June 4, 2022 16:39
Use VS Code to debug a go program that is running externally
# see also https://github.com/go-delve/delve/tree/master/Documentation/api/dap
go build -o plaintweet-darwin \
&& dlv exec --headless --log --api-version 2 --listen localhost:42353 -- ./plaintweet-darwin serve
@suhlig
suhlig / attributes.j2
Created February 20, 2023 20:35
Dealing with attributes in HA templates
{% set SENSOR = 'device_tracker.hexa' -%}
{{ SENSOR }} manufactured by {{ device_attr(SENSOR, 'manufacturer') }}
Attributes:
{% for attr in states[SENSOR].attributes -%}
- {{ attr }}: {{state_attr(SENSOR, attr)}}
{% endfor %}
hexa has {{ state_attr('device_tracker.hexa', 'AP SSID') }}
@suhlig
suhlig / concourse-container-metrics.markdown
Created January 15, 2023 10:01
Pulling simple container metrics with jq
  • Container count by pipeline

    $ fly -t uh cs --json | jq -r '[group_by(.pipeline_name)[] | {(.[0].pipeline_name): length }] | add'
    {
      "concourse-resource-proxy": 2,
      "concourse-rss-resource": 2,
      "env-sensors": 7,
      "forwardemail-webhook-rs": 2,
      "mosquitto-prometheus-exporter": 7,
@suhlig
suhlig / qrencode.sh
Last active September 10, 2022 09:24
Encode the clipboard content as QR code and show it in Preview
# adapted from https://twitter.com/David3141593/status/1509457643206811652
pbpaste | qrencode -o - | open -fa Preview
# terminal only
pbpaste | qrencode -t UTF8 -o -
@suhlig
suhlig / totp-qrencode.sh
Created August 30, 2022 11:10
Generate 2FA auth code from known secret
pbpaste | xargs -I {} qrencode -t UTF8 -o - 'otpauth://totp/github.com/suhlig?secret={}&issuer=GitHub'