Skip to content

Instantly share code, notes, and snippets.

View rudolfbyker's full-sized avatar
🌍
The grass withers, the flower falls, but the word of the Lord remains forever.

Rudolf Byker rudolfbyker

🌍
The grass withers, the flower falls, but the word of the Lord remains forever.
View GitHub Profile
@rudolfbyker
rudolfbyker / example.py
Created October 1, 2024 20:00
Combining logs from multiple processes in Python
import multiprocessing
from logging import LogRecord, getLogger, Logger, DEBUG
from logging.handlers import QueueHandler
from queue import Queue
from typing import Optional, TypedDict, List
from .log_combiner import log_combiner_thread
logger = getLogger(__name__)
@rudolfbyker
rudolfbyker / README.md
Created August 16, 2024 06:59
Backup and restore ZFS PVCs on Kubernetes

Backup and restore ZFS PVCs on Kubernetes

Dump all ZFS PVCs to files:

for name in $(zfs list -H -o name | grep pvc); do zfs snapshot $name@snap1; zfs send $name@snap1 | pv | gzip > ${name##*/}.gz; done

Restore a ZFS dataset from a file:

@rudolfbyker
rudolfbyker / README.md
Last active May 25, 2024 10:45
Hosting Unturned on Kubernetes

Hosting Unturned on Kubernetes

Helm chart

@rudolfbyker
rudolfbyker / author.sh
Created March 30, 2024 08:12
How to mux a DVD
dvdauthor -t -o author walle_remuxed_3.mpg
export VIDEO_FORMAT=NTSC
dvdauthor -T -o author
@rudolfbyker
rudolfbyker / remove-drivers.py
Created November 2, 2023 07:26
Remove drivers newer than a given date from Windows
from __future__ import annotations
from typing import Generator, TypedDict
from subprocess import run, CalledProcessError
import re
import logging
from datetime import date, datetime
import click
import yaml
logger = logging.getLogger(__name__)
@rudolfbyker
rudolfbyker / grab_uart.sh
Created August 16, 2023 13:34
Wait for UART device, read it, and dump the received data to a text file and to the screen
#!/bin/bash
set -eu
DEVICE="$1" # e.g.: /dev/ttyUSB0
BAUD_RATE="$2" # e.g.: 115200
OUTPUT_FILE="$3" # e.g.: uart.txt
echo "Waiting for $DEVICE to become available ..."
while true
@rudolfbyker
rudolfbyker / purge.sh
Last active January 26, 2022 21:35
Linux ffmpeg background audio recorder
#!/usr/bin/env bash
# Delete old recordings.
DIR="$HOME/rec"
EXPIRE=7
find $DIR -mtime +$EXPIRE -type f -delete
@rudolfbyker
rudolfbyker / find_silence.py
Created October 4, 2021 18:58
Find silences in audio samples
import numpy as np
def find_silences_of_minimum_length(data: np.array, min_length: int) -> Generator[Tuple[int, int], None, None]:
"""
Get a (start, stop) tuple for each detected silence of minimum length.
The start is inclusive, and the stop is exclusive, to match Python's list slicing.
>>> list(find_silences_of_minimum_length([1,0,1], 1))
[(1, 2)]
@rudolfbyker
rudolfbyker / FieldTypeUpdateUtil.php
Created August 3, 2021 15:53
Utilities for updating Drupal field type definitions.
<?php
namespace Drupal\my_module;
use Drupal;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
/**
* Utilities for updating field type definitions.
*