Skip to content

Instantly share code, notes, and snippets.

View luckman212's full-sized avatar

Luke Hamburg luckman212

View GitHub Profile
@luckman212
luckman212 / syno_hb_hcio.sh
Last active March 24, 2024 14:42
Script to ping healthchecks.io if Synology HyperBackup was successful
#!/usr/bin/env bash
ENDPOINT='https://hc-ping.com/{insert-HealthChecks-UUID-here}'
LOGFILE='/var/log/synolog/synobackup.log'
[[ -e $LOGFILE ]] || exit 1
awk -f- $LOGFILE <<'EOF'
BEGIN {
FS="\t";
@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
@luckman212
luckman212 / obsidian_link2.sh
Last active March 7, 2024 16:37
Self contained version that should fully work for generating Markdown links via Service Station [REQUIRES Python3 from Homebrew!]
#!/usr/bin/env bash
###############################################
### requires python3 installed via Homebrew ###
###############################################
unset TARGETED_URL
MENU_KIND=-1
SELECTED_ITEM_URLS=()
@luckman212
luckman212 / wgfix.sh
Last active October 3, 2022 20:54
wgfix 1.0 (deprecated: use v2.0, see https://github.com/luckman212/wgfix)
#!/bin/sh
# put the line below at the end of /etc/rc.gatway_alarm, just above the final `exit`:
# /root/wgfix.sh "${GW}" "${alarm_flag}"
# set the 2 variables below to match the interface name and public key
# of the wg tunnel that you want to "fail back" when your default gateway changes
# WG_PEER_PUBLIC_KEY should be the public key from the FAR side (i.e the one from the PEERS tab)
WG_IFNAME='tun_wg0'
WG_PEER_PUBLIC_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@luckman212
luckman212 / dpinger_static_routes.php
Last active July 18, 2023 22:58
dpinger_static_routes.php - helper script related to https://github.com/pfsense/pfsense/pull/4591
<?php
// includes
require_once("functions.inc");
require_once("system.inc");
require_once("util.inc");
// global dpinger_dont_add_static_routes option
$dp_global_sr_disable = (isset($config['system']['dpinger_dont_add_static_routes']) ? 'ENABLED (checked)' : 'default (unchecked)');
printf("==> global `dpinger_dont_add_static_routes` setting: %s\n", $dp_global_sr_disable);
@luckman212
luckman212 / plist-parse.py
Created May 18, 2022 23:14
small python script to print a single key from a plist
#!/usr/bin/env python3
import sys
import plistlib
try:
f = sys.argv[1]
k = sys.argv[2]
except:
print(f'supply .plist pathname AND key as args', file=sys.stderr)
@luckman212
luckman212 / clip_pop.py
Created May 18, 2022 21:50
python script to pop the top row off Alfred's sqlite clipboard database
#!/usr/bin/env python3
import sqlite3
import os
import sys
import inspect
from contextlib import contextmanager
home_path = os.getenv('HOME')
db_path = os.getenv('db_path') or 'Library/Application Support/Alfred/Databases/'
@luckman212
luckman212 / imessage-i-mean-what-i-type.sh
Last active October 13, 2022 05:00
Possible fix for iMessage text mangling
#!/usr/bin/env bash
# ref:
# https://forums.macrumors.com/threads/smart-quotes-forced-on-in-messages.2284346/post-30657259
_res() {
(( res += $1 ))
}
res=0

JavaScript (JXA)

The following applies to Alfred 4+. For Alfred 3, see below.

The equivalents to the above in JXA JavaScript (again, the exportable variable is optional):

Application('com.runningwithcrayons.Alfred').setConfiguration('browser', {
  toValue: 'Safari',
  inWorkflow: 'net.deanishe.demo',
 exportable: true
@luckman212
luckman212 / airdropfix.sh
Created January 23, 2022 21:14
When Airdrop stops working, this might fix it without requiring a reboot...
#!/usr/bin/env bash
# requires blueutil: `brew install blueutil`
if ! sudo -v ; then
echo requires root
exit
fi
function dots() {