Skip to content

Instantly share code, notes, and snippets.

View nriley's full-sized avatar

Nicholas Riley nriley

View GitHub Profile
@nriley
nriley / gist:1390070
Created November 23, 2011 22:06
bluetooth switcher
#!/bin/zsh -f
dscacheutil -flushcache
# coproc scutil -Wr cmi.sabi.net
# until [[ $(read -pe) == Reachable* ]]; do
# dscacheutil -flushcache
# done
# kill $!
blueutil off
if [[ "$(ssh bw2 /usr/local/bin/blueutil status)" == 'Status: on' ]]; then
local _outlinePath, _htmlPath, _htmlFolder, _outlineName, _itemsToCommit
tell application "OmniOutliner Professional"
tell front document
save
set _outlineName to name
set _outlinePath to path
end tell
set _htmlPath to ((characters 1 thru ((count characters of _outlinePath) - 4) of _outlinePath) as string) & ".html"
set _htmlFolder to (_htmlPath as POSIX file)
@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
@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 / 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 / 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 / .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 / 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 / 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 / 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