Skip to content

Instantly share code, notes, and snippets.

View leonrinkel's full-sized avatar

Leon Rinkel leonrinkel

View GitHub Profile
@leonrinkel
leonrinkel / gist:5a5ce462c752c6215bf28fb2ffe486ec
Last active May 22, 2021 20:23
raspberry pi linux waveshare oled fan hat
mount sd cards boot partition
remove console=tty1 from boot/cmdline.txt
add modules_load=pwm_pca9685 to boot/cmdline.txt
add dtoverlay=ssd1306,address=0x3c,width=128,height=32,inverted,sequential to boot/firmware/config.txt
add dtoverlay=i2c-pwm-pca9685a,addr=0x40 to boot/firmware/config.txt
# or
$ echo "dtoverlay=ssd1306,address=0x3c,width=128,height=32,inverted,sequential" | sudo tee -a /boot/firmware/config.txt
$ echo "dtoverlay=i2c-pwm-pca9685a,addr=0x40" | sudo tee -a /boot/firmware/config.txt
@leonrinkel
leonrinkel / traffic-light.ts
Created June 13, 2021 13:30
Typescript State Machine
interface TrafficLightOperations {
onButtonPressed(): void;
onWaitedToTurnGreen(): void;
waitToTurnRed(): void;
onWaitedToTurnRed(): void;
}
interface TrafficLightContext {
activeLight?: "red" | "green";
}
@leonrinkel
leonrinkel / bcd_to_seven_segment_decoder.v
Created October 10, 2021 10:36
Verilog BCD to Seven Segment Decoder
module bcd_to_seven_segment_decoder(
input [3:0] in,
output reg a, b, c, d, e, f, g
);
always @(in) begin
case (in)
0: assign {a, b, c, d, e, f, g} = 7'b1111110;
1: assign {a, b, c, d, e, f, g} = 7'b0110000;
2: assign {a, b, c, d, e, f, g} = 7'b1101101;
3: assign {a, b, c, d, e, f, g} = 7'b1111001;
---
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: psp.flannel.unprivileged
annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default
seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default
apparmor.security.beta.kubernetes.io/allowedProfileNames: runtime/default
apparmor.security.beta.kubernetes.io/defaultProfileName: runtime/default
# All resources definition must be declared
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.2
creationTimestamp: null
name: ingressroutes.traefik.containo.us
@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:
$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 / 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 */
@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
#!/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