Skip to content

Instantly share code, notes, and snippets.

struct SS {
long n1;
long n2;
long n3;
long n4;
};
int foo(struct SS s) {
@eliben
eliben / gist:3314190
Created August 10, 2012 13:23
ROLE_REGEX for my Python plugin article
# Regex for matching/capturing role text.
# E.g. :name:`text` - first capture group is "name", second group is "text"
#
ROLE_REGEX = re.compile(r':(\w+):`([^`]*)`')
@eliben
eliben / templatelexer.py
Created August 8, 2012 09:33
initial attempt implementing the go template lexer in Python
from collections import namedtuple
TOK_TEXT = 'TOK_TEXT'
TOK_LEFT_META = 'TOK_LEFT_META'
TOK_RIGHT_META = 'TOK_RIGHT_META'
TOK_DUMMY = 'TOK_DUMMY'
# A token has
@eliben
eliben / gist:2944722
Created June 17, 2012 14:42
Timer utility
class Timer(object):
def __init__(self, name=None):
self.name = name
def __enter__(self):
self.tstart = time.time()
def __exit__(self, type, value, traceback):
if self.name:
@eliben
eliben / factor_server.py
Created May 27, 2012 02:57
factor_server
import multiprocessing
from multiprocessing.managers import SyncManager
import Queue
import time
from factorize import factorize_naive
from eblib.utils import Timer
IP = '192.168.1.102'
PORTNUM = 55444
AUTHKEY = 'shufflin'
@eliben
eliben / gist:1734923
Created February 4, 2012 03:20
AST for parsing Duff's device with pycparser
ileAST:
FuncDef:
Decl: send, [], [], []
FuncDecl:
ParamList:
Decl: to, [], [], []
TypeDecl: to, []
IdentifierType: ['int']
Decl: from, [], [], []
TypeDecl: from, []