Skip to content

Instantly share code, notes, and snippets.

View casebeer's full-sized avatar

Christopher Casebeer casebeer

View GitHub Profile
@casebeer
casebeer / flush-unbound-zones.sh
Created May 15, 2024 20:34
Flush Unbound DNS local auth-zones and their cached entries after updating zonefiles (and serial numbers).
#!/bin/bash
# set path to directory holding docker-compose.yaml
#dockerComposeRoot=
if [ -z "$dockerComposeRoot" ]; then
echo "ERROR: Set dockerComposeRoot before calling $0" >&2
exit 1
fi
@casebeer
casebeer / thermal-camera-ffmpeg.sh
Last active May 15, 2024 04:33
Script to read data from Tooltop T7 a.k.a. Infiray P2 Pro thermal camera using ffmpeg
#!/bin/bash
# https://www.eevblog.com/forum/thermal-imaging/infiray-and-their-p2-pro-discussion/200/
# https://superuser.com/questions/1009969/how-to-extract-a-frame-out-of-a-video-using-ffmpeg
# https://stackoverflow.com/questions/37960828/webcam-streaming-from-mac-using-ffmpeg
#
# Selected pixel format (yuv420p) is not supported by the input device.
#[avfoundation @ 0x7f961cd08b40] Supported pixel formats:
#[avfoundation @ 0x7f961cd08b40] uyvy422
#[avfoundation @ 0x7f961cd08b40] yuyv422
@casebeer
casebeer / unleashed-nginx.conf
Created May 11, 2024 20:40
Nginx reverse proxy config for Ruckus Unleashed controller w/ backend failover support
#
# Reverse proxy config for Ruckus Unleashed controllers
#
# Requirements:
#
# - DNS entries for all unleashed<IPv4 last octet of controllers>.example.com
# - DNS entry for unleashed.example.com
# - (DNS entries to point to Nginx reverse proxy)
# - Wildcard TLS cert on reverse proxy (or SAN cert covering all above mentioned names)
#
@casebeer
casebeer / ecc-tls-certs.sh
Last active April 25, 2024 04:47
Scripts to generate self-signed ECC TLS certificates with OpenSSL
#!/bin/bash
cat <<EOF > req.template
[req]
#default_bits = 2048
distinguished_name = dn
prompt = no
#req_extensions = req_ext
[dn]
@casebeer
casebeer / luksunlockusb.sh
Last active March 21, 2024 22:19
Script to unlock Ubuntu LUKS encrypted volume from initramfs during boot using a keyfile stored on a USB thumb drive with fallback to manual passphrase entry.
#!/bin/sh
# https://tqdev.com/2022-luks-with-usb-unlock
#
# Script to unlock Ubuntu LUKS encrypted volume from initramfs during boot using
# a keyfile stored on a USB thumb drive with fallback to manual passphrase entry.
#
# Runs in Busybox shell environment in initramfs
# After updates to this script or crypttab, update initramfs:
#
@casebeer
casebeer / getpocket-csv.py
Last active March 4, 2024 22:26
Script for converting GetPocket.com exported HTML to CSV
'''
Script for converting GetPocket.com exported HTML to CSV
Export data via https://getpocket.com/export
'''
import csv
import sys
import xml.etree.ElementTree as ET
def main():
@casebeer
casebeer / random-normal.md
Last active March 3, 2024 21:28
Random normal variables in Home Assistant automations/Jinja templates

Random normal variables in Home Assistant/Jinja

Via Iwrin-Hall/uniform sum distribution.

μ = n / 2, σ = sqrt(n / 12)

where n = # of summed uniform U(0, 1) random variables

Scale and shift Irwin-Hall to provide μ and σ as needed.

@casebeer
casebeer / picture-elements-card.yaml
Created November 29, 2023 22:22
Hikvison PTZ and white light from Home Assistant dashboard
type: picture-elements
title: Hik PTZ Control
elements:
- type: icon
icon: mdi:arrow-up
tap_action:
action: call-service
service: rest_command.hik_ptz_up
hold_action:
action: call-service
@casebeer
casebeer / :etc:netplan:01-macvlan-bridge.yaml
Last active November 24, 2023 21:59
Macvlan bridge for host connectivity in Netplan and Networkd-dispatcher
network:
version: 2
renderer: networkd
ethernets:
mvlan-bridge:
addresses:
- 192.168.0.10/32
routes:
- to: 192.168.0.128/28 # docker macvlan address range
via: 192.168.0.10
@casebeer
casebeer / configuration.yaml
Last active November 16, 2023 23:18
Home Assistant configuration using the REST Switch integration to control the white supplemental lights on Hikvision/Annke ColorVu or NightChroma color night vision cameras.
#
# # REST Switch configs for toggling the white "Supplemental Lights" on Hikvision/Annke cameras
#
# Note that we must hit the cameras' ISAPI endpoints directly, not through the NVR,
# since (at least the Annke N88PCH) NVR does not seem to support getting nor setting the
# `/ISAPI/Image/channels/<ID>/supplmentalLight` API endpoint. This also implies that
# we must use the NVR's "integration password," i.e. the username and password used by the
# NVR to automatically config the cameras, NOT a user of the NVR itself.
#
# ## Camera Settings