Skip to content

Instantly share code, notes, and snippets.

View joshuathayer's full-sized avatar

Joshua Thayer joshuathayer

  • San Francisco, CA
View GitHub Profile
Tree: {:version :a, :state :enabled, :parent nil}
Live: #{:a}
Shadow: #{}
Tree: {:version :b, :state :disabled, :parent :a}
{:version :a, :state :enabled, :parent nil}
Live: #{}
Shadow: #{}
Tree: {:version :b, :state :shadow, :parent :a}
(defmacro if->
[exp t f]
`(let [exp-val# ~exp
[fn-t# rest-t#] ~(if (seq? t)
[(first t) (vec (next t))]
[t []])
[fn-f# rest-f#] ~(if (seq? f)
[(first f) (vec (next f))]
[f []])]
$ mkdir bash-fix
$ cd bash-fix
$ curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf -
$ cd bash-92/bash-3.2
$ curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0
$ cd ..
$ xcodebuild
$ sudo cp /bin/bash /bin/bash.old
$ sudo cp /bin/sh /bin/sh.old
$ build/Release/bash --version # GNU bash, version 3.2.52(1)-release

Keybase proof

I hereby claim:

  • I am joshuathayer on github.
  • I am joshuathayer (https://keybase.io/joshuathayer) on keybase.
  • I have a public key whose fingerprint is 5905 446D 52E9 6655 38B0 FDAA 8AE3 C609 DC28 4680

To claim this, I am signing this object:

(defn foo []
(println (+ 1 2))
(println (+ 2 3))
(+ 5 6))
(foo)
@joshuathayer
joshuathayer / gist:3868785
Created October 10, 2012 22:06 — forked from anonymous/gist:3868185
Queue Anti-patterns (an argument in DMs)
I can make a case that queues only do what people want if you don’t consider failure cases.
Qs are empty (normal) or full (fail). Normally things are processed quickly. Failure case processing time is unbounded (or “too long”).
Solution is always “dump the Q”. Which means you do care about how long it takes to process items. So you want the queue to always be empty
Which means you only want a non-failing Q.
So why not admit it, use in-proc buffers, run enough servers to handle load? Reject work up front instead of dropping oldest items w/…
@joshuathayer
joshuathayer / session.py
Created April 5, 2011 01:32
demonstrate connect session ID as query param
# hit "new session" url, get a session object back which include a session id
params = urllib.urlencode({'email': 'example@example.com', 'password':'1234'});
f = urllib2.urlopen('http://127.0.0.1:8080/session', params)
ob = json.loads(f.read());
session_id = ob['data']['session_id']
# use that session to take other action
params = urllib.urlencode({'connect.sid': session_id });
f = urllib2.urlopen('http://127.0.0.1:8080/account_homepage?%s' % params)
@joshuathayer
joshuathayer / getkey-gist.js
Created April 1, 2011 06:40
demonstrating get_key function, which pulls session id out of query parameters if present, otherwise from cookie.
// in app.js:
// ...
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session( { secret: 'verySecret', get_key: session.get_session_key }));
// ...
// in session.js (of my app):