Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""File format conversion
category: vtk, file conversion, tomb"""
import os, sys
import vtk
def vtk2vtp(invtkfile, outvtpfile, binary=False):
"""What it says on the label"""
reader = vtk.vtkPolyDataReader()
thomasballinger / gist:1336916
Created Nov 3, 2011
nifti2nrrd dwi conversion
View gist:1336916
#!/usr/bin/env python
#1) Add measurement frame
#2) Save data part of nifti to its own file, and point to it in 'data file' field
import nibabel as nib
import sys
thomasballinger / gist:1628735
Created Jan 17, 2012
What I'd like to do at Hacker School
View gist:1628735

I'm most excited about collaborating with others and discussing interesting problems.

These are all just ideas

get deeper into javascript learn cool new languages (anything not Python, c, java, javascript) specifically, learn ruby continue project Euler problems (very exciting to collaborate with others on them) learn some css, client side javascript, and web page design

thomasballinger / gist:2918779
Created Jun 12, 2012
hacker school name quiz
View gist:2918779
javascript:(function(){if(document.timesClicked==undefined){document.timesClicked=0;};document.timesClicked++;var names=document.getElementsByClassName('name');for(var i=0;i<names.length;i=i+1){if(!names[i].savedName){names[i].savedName=names[i].innerHTML;}names[i].innerHTML=names[i].savedName;};setTimeout(function(){for(var i=0;i<names.length;i=i+1){names[i].innerHTML='?';};},1000);if(document.timesClicked==1){var ircs=document.getElementsByClassName('irc');for(var i=0;i<ircs.length;i=i+1){ircs[i].savedIRC=ircs[i].innerHTML;ircs[i].innerHTML='?';};var images=document.getElementsByClassName('profile-image');var remove=function(img){var toRemove=img.parentElement.parentElement;var parent=toRemove.parentElement;parent.removeChild(toRemove);};var addRemover=function(img){img.addEventListener('click',function(e){e.preventDefault();remove(img);return false;});};for(var i=0;i<images.length;i=i+1){addRemover(images[i])};};})()
View gist:2980096
# TODO: make mix-in functions return objects of the same type?
# Whatever objects they would return, but with the mix-in mixed in?
class enumerable(object):
def filter(self, f):
return filter(f, self)
def map(self, f):
return map(f, self)
def foreach(self, f):
return [f(x) for x in self]
View gist:2991211
#!/usr/bin/env python
"""An externally-accessible toy server whith several response strategies"""
import socket
import sys
from multiprocessing import Pool
def web_scrape(site):
s = socket.socket()
s.connect((site, 1333))
View gist:2991235
#!/usr/bin/env python
"""An externally-accessible toy server"""
import socket
def get_local_address_hack():
s = socket.socket()
s.connect(('', 80))
address, port = s.getsockname()
return address
thomasballinger / gist:3037579
Created Jul 3, 2012
brew install -v portmidi, brew --config, brew doctor output
View gist:3037579
Thomass-MacBook-Air:~ tomb$ brew install -v portmidi
Warning: Experimental support for using the "Command Line Tools" without Xcode.
Some formulae need Xcode to be installed (for the Frameworks not in the CLT.)
==> Downloading
Already downloaded: /Library/Caches/Homebrew/
/usr/bin/unzip /Library/Caches/Homebrew/
Archive: /Library/Caches/Homebrew/
creating: portmidi/
inflating: portmidi/ALL_BUILD.vcproj
inflating: portmidi/CHANGELOG.txt
thomasballinger /
Created Jul 3, 2012 — forked from jasonLaster/
Dynamic Dispatch in Python
class FlexiDict(dict):
def get_gt(self, key):
return [v for k,v in d.iteritems() if k > key]
def __getattr__(self, name):
if name.startswith("find_"):
params = name.split("_")
if len(params) == 3:
def func():
thomasballinger / gist:3836154
Created Oct 4, 2012
functional regex engine in python by psykotic of reddit
View gist:3836154
from itertools import chain
def nil(s):
yield s
def seq(l, r):
return lambda s: (sr for sl in l(s) for sr in r(sl))
def alt(l, r):
return lambda s: chain(l(s), r(s))