Skip to content

Instantly share code, notes, and snippets.

View justinabrahms's full-sized avatar

Justin Abrahms justinabrahms

View GitHub Profile
#!/usr/bin/env python
import time
import nose
from nose.plugins.base import Plugin
class NoseTimer(Plugin):
"""
Times each individual test and outputs them in reverse order of
speed (highest first)
@justinabrahms
justinabrahms / pyc0n.js
Created December 3, 2010 03:38
bot to handle votes for pycon selection.
// pycon talk selection irc bot.
var irc = require('../../node-irc/lib/irc.js');
var sys = require('sys');
var imb0t = function () {
return {
pattern_list: [],
client: undefined,
position: -1, // starts at -1 so we can increment it on the first ,next to make it 0, which properly indexes
@justinabrahms
justinabrahms / gist:831856
Created February 17, 2011 14:53
Simple tree walking using goroutines.
package main
import (
"tour/tree"
"fmt"
)
func Walk(tree *tree.Tree, ch chan int) {
if tree != nil {
Walk(tree.Left, ch)
@justinabrahms
justinabrahms / colortest.py
Created June 26, 2011 17:10 — forked from graven/colortest.py
Small utility to test terminal support for 256-color output.
#!/usr/bin/env python
# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349
print "Color indexes should be drawn in bold text of the same color."
print
colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
colored_palette = [
"%02x/%02x/%02x" % (r, g, b)
for r in colored
@justinabrahms
justinabrahms / gist:1390864
Created November 24, 2011 07:59
extract archives from eshell
(defun if-string-match-then-result (to-match pairs)
"Takes a string to match and a list of pairs, the first element
of the pairs is a regexp to test against the string, the second of
which is a return value if it matches."
(catch 'break
(dolist (val pairs)
(if (string-match-p (car val) to-match)
(progn
(throw 'break (cadr val)))))
@justinabrahms
justinabrahms / gist:1638664
Created January 19, 2012 08:02
notes for "You and Your Research"
* You and Your Research
http://www.cs.virginia.edu/~robins/YouAndYourResearch.html
** Necessities for Success
*** Courage
It seems as though the speaker said this as if this was also
synonymous with confidence. Asking impossible questions, etc. Maybe
brazenness would be a reasonable quality too.
*** Thinking
*** Age
Math folks are best when young. Composers best when old. His theory is
@justinabrahms
justinabrahms / gist:1810217
Created February 12, 2012 18:50
A product request I filed with openstudy.com in 2010. Why doesn't this exist right now?
Ideal online learning experience:
1. Lessons that are applicable to me.
a. CompSci data structures
b. CompSci algorithms
c. CompSci operating systems
d. CompSci (sensing a theme?) database design
2. Variety of questions which are in increasing difficulty (with approximate levels for each question)
3. The ability to have someone validate my answers (I'd pay for this, not sure if its per-question, per-lesson or per-"semester")
4. A bit of code that would evolve over the course of the "semester"
2166 ± : ruby github-services.rb [7d0h36m] ✹
WARN The gem environment is out-of-date or has yet to be bootstrapped.
Runnning script/bootstrap to remedy this situation...
bundle install requires at least 0 argument: "bundle install".
/Users/justinlilly/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/spec_set.rb:90:in `block in materialize': Could not find rake-0.8.7 in any of the sources (Bundler::GemNotFound)
from /Users/justinlilly/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/spec_set.rb:83:in `map!'
from /Users/justinlilly/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/spec_set.rb:83:in `materialize'
from /Users/justinlilly/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/definition.rb:113:in `specs'
from /Users/justinlilly/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib
; setup dev environment w/ ponymode.
(defun pony-time ()
(interactive)
(if virtualenv-workon-session
(progn
(pony-runserver)
(pony-manage-run '("celeryd" "-lINFO" "--traceback" "--autoreload"))
(pony-shell)
(sql-mysql))
@justinabrahms
justinabrahms / gist:3830804
Created October 4, 2012 00:34
pretty time formatting in python
def nice_time(delta):
"""
Gets time delta in seconds and returns a pretty string
representing it in the format of 1w2d9h16m44s
"""
weeks = 0
days = 0
hours = 0