Skip to content

Instantly share code, notes, and snippets.

View tsjk's full-sized avatar

Tamas Jantvik tsjk

View GitHub Profile
"Fiction" titles for Lund (Audio)Book Club Meetup Group 20240318
Waris Dirie, Cathleen Miller - Desert Flower (1998) {256pp} [https://www.goodreads.com/book/show/8745.Desert_Flower]
Sarah Bradford - Queen Elizabeth II: Her Life in Our Times (2011) {320pp} [https://www.goodreads.com/book/show/13153168]
Alan Cumming - Not My Father's Son (2014) {292pp} [https://www.goodreads.com/book/show/22934446]
Michelle Obama - Becoming (2018) {426pp} [https://www.goodreads.com/book/show/38746485]
Gregory Zuckerman - The Man Who Solved the Market: How Jim Simons Launched the Quant Revolution (2019) {359pp} [https://www.goodreads.com/book/show/43889703]
Barack Obama - A Promised Land (2020) {768pp} [https://www.goodreads.com/book/show/55361205]
Dave Grohl - The Storyteller: Tales of Life and Music (2021) {384pp} [https://www.goodreads.com/book/show/57648017]
James B. Stewart and Rachel Abrams - Unscripted: The Epic Battle for a Media Empire and the Redstone Family Legacy (2023) {416pp} [https://www.goodreads.com/book/show/6
@tsjk
tsjk / pdmn-ps.functions
Created September 29, 2023 15:53
Functions for getting process lists and process trees of podman containers from the host's perspective
function pdmn-ps() {
# With this one can do like, given a container called tor-client,
# kill -HUP $(pdmn-ps tor-client | \
# grep -F ' tor -f /config/torrc --defaults-torrc /config/torrc.custom.default' | \
# awk '{ print $2 }')
# Useful for when one has both a client and a relay, and has a smaller overhead than exec-ing into the container.
local container_pid
[[ -n "${1}" ]] && podman container exists "${1}" && { \
container_pid=$(podman inspect --format '{{.State.Pid}}' "${1}")
ps -o 'user,pid,%cpu,%mem,vsz,rss,tty,stat,lstart,time,command' \
@tsjk
tsjk / openwrt-wg0-firewall.sh
Last active September 11, 2023 06:46
Fix of WireGuard routing confusion on OpenWRT
#!/bin/sh
# Intermittently, the routing of WireGuard datagrams seem to become confused, leading to temporarily hung connections.
# This script aims to remedy this - assuming that the OpenWRT system is a
# WireGuard peer that uses the port(s) listed in WG_PORTS. E.g. (/etc/config/network):
# config interface 'wg0'
# option proto 'wireguard'
# option listen_port '51820'
# ...
#
@tsjk
tsjk / ln-fee-info.sh
Created August 22, 2023 09:39
Defines an ln-fee-info() function. Needs the uplot ruby package, sqlite3, bc, jq, working bitcoin-cli, working lightning-cli, and clboss's data. To see the response, you need to call the function.
function ln-fee-info() {
pgrep -u lightning -f '^/usr/bin/lightningd\s.*' &> /dev/null && { \
function o() {
if [[ "${1}" =~ ^.*1$ ]]; then echo "st"
elif [[ "${1}" =~ ^.*2$ ]]; then echo "nd"
elif [[ "${1}" =~ ^.*3$ ]]; then echo "rd"
else echo "th"; fi
}
local -i M N f n p x; local percentile j j_c t x_v; local -A T
local b=$(/usr/bin/timeout -k 35s 30s /usr/bin/lightning-cli --rpc-file=/run/lightning/lightningd.rpc getinfo | jq -r .blockheight)
@tsjk
tsjk / lightning-listconfigs.json
Last active June 11, 2023 13:32
lightning-listconfigs
{
"# version": "23.05-gentoo-r0",
"conf": "/etc/lightning/lightningd.conf",
"lightning-dir": "/var/lib/lightning",
"network": "bitcoin",
"allow-deprecated-apis": true,
"rpc-file": "/run/lightning/lightningd.rpc",
"plugins": [
{
"path": "/usr/bin/clboss",
@tsjk
tsjk / signal-desktop.local
Created February 7, 2023 10:28
Local profile for signal-desktop that enables its tray icon to work with firejail v0.9.72 (Tested on Gentoo) [~/.config/firejail/signal-desktop.local]
ipc-namespace
dbus-user.talk org.freedesktop.portal.Fcitx
dbus-user.talk org.freedesktop.portal.Background
dbus-user.talk org.freedesktop.Notifications
dbus-user.talk org.kde.StatusNotifierWatcher
dbus-user.own org.kde.*
env SIGNAL_DISABLE_GPU=0
env SIGNAL_DISABLE_GPU_SANDBOX=0
@tsjk
tsjk / sdparm-disable_sleep.sh
Last active January 9, 2024 20:17
Disabling of sleep on external disk using sdparm so that they do not disconnect in middle of transactions (e.g. WD_My_Book_25ED)
#!/bin/bash
# Usage: sdparm-disable_sleep.sh <device>
[[ -n "${1}" && -b "${1}" ]] \
&& sdparm --flexible --page=po -l -a "${1}" \
&& { sdparm --set=STANDBY_Z=0 -S "${1}" \
&& sdparm --set=SZCT=$((45*60*100)) -S "${1}" \
&& sdparm --flexible --page=po -l -a "${1}"; }
@tsjk
tsjk / imgbuilder-19.07.9-ar71xx-tiny.sh
Last active April 13, 2022 20:05
OpenWRT v19.07.9 extroot image for the TP-Link TL-MR3420 V2 - the easy way
#!/bin/bash
BASENAME=$(basename "${0}"); DIRNAME=$(dirname "${0}"); DIRNAME=$(realpath "${DIRNAME}");
VERSION=$(grep -oP '(?<=imgbuilder-)[0-9\.]+(?=-)' <<< "${BASENAME}")
ARCH=$(sed -E 's@^imgbuilder-[0-9\.]+-@@' <<< "${BASENAME}" | grep -oP '^[^-]+')
TYPE=$(sed -E 's@^imgbuilder-[0-9\.]+-@@; s@'"${ARCH}"'-@@' <<< "${BASENAME}" | grep -oP '^[^\.]+')
[[ -n "${VERSION}" && -n "${ARCH}" && -n "${TYPE}" ]] || exit 255
[[ ! -x "${DIRNAME}/imgbuilder-get-base-path.sh" ]] || source "${DIRNAME}/imgbuilder-get-base-path.sh"
[[ -n "${OPENWRT_IMG_BUILDER_BASE_PATH}" ]] || OPENWRT_IMG_BUILDER_BASE_PATH="${DIRNAME}/openwrt-imagebuilder-${ARCH}-${TYPE}"
@tsjk
tsjk / openwrt-v19.07.9-ar71xx-tiny-config.diff
Last active April 13, 2022 20:02
Generated OpenWRT v19.07.9 diffconfig for TP-Link TL-MR3420 V2 - with USB storage support for extroot on an f2fs-formatted USB-stick
# Usage: ( VERSION="19.07.9" && ARCH="ar71xx" && TYPE="tiny" && cd "${OPENWRT_BUILD_DIR}" && \
# wget -O './.config' "https://downloads.openwrt.org/releases/${VERSION}/targets/${ARCH}/${TYPE}/config.buildinfo" && \
# cat "${THIS_FILE}" >> ./.config && make defconfig )
CONFIG_TARGET_ar71xx=y
CONFIG_TARGET_ar71xx_tiny=y
CONFIG_TARGET_ar71xx_tiny_DEVICE_tl-mr3420-v2=y
CONFIG_ALL_KMODS=y
CONFIG_ALL_NONSHARED=y
CONFIG_DEVEL=y
CONFIG_AUTOREMOVE=y
@tsjk
tsjk / 79_usbmode
Last active August 9, 2020 13:40
/lib/preinit/79_usbmode - For pre-init USB mode switch on OpenWRT
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
# To be included in ROM image, together with at least usb-modeswitch,
# kmod-usb-storage and a /etc/usb-mode.preinit.json.
#
# Tested on OpenWRT v19.07.3
log_usbmode() {