Skip to content

Instantly share code, notes, and snippets.

View cscorley's full-sized avatar
🐷
PIG MODE

Christopher Corley cscorley

🐷
PIG MODE
View GitHub Profile
from timeit import timeit
from ctypes import *
size = 10
l = list()
arr = (c_int * size)()
def test(x):
for n in range(x):
l.append(n)
@cscorley
cscorley / RangedTarget.py
Created June 25, 2012 01:16
lxml RangedTarget for hacking in ranged sourceline numbers
from lxml import etree
class RangedTarget(etree.TreeBuilder):
"""
Extends the regular etree.TreeBuilder target to assign all elements
built two attributes:
ranged_tag_start = line number of the start tag
ranged_tag_end = line number of the end tag
To use this, you must feed the parser line by line, while assigning
@cscorley
cscorley / pulseinput.sh
Created March 16, 2012 23:38
Play audio from line-in in Pulseaudio; unload when finished.
#!/bin/bash
set -e
function get_loopback(){
# Detect the module number module-loopback is on
# If it isn't loaded, then load it.
loopback=`pactl list short modules | grep module-loopback | awk '{print $1}'`
if [ "$loopback" == "" ]; then
loopback=`pactl load-module module-loopback`
fi
@cscorley
cscorley / mergetex.py
Created February 29, 2012 03:34
Merge a tex file with all of it's \inputs recursively.
#!/usr/bin/env python3
import sys
def merge(input_tex):
new_lines = []
for c_line in input_tex:
# check for line comment
line = c_line
@cscorley
cscorley / problem.py
Created January 30, 2012 04:56
generates the number of valid strings for DFA in a particular homework problem I had
def A(s, c):
if len(s) <= c:
return False
if s[c] == '0':
return B(s, c+1)
elif s[c] == '1':
return C(s, c+1)
def B(s, c):
@cscorley
cscorley / example.tex
Created October 18, 2011 07:16 — forked from jhwilson/jhwhw.cls
A modified JHW document class for Homework assignments
\documentclass{jhwhw}
\author{Christopher S. Corley}
\title{Class homework solutions}
\date{October 19, 2011}
\begin{document}
\problem{Some problem name}
blahblah
\solution
@cscorley
cscorley / proposal.md
Last active September 10, 2015 18:59

the general algo goes like so:

for chunk in corpus:
  e-step
  m-step

gensim hacks in multiple passes:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from node import Node
class LinkedList:
def __init__(self, iterable=None):
last = None
if iterable:
for item in reversed(iterable):
@cscorley
cscorley / README.md
Last active August 29, 2015 14:10
Teaching SOP
\newcommand{\attn}[1]{{\color{red}#1}}
\newcommand{\desc}[1]{{\emph{\color{blue}#1}}}
\newcommand{\needcite}{\attn{\tiny{[cite]}}}