Skip to content

Instantly share code, notes, and snippets.


Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
Hermann-SW / irplay
Created Oct 12, 2021
Script to easily send keys via IR led, includes (unmodified) pigpio lib demo, as well as codes file created by it
View irplay
clean=0; if [ ! -f /var/run/ ]; then sudo pigpiod; clean=1; fi
# script from
# json created with "./ -r -g17 -fcodes 1 3"
Hermann-SW / CTRL_ALT_Q.c
Last active Oct 18, 2021
keybinder repo modified demo, for switching Raspberry Pi400 between USB keyboard mode and normal operation
/* main.c
* Created in 2010 by Ulrik Sverdrup <>
* This work is placed in the public domain.
#include <stdio.h>
#include <gtk/gtk.h>
#include <keybinder.h>
Hermann-SW / fagnano.tex
Created Oct 2, 2021
Simple check of Fagnano identity via Euler's identity, with Latex ("chktex"ed)
View fagnano.tex
Fagnano: \pi& =& 2 i \log\frac{1-i}{1+i} \\
& & \\
Euler: -1 & =& e^{i \pi} \\
& =& e^{-2 \log\frac{1-i}{1+i} } \\
& =& \left(\frac{1-i}{1+i}\right) ^ {-2} \\
& =& \left({\frac{1+i}{1-i}}\right) ^ 2 \\
Hermann-SW / hello_world.cpp
Created Sep 16, 2021
C++ script with bash part output "hello " and C++ part output "world"
View hello_world.cpp
exc=/tmp/`basename $0`
if [ $0 -nt $exc ]; then sed -n "/^\/\*\*$/,\$p" $0 | g++ -x c++ - -o $exc; fi
echo -n "hello "
Hermann-SW / run_from_memory_stdin.c
Last active Sep 16, 2021
C script runs C code without temp space (tcc -run) and script stdin available to C
View run_from_memory_stdin.c
echo "foo"
tcc -run <(sed -n "/^\/\*\*$/,\$p" $0) 42
#include <stdio.h>
Hermann-SW / mergesort
Created Sep 15, 2021
Parallel recursive bash mergesort
View mergesort
rm -f ${tms}[01]
while read line1
let n1=n1+1; echo $line1 >> ${tms}0
if read line2; then let n2=n2+1; echo $line2 >> ${tms}1; fi
Hermann-SW / mfpsyuv
Last active Sep 7, 2021
Measure framerate really achieved by raspividyuv (varying mode, width, height, record time and requested framerate)
View mfpsyuv
# mfpsyuv: measure framerate really achieved by raspividyuv, varying
# mode, width, height, record time and requested framerate
align () {
let x=$(($1-1))
echo $((x+$2-(x%$2)))
Hermann-SW / encode.c
Last active Sep 5, 2021
parallel version of "/opt/vc/src/hello_pi/hello_encode"
View encode.c
Copyright (c) 2012, Broadcom Europe Ltd
Copyright (c) 2012, Kalle Vahlman <zuh@iki>
Tuomas Kulve <>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Hermann-SW / pipeN.c
Last active Sep 5, 2021
"man pipe" example extended to N childs+pipes
View pipeN.c
/* gcc -Wall -Wextra -pedantic pipeN.c -o pipeN
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
Hermann-SW / mecanum
Created Aug 18, 2021
Runs on mecanum wheel robot Pi0W, processes gamepad commands received over netcat
View mecanum
if [ ! -f /var/run/ ]; then sudo pigpiod -s 1; sleep 0.5; fi