Skip to content

Instantly share code, notes, and snippets.

Avatar
💭

mbarkhau

💭
  • Cyberspace
View GitHub Profile
@mbarkhau
mbarkhau / proc_example.coffee
Created Mar 19, 2011
processing example script
View proc_example.coffee
# Example code adapted from http://processingjs.org/learning
delay = 10
X = width / 2
Y = height / 2
# Setup the Processing Canvas
setup = ->
strokeWeight( 10 )
View getattr_sub.py
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
Makes a sprite and css file for png images in a directory.
View simple_sprites.py
#!/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
mbarkhau / gorun.sh
Created Nov 28, 2011
command to compile and run go files
View gorun.sh
#!/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 Jan 14, 2012
Minimalist defer() function
View defer.js
// 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 Apr 30, 2012
Convert googles audio transcription xml to sbv
View youtube_transcribe.py
#!/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 Jun 23, 2016
i18n test string
View unicode_test.txt
イërnâ七iônàنلzætiøn
@mbarkhau
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
mbarkhau / filepaths.py
Last active Dec 15, 2015
Iterate over all filenames in a directory tree
View filepaths.py
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