Skip to content

Instantly share code, notes, and snippets.

View leonrinkel's full-sized avatar

Leon Rinkel leonrinkel

View GitHub Profile
@leonrinkel
leonrinkel / patch-initrd.sh
Created January 12, 2025 13:54
patch segmented initrd/initramfs
#!/bin/sh
# copied together from initramfs-tools
set -eu
# Read bytes out of a file, checking that they are valid hex digits
readhex()
{
dd < "$1" bs=1 skip="$2" count="$3" 2> /dev/null | \
{
"ISDs" : [1],
"ASes" : [
{
"asn" : 101,
"isd" : 1,
"label" : "101",
"is_core_as" : true,
"kubos": 1,
"bwserver": true
@leonrinkel
leonrinkel / gist:a874e1802648bf32e224c457b1b7221d
Created March 22, 2024 19:47
My personal Arch install instructions
# boot option override is F11 (on my system)
# disable windows fast startup to save a headache
# set keyboard layout
loadkeys de-latin1
# verify UEFI boot mode
cat /sys/firmware/efi/fw_platform_size
# verify connectivity
@leonrinkel
leonrinkel / .vimrc
Last active October 15, 2023 17:17
" disable vi compatibility
set nocompatible
" enable mouse support
set mouse=a
" use utf-8 encoding
set encoding=utf-8
" highlight search matches
@leonrinkel
leonrinkel / yleon.zsh-theme
Created August 22, 2022 23:14
oh-my-zsh theme
PROMPT="%{$fg_bold[magenta]%}%m%{$reset_color%} "
PROMPT+="%(?:%{$fg_bold[green]%}∆ :%{$fg_bold[red]%}∆ )"
PROMPT+='%{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
PROMPT+="%{$fg_bold[white]%}$%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
#!/bin/bash
# usage: ocr.sh directory
find "${1}" -type f \
-iname "*.png" -print0 \
-o -iname "*.jpg" -print0 \
-o -iname "*.jpeg" -print0 |
while IFS= read -r -d '' FILE; do
DEST="${FILE}.pdf"
if [ ! -f "${DEST}" ]; then
@leonrinkel
leonrinkel / MergeSegments.ps1
Created February 19, 2022 13:27
Merge HLS segments
for ($i=1; $i -le 540; $i++) {echo "segment$i.ts" >> list.txt}
& "..\ffmpeg.exe" -f concat -safe 0 -i list.txt -c copy output.ts
@leonrinkel
leonrinkel / adt7410_feb11a.ino
Created February 11, 2022 20:37
Arduino <-> Analog Devices ADT7410 Temperature Sensor
#include <stdint.h>
#include <Wire.h>
#define DEVICE_ADDRESS 0x48u
#define TEMPERATURE_REGISTER_ADDRESS 0x00u
#define STATUS_REGISTER_ADDRESS 0x02u
#define CONFIG_REGISTER_ADDRESS 0x03u
#define POLL_DELAY 240 /* ms */
$from = 1
$to = 540
$url = "https://someurl/segment{}.ts"
$out = "segment{}.ts"
for ($i = $from; $i -le $to; $i++)
{
Invoke-WebRequest $url.Replace("{}", $i) -OutFile $out.Replace("{}", $i)
}
@leonrinkel
leonrinkel / example.py
Created October 24, 2021 13:32
Python Multiprocess Work Producer/Consumer Example
import time
import logging
import logging.handlers
import multiprocessing
number_of_work_consumers = 4
def log_handler_fn(log_queue: multiprocessing.Queue):
logging.basicConfig(level=logging.DEBUG)
while True: