Skip to content

Instantly share code, notes, and snippets.

View nriley's full-sized avatar

Nicholas Riley nriley

View GitHub Profile
@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
@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
(defun toggle-frame-fullscreen (&optional frame)
(interactive)
(set-frame-parameter frame 'fullscreen
(if (null (frame-parameter frame 'fullscreen))
'fullboth nil)))
(global-set-key "\C-x59" 'toggle-frame-fullscreen)
; ediff-toggle-wide-display tries to use the entire display width,
; which breaks with multiple monitors
@nriley
nriley / gist:1198239
Created September 6, 2011 17:11
uwsgi settings
[uwsgi]
socket = 127.0.0.1:46918
chdir = /home/hg/reviews/conf
env = DJANGO_SETTINGS_MODULE=reviewboard.settings
env = HOME=/home/hg/reviews/data
module = django.core.handlers.wsgi:WSGIHandler()
enable-threads = true
master = true
threads = 5
processes = 2
@nriley
nriley / unescape.py
Created August 31, 2011 20:01
Unescape for XML
import re, htmlentitydefs
# from http://effbot.org/zone/re-sub.htm#unescape-html
def unescape(text):
def fixup(m):
text = m.group(0)
if text[:2] == "&#":
# character reference
try:
if text[:3] == "&#x":
@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
#!/bin/zsh -ef
export PATH=/bin:/usr/bin:/usr/sbin:/usr/libexec
setopt extendedglob
diskutil unmount $(diskutil list | awk '/MaryBackup\+ A/ { print $NF }')
[[ $(id -u) == 0 ]] || { print "$0: must be running as root" >&2 ; exit 1 }
# enable AppleFileServer
#!/bin/zsh -ef
# Stop Time Machine & AppleFileServer
export PATH=/bin:/usr/bin:/usr/sbin:/usr/libexec
setopt extendedglob
diskutil mount $(diskutil list | awk '/MaryBackup\+ A/ { print $NF }')
[[ $(id -u) == 0 ]] || { print "$0: must be running as root" >&2 ; exit 1 }
Program received signal: “SIGABRT”.
(gdb) thread apply all bt
Thread 2 (process 829):
#0 0x0000000100032ca2 in kevent ()
#1 0x00000001000350b6 in _dispatch_mgr_invoke ()
#2 0x000000010003485f in _dispatch_queue_invoke ()
#3 0x00000001001b7adc in _dispatch_continuation_pop ()
#4 0x0000000100034433 in _dispatch_worker_thread2 ()
#5 0x0000000100033d6b in _pthread_wqthread ()