Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Honnibal syllog1sm

View GitHub Profile
@syllog1sm
syllog1sm / gist:0d40bcdbcba5d4f632a6
Created May 31, 2015
Output of cython -a for Celery's core task runner module. Click lines to reveal C code.
View gist:0d40bcdbcba5d4f632a6
<!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; }
View gist:a13542690c59d5e60ebf
<!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; }
View gist:3dd24cc8b0ad925325e1
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 Aug 28, 2014
react-bootstrap Form component
View form.jsx
/** @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 Sep 27, 2021
A simple Python dependency parser
View gist:10343947
"""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 Jan 13, 2014
Draft proposals for wrapping Bootstrap components with React.js
View bootreact
/** @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',
View guide.js placement option
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 Sep 22, 2013
The implementation of urllib.quote, as of Python2.7.
View urllib_quote.py
_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'
View serve.py
#!/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)