Skip to content

Instantly share code, notes, and snippets.

View zouppen's full-sized avatar

Joel Lehtonen OH64K zouppen

View GitHub Profile
@zouppen
zouppen / ratas-v8.stl
Last active February 27, 2023 00:41
Hammasrattaan ripustin polkupyörägeneraattoriin
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zouppen
zouppen / README.md
Last active December 25, 2022 00:54
Advent of code 2022 epic häx

Advent of code 2022 epic häx

Zouppen is not trying to solve 'em all but just show some epic overoptimized stuff.

@zouppen
zouppen / README.md
Last active December 12, 2022 23:11
Command-line tool to convert Lightning Address to LN invoice

Command-line tool to convert Lightning Address to LN invoice

Usage:

lnaddress user@example.com 1000 "Thanks a lot!"

Probably not 100% compliant with LUDS but should almost fulfill LUD-01, LUD-06, and LUD-12.

@zouppen
zouppen / README.md
Last active April 17, 2024 21:52
Block incoming traffic from Tor exit nodes on Linux + ipset

Block Tor exit nodes with Linux and ipset

This gist blocks incoming traffic from Tor exit nodes. You can also use it to MARK or redirect the incoming traffic, depending of your needs.

This guide is for IPv4 only, feel free to contribute IPv6 support if you have it.

Installing

@zouppen
zouppen / README.md
Last active October 31, 2022 13:13
Throttle Raspberry Pi CPU to avoid overheating

Raspberry Pi overheating protection

If your Raspberry Pi is overheating, a common solution is to add a fan. Sometimes it's not feasible and in most cases the computer is runnning smoothly without a fan.

To limit heating, CPU throttling is a solution which keeps your computer not crashing during long compiles or so, but gives out the peak performance for shorter period of times. It depends of your application, if this is good enough solution. For me it is. I like my

@zouppen
zouppen / README.md
Last active September 16, 2022 15:25
Command line TOTP (Google Authenticator) validator

TOTP (Google Authenticator) support in shell scripts

Here is a POSIX shell compliant TOTP validator.

Requires oathtool which is available from Debian / Ubuntu repositories and probably many other distros as well.

@zouppen
zouppen / README.md
Last active September 2, 2022 11:02
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)])]