Skip to content

Instantly share code, notes, and snippets.

View syllog1sm's full-sized avatar

Matthew Honnibal syllog1sm

View GitHub Profile
@syllog1sm
syllog1sm / gist:0d40bcdbcba5d4f632a6
Created May 31, 2015 12:50
Output of cython -a for Celery's core task runner module. Click lines to reveal C code.
<!DOCTYPE html>
<!-- Generated by Cython 0.20.1 on Sun May 31 14:47:14 2015 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family: courier; font-size: 12; }
<!DOCTYPE html>
<!-- Generated by Cython 0.20.1 on Sat May 30 04:30:00 2015 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family: courier; font-size: 12; }
import random
from cymem.cymem cimport Pool
from libc.math cimport sqrt
cimport cython
ctypedef double[2] double_pair
cdef class World:
@syllog1sm
syllog1sm / form.jsx
Created August 28, 2014 15:29
react-bootstrap Form component
/** @jsx React.DOM */
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';
var Form = React.createClass({
mixins: [BootstrapMixin],
@syllog1sm
syllog1sm / gist:10343947
Last active November 7, 2023 13:09
A simple Python dependency parser
"""A simple implementation of a greedy transition-based parser. Released under BSD license."""
from os import path
import os
import sys
from collections import defaultdict
import random
import time
import pickle
SHIFT = 0; RIGHT = 1; LEFT = 2;
@syllog1sm
syllog1sm / bootreact
Created January 13, 2014 15:09
Draft proposals for wrapping Bootstrap components with React.js
/** @jsx React.DOM */
'use strict';
// Components wrapping Twitter Bootstrap stuff
//
var BSNames = {
// This isn't exhaustive. Need to think through what should go here. Should
// be exclusive.
bsClass: {'column': 'col', 'button': 'btn', 'btn-group': 'btn-group', 'label': 'label',
var placement = (steps[i].options && steps[i].options.placement) ? steps[i].options.placement : options.placement;
var css = {};
if (placement === 'right') {
css.top = top + (height / 3) + "px";
css.left = left + element.outerWidth() + margin;
} else if (placement === 'left') {
css.top = top + (height / 3) + "px";
css.left = (left - element.outerWidth()) - margin;
} else if (placement === 'bottom') {
css.top = (height + top + margin + 10) + "px";
@syllog1sm
syllog1sm / urllib_quote.py
Created September 22, 2013 02:35
The implementation of urllib.quote, as of Python2.7.
_safe_quoters = {}
always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz'
'0123456789' '_.-')
_safe_map = {}
for i, c in zip(xrange(256), str(bytearray(xrange(256)))):
_safe_map[c] = c if (i < 128 and c in always_safe) else '%{:02X}'.format(i)
def quote(s, safe='/'):
"""quote('abc def') -> 'abc%20def'
#!/usr/bin/env python
from BaseHTTPServer import HTTPServer, test
from SimpleHTTPServer import SimpleHTTPRequestHandler
SimpleHTTPRequestHandler.extensions_map['.less'] = 'text/css'
SimpleHTTPRequestHandler.extensions_map['.ks'] = 'text/javascript'
test(SimpleHTTPRequestHandler, HTTPServer)