Skip to content

Instantly share code, notes, and snippets.

View deckerego's full-sized avatar

John Ellis deckerego

View GitHub Profile
@deckerego
deckerego / wlan.conf
Created October 22, 2025 16:14
Monit config to restart NetworkManager if the default gateway is no longer reachable
check host gateway with address 192.168.1.1
restart program = "/usr/bin/systemctl restart NetworkManager.service"
if failed
port 443
protocol https
timeout 10 seconds
retry 3
with ssl options {verify: disable}
then restart
@deckerego
deckerego / reset_nic.sh
Last active October 22, 2025 16:17
Reset all USB NICs at the hardware level
#!/bin/bash
for device in /sys/bus/usb/devices/*; do
grep "NIC" "$device/product" &>/dev/null
if [ "$?" == 0 ]; then
echo -n "Resetting "
cat "$device/product"
sh -c "echo 0 > $device/authorized"
sh -c "echo 1 > $device/authorized"
echo "Device reset."
@deckerego
deckerego / clearspelling.sh
Created September 19, 2025 13:41
Clear list of user-defined spelling exceptions
echo '' > "/Library/Group Containers/group.com.apple.AppleSpell/Library/Spelling/LocalDictionary"
@deckerego
deckerego / wlan
Created May 21, 2025 20:36
WIFI monitoring with Monit
check network WIFI with interface wlan0
restart program = "/usr/sbin/service networking restart"
if failed link then restart
@deckerego
deckerego / sync_dir.sh
Last active March 24, 2025 19:32
Sync a Synology folder to another directory on the same NAS
find /volume1/scanned -type d \( -path '**/@eaDir' -o -path '**/#recycle' \) -prune -o -type f -newer /volume1/paperless/sync_last_run.lock -print | sed 's/\/volume1\/scanned\///g' > /volume1/paperless/sync_last_run.log
touch /volume1/paperless/sync_last_run.lock
rsync --files-from=/volume1/paperless/sync_last_run.log /volume1/scanned /volume1/paperless/consume
@deckerego
deckerego / prusacam
Last active January 12, 2024 14:09
Send an (old) RPi camera still to Prusa Connect
* * * * * pi raspistill -n -q 80 -w 960 -h 720 -e jpg -t 1000 -o - | curl -v -H 'Token: TOKEN' -H 'Content-Type: application/jpg' -H 'Fingerprint: FINGERPRINT' https://webcam.connect.prusa3d.com/c/snapshot -T -
@deckerego
deckerego / action_fingerprint.sh
Created June 29, 2023 20:28
Find the TLS fingerprint for GitHub Actions token server
#!/bin/bash
openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 2>/dev/null < /dev/null | \
openssl x509 -fingerprint -sha1 -noout | \
grep Fingerprint | \
tr -d ':' | \
tr '[:upper:]' '[:lower:]' | \
cut -f2 -d=
@deckerego
deckerego / terraform.tf
Last active October 7, 2022 03:05
Redirect HTTP traffic using Application Load Balancers
locals {
public_zones = {
"domainone.egg" = "FEEDFACEBEEF"
"domaintwo.egg" = "BEEFBEEFFACE"
"domainthree.egg" = "FACEFEEDFACE"
}
}
resource "aws_default_vpc" "default" {}
@deckerego
deckerego / redirect.tf
Last active October 7, 2022 03:06
HTTP (only) redirect for alternate domains using S3
locals {
www_zones = {
"www.domainone.egg" = "FEEDFACEBEEFFEED"
"www.domaintwo.egg" = "BEEFBEEFFEEDFACE"
"www.domainthree.egg" = "FACEFACEFEEDFACE"
}
}
resource "aws_s3_bucket" "redirect-www-bucket" {
for_each = local.www_zones
@deckerego
deckerego / iterate_network.js
Last active May 25, 2021 02:13
IPv4 Network Info Calculator & Iterator
function getIPv4Range(networkString) {
const networkdef = networkString.split('/');
const netmask = parseInt(networkdef[1])
const bitmask = 32 - netmask;
const quads = networkdef[0].split('.');
const addrbin =
(parseInt(quads[0]) << 24) +
(parseInt(quads[1]) << 16) +
(parseInt(quads[2]) << 8) +
parseInt(quads[3]);