Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar
💭
I may be slow to respond.

Stephen Diehl sdiehl

💭
I may be slow to respond.
View GitHub Profile
# SVN Gource
# Download http://gource.googlecode.com/files/svn-gource-1.2.tar.gz and place svn-source.py in directory
# 1 Day = 0.05 seconds
COMPRESSION=0.05
svn log --verbose --xml > my-project.log
python svn-gource.py --filter-dirs my-project.log > data_unsorted.log
sort -t'|' -k1 data_unsorted.log > data_sorted.log
gource --log-format custom data_sorted.log -s $(COMPRESSION) --disable-progress --stop-at-end --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre libx264-default gource.mp4
# Stephen Diehl ( [email protected] )
# Build up an OWL ontology recursively from the Python given Python objects inheritance tree.
from xml.dom import minidom
def generate(icls):
xml = minidom.Document()
rdf = xml.createElement('rdf:RDF')
rdf.setAttribute('xmlns:owl','http://www.w3.org/2002/07/owl#')
def generate(icls):
strs = []
def descend(cl):
for cls in cl.__subclasses__():
strs.append('[%s]^[%s|%s]' % (cl.__name__,cls.__name__, ';'.join(cls.__dict__.keys())))
descend(cls)
descend(icls)
@sdiehl
sdiehl / eqtexsvg_pipe.py
Created November 17, 2010 02:19
Input Tex Output SVG
#!/usr/bin/env python
"""
eqtexsvg.py
Modified from the script by Julien Vitard <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@sdiehl
sdiehl / logic.pure
Created November 21, 2010 17:57
logic definitions
infixl (and) ∧;
infixl (or) ∨;
infixl (or) xor;
infixl (and) nand;
infixl (or) xnor;
infixl (or) iff;
infixl (or) implies;
infixl (or) ⊕;
@sdiehl
sdiehl / conditional_display.py
Created November 25, 2010 04:36
Conditional CSS Display Tag
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
# Usage:
# template.render({'showme': False })
# {% conditional_display showme %} -> style="display: none"
@register.tag(name="conditional_display")
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>insert mathml</title>
<script type="text/javascript">
function addSqrt(){
var mml_namespace = "http://www.w3.org/1998/Math/MathML";
@sdiehl
sdiehl / .zshrc
Created December 11, 2010 18:06
export EDITOR=vim
set -o vi
zstyle :compinstall filename '/home/stephen/.zshrc'
autoload -Uz compinit
compinit
setopt AUTO_CD # cd if no matching command
setopt AUTO_PARAM_SLASH # adds slash at end of tabbed dirs
setopt CHECK_JOBS # check bg jobs on exit
@sdiehl
sdiehl / vanilla jquery
Created December 16, 2010 21:46
jquery-mathml
convertMath = function (node) {
try {
if (node.nodeType == 1) {
var newnode = document.createElementNS("http://www.w3.org/1998/Math/MathML", node.nodeName.toLowerCase());
for (var i = 0; i < node.attributes.length; i++)
newnode.setAttribute(node.attributes[i].nodeName, node.attributes[i].nodeValue);
for (var i = 0; i < node.childNodes.length; i++) {
fib = 1 : 1 : [ a+b | (a,b) = zip fib (tail fib) ] & ;