Skip to content

Instantly share code, notes, and snippets.

View nriley's full-sized avatar

Nicholas Riley nriley

View GitHub Profile
@nriley
nriley / init.lua
Last active March 6, 2024 17:02
Hammerspoon script for ensuring Sidecar is active when iPad is plugged in (macOS 10.15; see comments for versions up to macOS 13)
hs.loadSpoon('SpoonInstall')
spoon.SpoonInstall.use_syncinstall = true
Install = spoon.SpoonInstall
log = hs.logger.new('init', 5)
-- function debugUI(msg, table)
-- log:d(msg)
-- log:d(hs.inspect(table))
-- end
@nriley
nriley / Fix broken Finder windows.applescript
Created January 26, 2020 19:55
Fix Catalina Finder windows that sprout unwanted toolbars
-- Fix Catalina Finder windows that sprout unwanted toolbars
-- Takes advantage of the property that these windows cannot have their toolbars hidden through AppleScript
-- Nicholas Riley <nriley@sabi.net>
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Finder"
set _windows to Finder windows
repeat with _window in _windows
@nriley
nriley / Move to Top.applescript
Created April 25, 2016 12:25
Move tasks to the top of their containing task or project in OmniFocus
tell application "OmniFocus"
tell default document's first document window's content
set _tasks to (selected trees where its value's class is task)'s value
set _tasks to _tasks's reverse
repeat with _task in _tasks
tell _task's parent task
move _task to beginning of tasks
end tell
end repeat
end tell
@nriley
nriley / archive-application.sh
Last active March 3, 2018 16:28
Script to archive a macOS application.
#!/bin/zsh -ef
set -x
app="$1"
# https://stackoverflow.com/a/1665662/6372
space_version=$(/usr/local/bin/launch -f "$1" |
sed -e 's/^ version: \(.*\) \[.*/ \1/; t' \
-e 's/^ version: \(.*\)/ \1/; t' \
@nriley
nriley / get_lutron_cert.sh
Created October 14, 2017 15:55 — forked from mhofman/get_lutron_cert.sh
Generate a signed certificate valid to connect locally to a Lutron Caseta Smart Bridge
#!/bin/bash
# Usage: get_lutron_cert.sh [bridge_ip] | tee cert.pem
function error() {
echo "Error: $1" >&2
exit 1
}
login_server="device-login.lutron.com"
@nriley
nriley / .tmux.conf
Created October 21, 2010 02:53
my initial .tmux.conf: recreates my Screen setup in large part
# Use ^A like Screen
unbind C-b
set -g prefix C-a
bind-key a send-prefix
## standard Screen shortcuts
# next sp
bind Space next-window
# status/message line colors
@nriley
nriley / README.md
Last active April 1, 2017 14:55
Fake switching with homebridge-websocket

Update

The below continues to work, but homebridge-http-webhooks is much easier to set up and use as it only requires a HTTP request. With this package, you configure individual switches from config.json.

    "platforms": [
[...]
        {
            "platform": "HttpWebHooks",
 "webhook_port": 4051,
@nriley
nriley / ts.zsh
Created February 6, 2016 17:11
Timestamp your command output with zsh
ts() {
local tspty=tspty.$(/usr/bin/uuidgen)
zmodload zsh/zpty
zpty $tspty $@
setopt localtraps
TRAPINT() { zpty -d $tspty }
while zpty -r $tspty line; do
print -Pn '%B%D{%m/%d %H:%M:%S}%b '
print -n -- $line
done
@nriley
nriley / extract.py
Created June 27, 2013 06:51
Extract English subtitle text for WWDC 2013 videos.
import requests
import os, re, sys
RE_SD_VIDEO = re.compile(
r'<a href="(http://devstreaming.apple.com/videos/wwdc/2013/[^"]*-SD.mov)')
RE_WEBVTT = re.compile(r'fileSequence[0-9]+\.webvtt')
# stdin: dump of https://developer.apple.com/wwdc/videos/
for l in sys.stdin:
m = RE_SD_VIDEO.search(l)
@nriley
nriley / Go home.applescript
Created March 5, 2012 23:27
Multiple disk unmounting script with Time Machine to disk image/iTunes support
property _timeMachineDiskName : "Backup of Babs"
property _diskNamesToTryToEject : {"MaryMedia", "MaryBackup+", "ShirleyClone", "ShirleyLion", "bzzt"}
property _growlApplication : "Go home"
property _growlNotification : "Status"
on _notify(_title, _description)
tell application "GrowlHelperApp" to notify with name _growlNotification title _title description _description application name _growlApplication identifier _growlNotification
end _notify