Skip to content

Instantly share code, notes, and snippets.

View mbarkhau's full-sized avatar
💭

mbarkhau

💭
  • Cyberspace
View GitHub Profile
@mbarkhau
mbarkhau / proc_example.coffee
Created March 19, 2011 11:51
processing example script
# Example code adapted from http://processingjs.org/learning
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)
'type'
>>> getattr_sub(int, '__cleese__.__name__', 'missing')
'missing'
"""
if type(attrs) == str:
attrs = attrs.split('.')
@mbarkhau
mbarkhau / simple_sprites.py
Created May 19, 2011 07:34
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"
@mbarkhau
mbarkhau / vimrc
Created May 26, 2011 09:10
my 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
mbarkhau / gorun.sh
Created November 28, 2011 01:16
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
$PWD/$1.bin
fi
@mbarkhau
mbarkhau / defer.js
Created January 14, 2012 23:16
Minimalist defer() function
// Adapted mostly from https://github.com/unscriptable/promises/blob/master/src/Tiny.js
// 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
mbarkhau / youtube_transcribe.py
Created April 30, 2012 23:52
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
mbarkhau / unicode_test.txt
Last active June 23, 2016 14:27
i18n test string
イërnâ七iônàنلzætiøn
@mbarkhau
mbarkhau / KSON.js
Last active December 26, 2015 13:31
KSON: Keyless Schemafied Object Notation
/* 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
mbarkhau / filepaths.py
Last active December 15, 2015 03:09
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
else:
_filter = ext_filter