Skip to content

Instantly share code, notes, and snippets.

@cbrew
cbrew / rc_mcfg_grammar.py
Created September 5, 2014 15:59
MCFG grammar for relative clauses
"""
Grammar designed by Alexander Clark (See: http://www.cs.rhul.ac.uk/home/alexc/lot2012/mcfgsforlinguists.pdf)
Adapted for use with Peter Ljunglof's code at https://github.com/heatherleaf/MCFParser.py
@author: Chris Brew
"""
from MCFParser import *
@cbrew
cbrew / gist:6248510
Last active April 7, 2016 09:33
IPython notebook showing how to measure SVG text using Javascript and Python.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@cbrew
cbrew / torus.py
Created September 12, 2012 23:15
Conway's Game of Life using scipy's convolve.
"""
Game of Life on a torus
Uses an amazingly concise pair of lines that do the update.
They are nearly identical to Allen Downey's code from
http://greenteapress.com/complexity/Life.py
The torus part is in mode='wrap'.
"""
# torus.py
#
# Game of Life on a torus, purely for fun...
# amazingly concise...
from scipy.ndimage import convolve
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
@cbrew
cbrew / index.html
Created August 28, 2012 14:42
A starter file for D3
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
body {
font: 300 13px "Helvetica Neue", Helvetica;
}