Skip to content

Instantly share code, notes, and snippets.

% pshell development.ini
Traceback (most recent call last):
File "/Users/danv/pythons/airport/bin/pshell", line 9, in <module>
load_entry_point('pyramid==1.5.7', 'console_scripts', 'pshell')()
File "/Users/danv/pythons/airport/lib/python2.7/site-packages/pyramid/scripts/pshell.py", line 16, in main
return command.run()
File "/Users/danv/pythons/airport/lib/python2.7/site-packages/pyramid/scripts/pshell.py", line 88, in run
setup_logging(config_file)
File "/Users/danv/pythons/airport/lib/python2.7/site-packages/pyramid/paster.py", line 72, in setup_logging
dict(__file__=config_file, here=os.path.dirname(config_file))
@safetydank
safetydank / gist:d320eaaee0b25eed6cf4
Created May 9, 2015 05:14
Euclidean algorithm debugging session
In [8]: run euclid.py
m 2 k 5
IN [1, 1, 1, 1, 1, 0, 0]
A it:1 v:0 p:5 rsz: 1 lsz: 1 initp: 5
B it:1 v:0 p:5 rsz: 1 lsz: 1 initp: 5
E it:1 v:1 p:6 rsz: 1 lsz: 1 initp: 5
[1, 0]

Keybase proof

I hereby claim:

  • I am safetydank on github.
  • I am danv (https://keybase.io/danv) on keybase.
  • I have a public key whose fingerprint is 18DB ADB3 2840 2F00 0C5F B657 7ADC 9259 DAB0 B340

To claim this, I am signing this object:

bitflags! {
flags HatState: u8 {
const CENTEREDHATSTATE = 0,
const UPHATSTATE = 0x01,
const RIGHTHATSTATE = 0x02,
const DOWNHATSTATE = 0x04,
const LEFTHATSTATE = 0x08,
const RIGHTUPHATSTATE = 0x02 | 0x01, // RightHatState | UpHatState
const RIGHTDOWNHATSTATE = 0x02 | 0x04, // RightHatState | DownHatState,
const LEFTUPHATSTATE = 0x08 | 0x01, // LeftHatState | UpHatState,
trait IA {
fn foo(&self);
}
trait IB : IA {
fn bar(&self);
}
struct SS {
x : int
@safetydank
safetydank / gist:5617553
Created May 21, 2013 04:55
Python JSON filtering
# Ipython session
# curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true' | jq
import json
data = !curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true'
js = json.loads(data[-1])
js.keys()
[u'next_page',
u'completed_in',
@safetydank
safetydank / ala.py
Last active December 16, 2015 09:09
ala.py - Android app launcher and log capture script
#!/usr/bin/env python
"""
Usage: ala.py <project dir> <extra adb args>
Launches an Android project, captures process logs to file "LOG" and stdout
Dan V. 20130418
"""
import os, sys, re
@safetydank
safetydank / remind.py
Created July 11, 2009 02:19
Send out VHS upcoming event emails
#!/usr/bin/env python
import urllib, datetime, re, StringIO, smtplib
def add_tag(event, tag, data):
if tag in ('DTSTART', 'DTEND', 'CREATED', 'LAST-MODIFIED', 'DTSTAMP'):
# parse a date string as a datetime object
(date, sep, time) = data.partition('T')
year, month, day = (int(s) for s in (date[0:4], date[4:6], date[6:]))
hour, min, sec = (int(s) for s in (time[0:2], time[2:4], time[4:]))
event[tag] = datetime.datetime(year, month, day, hour, min, sec)