migrated lots of stuff from gist.github