Skip to content

Instantly share code, notes, and snippets.

View luckman212's full-sized avatar

Luke Hamburg luckman212

View GitHub Profile
@luckman212
luckman212 / json-diff
Last active February 17, 2024 16:34
json-diff using jd, for diffing Syncthing file debug outputs: https://docs.syncthing.net/rest/db-file-get.html
#!/usr/bin/env bash
case $1 in
-h|--help|'') echo "${0##*/} [files-or-dir]"; exit;;
esac
#requires jd, jq
for f in jd jq; do
if ! hash $f &>/dev/null; then brew install --quiet $f; fi
done
@luckman212
luckman212 / xattr-watcher.sh
Last active February 12, 2024 00:26
macOS script to log xattr changes in realtime, requires `jq`
#!/usr/bin/env bash
# watches for changes to xattrs and utimes
# https://github.com/syncthing/syncthing/issues/9371#issuecomment-1937696552
# https://gist.github.com/luckman212/4bb90c65a3470cb11fba49e694dc205f
sudo eslogger --format json setextattr deleteextattr setattrlist utimes | jq -r '
.event as $e |
.process as $p |
($e | keys[0]) as $t |
@luckman212
luckman212 / unifi-backup.sh
Created January 26, 2024 02:07 — forked from corny/unifi-backup.sh
Improved backup script for Ubiquiti UniFi controller
#!/bin/bash -e
#
# Improved backup script for Ubiquiti UniFi controller
# original source: http://wiki.ubnt.com/UniFi#Automated_Backup
#
# must contain:
# username=<username>
# password=<password>
source ~/.unifi-backup
@luckman212
luckman212 / sprinkler.sh
Created November 16, 2023 06:06
Example sprinkler alert script (Ask Different)
#!/bin/zsh
#number of times after which a refill is required
REFILL_AFTER=25
#text (case sensitive regex) that should cause the counter to increment
TRIGGER_STR='Sprinkler turned on'
#script to run when alert fires (send email, SMS, etc...)
ALERT_SCRIPT=/path/to/your/script
@luckman212
luckman212 / icloud_ubiquity_fix.sh
Last active July 30, 2025 23:42
Fix for stuck iCloud Ubiquity containers reported as Client Truth Unclean Items
#!/usr/bin/env bash
CLIENT_DB="$HOME/Library/Application Support/CloudDocs/session/db/client.db"
[[ -e $CLIENT_DB ]] || { echo "db not found"; exit 1; }
mapfile -t ITEM_IDS < <(sqlite3 "$CLIENT_DB" <<-EOS
SELECT throttle_id
FROM client_sync_up
EOS
)
@luckman212
luckman212 / .env
Last active September 3, 2023 01:27
docker-compose config for speedtest-tracker + MariaDB on Synology
# place in same dir as compose.yml, adjust as needed for your environment
# create a limited user and run `id <username>` to get the PUID/PGID values
TZ=America/New_York
CNAME=speedtest
DOCKER_DIR=/volume1/docker
PUID=1030
PGID=100
MARIADB_DATABASE=speedtest-tracker
MARIADB_USER=speedy
Just something weird I'm investigating
https://www.alfredforum.com/topic/20542-with-space-keywordargument-option-being-ignored-script-filter/
@luckman212
luckman212 / pwgen-dw.py
Last active January 25, 2023 15:01
small wrapper around diceware (https://pypi.org/project/diceware) to implement multiple passphrase generation
#!/usr/bin/env python3
"""
generates multiple random passphrases in one go
https://github.com/ulif/diceware/issues/53
requires diceware: pip install diceware
"""
import os
@luckman212
luckman212 / syno_hb_hcio.sh
Last active November 7, 2024 17:39
Script to ping healthchecks.io if Synology HyperBackup was successful
#!/usr/bin/env bash
ENDPOINT='https://hc-ping.com/{insert-HealthChecks-UUID-here}'
#logfile location changed as of v4.1.2-4039
#LOGFILE='/var/log/synolog/synobackup.log'
LOGFILE='/volume1/@appdata/HyperBackup/log/synolog/synobackup.log'
[[ -e $LOGFILE ]] || exit 1
awk -f- $LOGFILE <<'EOF'
@luckman212
luckman212 / syncthing-log-stream.sh
Created November 7, 2022 18:09
stream change events via syncthing REST API
#!/usr/bin/env bash
# https://docs.syncthing.net/rest/events-get.html
# https://docs.syncthing.net/dev/events.html#event-types
APIKEY=$(defaults read com.github.xor-gate.syncthing-macosx ApiKey)
[[ -n "$APIKEY" ]] || { echo "error retreiving API key"; exit 1; }
ENDPOINT='http://localhost:8384/rest/events/disk'
INTERVAL=2