Skip to content

Instantly share code, notes, and snippets.

View nriley's full-sized avatar

Nicholas Riley nriley

View GitHub Profile
>>> class Old: pass
...
>>> type(Old)
<type 'classobj'>
>>> class New(object): pass
...
>>> type(New)
<type 'type'>
class Foo(object):
def is_it_a_foo(self, other):
print issubclass(Foo, other)
Foo().is_it_a_foo(Foo)
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 ()
#!/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 }
#!/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
@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 / 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 / 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
(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: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