Skip to content

Instantly share code, notes, and snippets.

View josharian's full-sized avatar

Josh Bleecher Snyder josharian

View GitHub Profile
@josharian
josharian / gist:1363230
Created November 14, 2011 04:27
Our neighbors to the north
In light of the recent (mis)handling of the Occupy protestors in the Bay Area,
I'd like to share a short anecdote from my parents in Portland, OR -- a story that, sadly,
you're pretty unlikely to hear on the media. Today (11/13/2011), the Occupy protestors
(or most of them, anyway) complied with a request to leave the park, and moved to a
street corner on 4th. After some time, the police were instructed to clear the intersection.
It was a familiar scene, easy to conjure: A line of policemen in full gear, face to face with
a line of protestors, tense, in the middle of the road. A policeman on a loudspeaker announced
that the intersection was going to be opened and that anyone who remained would be arrested.
And then the policemen moved. Backwards. The police line stepped backwards out of the road.
@josharian
josharian / django_sleep.py
Created December 9, 2011 22:38
Simple Django middleware that delays the processing of each request
"""
This module provides very simple Django middleware that sleeps on every request.
This is useful when you want to simulate slow response times (as might be
encountered, say, on a cell network).
To use, add this middleware, and add a value for SLEEP_TIME to your settings.
Possible future feature: Look for an X-Django-Sleep header on each request,
to let the client specify per-request sleep time.
from time import time
import pylab as pl
import scipy as sp
import numpy as np
from sklearn.decomposition import MiniBatchDictionaryLearning
from sklearn.feature_extraction.image import PatchExtractor
from sklearn.feature_extraction.image import reconstruct_from_patches_2d
from sklearn.pipeline import Pipeline
@josharian
josharian / theano_trampoline.py
Created December 29, 2011 02:30
Sample theano trampoline for supporting generic variables
#!/usr/bin/env python
"""
sample theano trampoline
"""
import numpy
import theano
import theano.tensor as T
@josharian
josharian / gitx_crash_report.txt
Created August 2, 2012 22:57
gitx crash report
Process: GitX [86438]
Path: /Applications/GitX.app/Contents/MacOS/GitX
Identifier: nl.frim.GitX
Version: 0.8.4 (0.8.4)
Code Type: X86-64 (Native)
Parent Process: launchd [251]
Date/Time: 2012-07-25 10:26:13.205 -0700
OS Version: Mac OS X 10.7.4 (11E53)
Report Version: 9
@josharian
josharian / call_me_ishmae.txt
Created August 4, 2012 16:57
Call Me Ishmae
[with apologies to Carly Rae Jepsen and Herman Melville]
We're on a hunt for a whale,
Too many leagues been at sail,
The endless seas like a jail,
And now we're on our way
Ahab's bent on revenge,
His every muscle is clenched,
Incident Identifier: E7DD51C4-D520-4D0A-BCED-4F15BF0DF608
CrashReporter Key: f06c5111b7e4bc75011a07aa9dfb1c515d296210
Hardware Model: iPhone3,1
Process: xkcd [512]
Path: /var/mobile/Applications/95AB618A-D2DF-41DD-A698-16E9BF2ADA1E/xkcd.app/xkcd
Identifier: xkcd
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
@josharian
josharian / binconvtest.py
Last active December 22, 2015 22:29
binconvtest.py from zach
import binascii
# To run doctests, do something like:
# python3 -m doctest binconvtest.py
def ascii_to_bin(input_string):
"""
ascii_to_bin converts a string of ASCII characters into a binary string
>>> ascii_to_bin("A")
@josharian
josharian / go_test_net_no_net.txt
Created September 13, 2013 17:33
`go test nest` with no network access
$ go test net
--- FAIL: TestResolveGoogle (0.00 seconds)
dialgoogle_test.go:32: ResolveTCPAddr failed: lookup www.google.com: no such host
dialgoogle_test.go:32: ResolveTCPAddr failed: lookup www.google.com: no such host
dialgoogle_test.go:32: ResolveTCPAddr failed: lookup www.google.com: no such host
--- FAIL: TestDialGoogle (0.00 seconds)
dialgoogle_test.go:65: Dial failed: dial tcp: lookup www.google.com: no such host
dialgoogle_test.go:65: Dial failed: dial tcp4: lookup www.google.com: no such host
dialgoogle_test.go:61: test disabled; use -ipv6 to enable
--- FAIL: TestDialGoogleIPv4 (0.01 seconds)
@josharian
josharian / go_test_net_bad_net.txt
Created September 13, 2013 17:35
`go test net` on a poor network
$ go test net
--- FAIL: TestDialGoogleIPv4 (0.01 seconds)
dialgoogle_test.go:143: lookup www.google.com: lookup www.google.com: no such host
--- FAIL: TestLookupIANACNAME (0.00 seconds)
lookup_test.go:98: LookupCNAME("www.iana.org.") = "", lookup www.iana.org: no such host, want "*.icann.org.", nil
--- FAIL: TestShutdown (0.00 seconds)
net_test.go:31: Accept: accept tcp 127.0.0.1:49962: too many open files
net_test.go:55: client Read: 0, EOF
--- FAIL: TestShutdownUnix (0.00 seconds)
net_test.go:87: Accept: accept unix /var/folders/jw/xrvq7wz95p5bwvjyx9yc2npm09k844/T/go_net_unixtest272364341: too many open files