Skip to content

Instantly share code, notes, and snippets.

View DavesCodeMusings's full-sized avatar

Dave Horton DavesCodeMusings

  • Planet Earth
View GitHub Profile
@DavesCodeMusings
DavesCodeMusings / gpsdump.sh
Last active January 10, 2026 16:06
Display data from serial attached GPS device for testing.
#! /bin/sh
# Display data from serial attached GPS device for testing.
PORT=/dev/ttyACM0
SPEED=9600
echo "Reading from $PORT at $SPEED bps."
stty -F $PORT $SPEED
#! /bin/sh
# When you're not using systemd on your Raspberry Pi, you
# can still enjoy GPIO push-button shutdown.
# Run this as:
# gpio_pwr_btn.sh &
# It will sit in the background and wait for GPIO to go low.
# When it does, it will issue the shutdown command.
GPIO=GPIO26
; Prevent recreation of System Volume Information by blocking it with an empty file of the same name.
; Does System Volume Information store presonally identifiable information? I don't know.
; Do I want Windoze automagically creating stuff on my Raspberry Pi microSD? No, I don't.
; Must be run with admin privs
dir /a
cd REMOVEABLE_DRIVE_LETTER (e.g. D:)
rmdir /s "System Volume Information" & copy NUL "System Volume Information"
attrib +h "System Volume Information"
@DavesCodeMusings
DavesCodeMusings / Armbian Ubuntu on Orange Pi Zero 3.md
Last active December 14, 2025 13:06
Installing and tweaking Ambian Ubuntu for the Orange Pi Zero 3 for fun and profit!

Ubuntu Server on Orange Pi Zero 3

Even with the current tariff nonsnese, the Orange Pi Zero 3 is a cheap and fairly capable ARM single board computer (SBC). If you've mastered the Raspberry Pi and you want to branch out, Armbian Ubuntu on the Zero 3 is a good place to start.

Download and flash the Armbian Ubuntu binary image

  1. Visit the Armbian Orange Pi Zero 3 page
  2. Scroll down to Server images
  3. Download Ubuntu 24.04 (Noble), the current version at time of writing.
  4. Use Raspberry Pi Imager, Balena Etcher, or whatever to flash the binary image to microSD.

Attach a console to the Orange Pi

@DavesCodeMusings
DavesCodeMusings / tasmota-esp32c3-install.cmd
Last active December 13, 2025 16:20
Tasmota flash firmware on ESP32-C3 with esptool on Windoze 11
; This assumes Python and esptool module are installed and working.
; Download the factory image for a fresh install
curl.exe --output tasmota32c3.factory.bin --url http://ota.tasmota.com/tasmota32/release/tasmota32c3.factory.bin
; Erase before flashing
py -m esptool --port=COM3 erase_flash
; Flash the image to the first detected COM port at offset 0
py -m esptool write_flash 0x0 .\tasmota32c3.factory.bin
@DavesCodeMusings
DavesCodeMusings / README.txt
Created July 24, 2025 12:59
syslog-ng in Docker for logging network hosts
Creates a syslog server that can be used to centrally collect logs from various network devices.
You'll need a Docker compose project directory structure that looks like this:
-rw-r--r-- 1 root root 351 Jul 24 12:00 compose.yml
drwxr-xr-x 3 1000 1000 4096 Jul 24 12:00 config/
drwxr-xr-x 2 1000 1000 4096 Jul 24 12:00 logs/
The syslog-ng.conf goes in the config/ directory. Logs will be found in the logs/ directory.
Logs are rotated daily.
@DavesCodeMusings
DavesCodeMusings / auto-inc-property.py
Created April 3, 2025 14:19
An 8-bit number as a class property that increments itself each time it's read.
# Auto-incrementing property
class Test:
_packet_id = -1
@property
def packet_id(self):
self._packet_id += 1
self._packet_id &= 0xFF # Truncate to 8-bit max
return self._packet_id
@DavesCodeMusings
DavesCodeMusings / ip-sort.js
Last active January 10, 2025 21:56
Sort IP addresses by octet order rather than the usual string sorting
#!/usr/bin/env node
function ipv4Compare(a, b) {
let aOctets = a.split('.');
let bOctets = b.split('.');
if (aOctets.length !== 4 || bOctets.length !==4) {
throw("InvalidIPv4Address");
}
if (parseInt(aOctets[0]) > parseInt(bOctets[0])) {
@DavesCodeMusings
DavesCodeMusings / containers.conf
Created January 7, 2025 18:54
Monit alerts for down Docker containers
check program containers with path "/usr/bin/docker ps --format '{{ .Names }}' --filter 'status=exited'"
every 120 cycles
if content != "" then alert
@DavesCodeMusings
DavesCodeMusings / fstab_align.sh
Created December 3, 2024 02:05
/etc/fstab field aligner
# Create order from chaos
awk '{ printf "%-42s %-16s %-8s %-12s %2s %2s\n", $1, $2, $3, $4, $5, $6 }' /etc/fstab > /etc/fstab.new