Skip to content

Instantly share code, notes, and snippets.



  • Cyberspace
View GitHub Profile
mbarkhau /
Created Mar 19, 2011
processing example script
# Example code adapted from
delay = 10
X = width / 2
Y = height / 2
# Setup the Processing Canvas
setup = ->
strokeWeight( 10 )
def getattr_sub(obj, attrs, default='__default__'):
>>> getattr_sub(int, '__class__.__name__', None)
>>> getattr_sub(int, '__cleese__.__name__', 'missing')
if type(attrs) == str:
attrs = attrs.split('.')
mbarkhau /
Created May 19, 2011
Makes a sprite and css file for png images in a directory.
#!/usr/bin/env python
import os, sys
import subprocess
import Image
from collections import namedtuple
min_css = lambda (s): s.replace(" ", "").replace("\n", "") + "\n"
View vimrc
"" zi : toggle folding
call pathogen#runtime_append_all_bundles()
set spl=en spell
set tag=/home/koloss/workspace/tags
set ruler
set number
set wrap
set tabstop=4
mbarkhau /
Created Nov 28, 2011
command to compile and run go files
#!/usr/bin/env bash
if [ "$1" ]; then
$GOBIN/gofmt -w -s=true $1
$GOBIN/gofix $1
$GOBIN/6g -o $1.6 $1
$GOBIN/6l -o $1.bin $1.6
mbarkhau / defer.js
Created Jan 14, 2012
Minimalist defer() function
View defer.js
// Adapted mostly from
// There are a few major problems with this promise that keep it from
// being useful outside of a constrained environment:
// 1. It modifies it's own public API:
// The then(), resolve(), and reject() methods are rewritten when the promise
// is completed (i.e. resolved or rejected). There's nothing inherently wrong
// with this unless some other code is overriding or hijacking the public
// methods (in which case, they'd be overriding the obsolete methods).
// 2. It doesn't distinguish between the "front end" API and the "back end" API:
// If some other code decided to call our reject() method, it could. We would
mbarkhau /
Created Apr 30, 2012
Convert googles audio transcription xml to sbv
#!/usr/bin/env python
# encoding: utf-8
import sys
import os.path
import HTMLParser
from xml.sax.saxutils import unescape
from xml.dom import pulldom
mbarkhau / unicode_test.txt
Last active Jun 23, 2016
i18n test string
View unicode_test.txt
mbarkhau / KSON.js
Last active Dec 26, 2015
KSON: Keyless Schemafied Object Notation
View KSON.js
/* KSON: Keyless Schemafied Object Notation
* Version: 0.1 Alpha
* A serialization format with two goals in mind:
* 1. Easily parsable using minimal javascript.
* 2. Reduce serialized size compared to JSON.
* 1. is accomplished by using the (comparativly fast) JSON parse/stringify
* functions, thus reducing the task of KSON to packing/unpacking the values
mbarkhau /
Last active Dec 15, 2015
Iterate over all filenames in a directory tree
import os
def filepaths(rootdir, ext_filter=None):
if isinstance(ext_filter, basestring):
_filter = lambda p: p.endswith(ext_filter)
elif isinstance(ext_filter, tuple):
_filter = lambda p: os.path.splitext(p)[1] in ext_filter
_filter = ext_filter