Skip to content

Instantly share code, notes, and snippets.

View zouppen's full-sized avatar

Joel Lehtonen OH64K zouppen

View GitHub Profile
@zouppen
zouppen / README.md
Last active February 21, 2025 10:07
How to setup a minimal diskless Debian initramfs with debootstrap for QEMU or iPXE

How to setup a minimal diskless Debian (year 2022 style)

This guide helps you to setup a minimal stateless and diskless Debian initramfs with debootstrap. It is suitable for running from QEMU or network booting with (e.g. with iPXE).

This guide is for amd64 architecture.

Motivation

@zouppen
zouppen / taikavehje.sh
Created September 1, 2022 22:42
A compact example how to convert rows to JSON objects in shell & jq
#!/bin/sh -eu
export ydin=`uname -r`
export os=`uname`
lspci | jq -Rs '{os: env.os, ver: env.ydin, laitteet: split("\n") | map(capture("^[^ ]* (?<key>[^:]*): (?<value>.*)$") ) | from_entries}'
@zouppen
zouppen / README.md
Last active April 10, 2022 22:32
GPIO state change tool for scripting.

GPIO interrupt polling

This useful little tool checks for changes in GPIO state without periodic polling by using the interrupt interface provided by Linux. It's useful in scripts to wait for a state change with Raspberry Pi, but works with any hardware with GPIOs.

Public domain.

To make this work, you need to export the pin and then enable interrupts. For example:

@zouppen
zouppen / balance.py
Last active February 21, 2022 16:29
Write all addresses in Electrum wallet containing 0.1 BTC to file
# Write all addresses containing 0.1 BTC to file
with open('/tmp/addresses.txt', 'w') as f:
f.write("\n".join([addr for addr in listaddresses() if wallet.get_addr_balance(addr)[0] == 10000000]))
# List all coins having balance of 0.1, with label starting with letter L containing transactions between blocks 395000 and 400350, inclusive.
[addr for addr in listaddresses() if wallet.get_addr_balance(addr)[0] == 10000000 and wallet.get_label(addr)[0] == 'L' and any([tx[1] >= 395000 and tx[1] <= 400350 for tx in wallet.get_address_history(addr)])]
@zouppen
zouppen / README.md
Last active September 16, 2024 06:24
Listen to DTMF in Asterisk and pass code to SSH for validation

Asterisk DTMF door opener

This is a script which listens to DTMF tones and collects 6-digit PIN code and passes it to given SSH server for processing. The server is also responsible of doing the action if it's correct. So, the correct codes are never stored on the PBX but on a remote system accessible via SSH key pair. The PIN code is passed as an argument to the command.

Why this and not just a caller ID check?

Caller IDs are so easy to fake, not only by phone phreaks but anyone with a plain web browser and some cryptocurrencies when you know where to go. So you should NEVER use caller phone number as an identification method. A better option is to

@zouppen
zouppen / update
Last active January 19, 2021 23:34
Sources for generating covid-19 vaccines to total cases
#!/bin/sh -eu
curl -o vaccines.json https://dynamic.hs.fi/2020/corona-embed-grid/vaccinesGlobalLatest.json
curl -o overview.json https://dynamic.hs.fi/2020/corona-embed-grid/overviewData.json
jq -r --slurpfile overview overview.json -f vaccines_to_cases_ratio.jq vaccines.json >ratios.csv
@zouppen
zouppen / plate.scad
Last active October 28, 2020 17:57
Openscad kind of sucks in verbosity
bottom_hole_dist = 120;
bottom_rise = 10;
width = 205;
height = 115;
rounding_w = 200;
rounding_h = 110;
rounding_r = 10;
max_depth = 80;
plateau_depth = 5;
hole_d = 3;
@zouppen
zouppen / README.md
Last active September 13, 2024 09:35
Push to talk microphone with Pulseaudio

Microphone PTT for Pulseaudio

This tool helps you with many absolutely proprietary software which doesn't include proper push-to-talk key. I wrote this with Google Meet in mind but is also useful for many other browser based apps as well.

It works so that when Caps Lock is held down, the microphone is unmuted. If you want to toggle it (for example during a demonstration), just press Ctrl + Caps Lock.

@zouppen
zouppen / plumb
Last active December 9, 2019 15:20
IRCNet - Matrix plumbing tool
#!/bin/sh -eu
#
# Change your IRC nickname and Matrix ID here
nick=Zouppeni
mxid='@zouppen:jkl.hacklab.fi'
if test $# -ne 2; then
echo Usage $0 IRC_CHANNEL ROOM_ID >&2
exit 1
fi
@zouppen
zouppen / merge-helper
Last active October 17, 2019 10:30
Git merge helper for merging multiple branches on a test branch
#!/bin/sh -eu
#
# Usage: merge-helper base_branch branches_to_merge...
# Example: merge-helper lamassu/dev dockerify ui-fixes
git diff-index --quiet HEAD && stash= || stash=1
test $stash && git stash
git checkout -B wip-`whoami` "$1"
tgt="$1"
shift