Skip to content

Instantly share code, notes, and snippets.

View timtadh's full-sized avatar
🔥
it's a trap!

Tim Henderson timtadh

🔥
it's a trap!
View GitHub Profile
@william-ml-leslie
william-ml-leslie / control.py
Created August 9, 2012 04:09
App-level dataflow
NO_RETURN = set(dis.opmap[name] for name in """
JUMP_ABSOLUTE JUMP_FORWARD RAISE_VARARGS STOP_CODE RETURN_VALUE
BREAK_LOOP""".split())
def decode_code(offset, code):
opcode = ord(code[offset])
if opcode >= dis.HAVE_ARGUMENT:
oparg = ord(code[offset + 1]) + ord(code[offset + 2])
return opcode, oparg, offset + 3
return opcode, 0, offset + 1
@tariqmislam
tariqmislam / examples
Created April 2, 2012 14:49
HBase | REST | JSON
Taken from Karmi via Gist @ gist: 1218928
#!/usr/bin/env bash
#
# ===================================
# Experiments with the HBase REST API
# ===================================
#
# <http://hbase.apache.org/docs/r0.20.4/api/org/apache/hadoop/hbase/rest/package-summary.html>
#
anonymous
anonymous / gist:1406238
Created November 29, 2011 20:09
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@leegao
leegao / Rationale.md
Created July 9, 2011 02:30
JIT for dummies: JIT compiling RPN in python

If you don't care about the explanation, scroll down to find the code, it's 50 some odd lines and written by someone who doesn't know any better. You have been warned.

What it does

This is a very simple proof of concept jitting RPN calculator implemented in python. Basically, it takes the source code, tokenizes it via whitespace, and asks itself one simple question: am I looking at a number or not?

First, let's talk about the underlying program flow. Pretend that you are a shoe connoisseur with a tiny desk. You may only have two individual shoes on that desk at any one time, but should you ever purchase a new one or get harassed by an unruly shoe salesman without realizing that you have the power to say no (or even maybe?), you can always sweep aside one of the two shoes on the desk (the one on the right, because you're a lefty and you feel that the left side is always superior) onto the messy floor, put the other shoe on the right hand side, and then place your newly acquired shoe in