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
@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 / gist:1410217
Created November 30, 2011 18:41
Convert directory of svn dumps to git repos
#!/bin/bash
# convert svn dumps located in ./svndumps/ into git repositories.
# assumes dump has basic svn top level structure of tags/, branches/, and trunk/,
# and authors.txt file of the svn committer id -> git committer id
# authors.txt example:
# csc = Christopher Corley <cscorley@ua.edu>
# inspired by/credit to: http://sebastian.formzoo.com/2010/11/04/3-steps-convert-svn-dump-to-git/
@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 / TerminusBold-Powerline.ttf
Created February 6, 2012 00:01
Terminus (TTF) for Powerline
@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 / 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 / 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
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)
from ctypes import *
class Cell(Structure):
pass
Cell._fields_ = [
("val", c_int),
("next", POINTER(Cell))]
class LinkedList:
@cscorley
cscorley / jekyll.py
Last active January 9, 2021 21:47
IPython to Jekyll Markdown
try:
from urllib.parse import quote # Py 3
except ImportError:
from urllib2 import quote # Py 2
import os
import sys
BLOG_DIR = os.environ['BLOG_DIR']
# BLOG_DIR = '/Users/cscorley/git/cscorley.github.io/'