Skip to content

Instantly share code, notes, and snippets.

View garybernhardt's full-sized avatar

Gary Bernhardt garybernhardt

View GitHub Profile
# One extra keyword needed for an RSpec clone. Just sayin.
describe('integers') do:
it('can be added') do:
expect(1 + 1) == 2
it('can be subtracted') do:
expect(2 - 1) == 1
it('truncates on division') do:
expect(3 / 2) == 1
# Implement blocks with plain old generators:
ls _posts/* | grep -v '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' | while read fn; do day=`grep '#postdate\|#date' $fn | cut -d '-' -f 3 | cut -d ' ' -f 1`; git mv $fn `echo $fn | sed "s/-\([0-9][0-9]\)-/-\1-$day-/"`; done
failbowl:temp $ rm -rf env && pip install -E env dingus && ls -l env/lib/python2.6/site-packages
Creating new virtualenv environment in env
New python executable in env/bin/python
Installing setuptools...done.....
Downloading/unpacking dingus
Downloading dingus-0.2.tar.gz
Running setup.py egg_info for package dingus
Installing collected packages: dingus
Running setup.py install for dingus
failbowl:temp $ rm -rf env && pip install -E env dingus && . env/bin/activate && pip update pip
Creating new virtualenv environment in env
New python executable in env/bin/python
Installing setuptools...done.....
Downloading/unpacking dingus
Downloading dingus-0.2.tar.gz
Running setup.py egg_info for package dingus
Installing collected packages: dingus
Running setup.py install for dingus
warning: build_py: byte-compiling is disabled, skipping.
failbowl:temp $ deactivate; rm -rf env && pip install -E env dingus && . env/bin/activate && ls -l env/lib/python2.6/site-packages
zsh: command not found: deactivate
Creating new virtualenv environment in env
New python executable in env/bin/python
Installing setuptools...done.....
Complete output from command /Users/grb/temp/env/bin/python /Users/grb/temp/env/bin/easy_install /opt/local/Library/Frameworks/...ar.gz:
Processing pip-0.7.2.tar.gz
Running pip-0.7.2/setup.py -q bdist_egg --dist-dir /var/folders/Vr/Vrnubf6zGE4qOl6GIOQjh++++TI/-Tmp-/easy_install-AFWiid/pip-0.7.2/egg-dist-tmp-72Ag6W
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
failbowl:temp $ pip install -U pip
Downloading/unpacking pip
Downloading pip-0.7.2.tar.gz (68Kb): 68Kb downloaded
Running setup.py egg_info for package pip
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
Found existing installation: pip 0.7.2
Uninstalling pip:
@garybernhardt
garybernhardt / gist:424416
Created June 3, 2010 20:20
whodoneit: Find who introduced a certain pattern to the code base
# Originally from Jonathan Penn, with modifications by Gary Bernhardt
function whodoneit() {
(set -e &&
for x in $(git grep -I --name-only $1); do
git blame -f -- $x | grep $1;
done
)
}
# This doesn't work – it calls nil.join (the map seems to return nil?)
puts things.to_a.sort_by(&:id).map do |thing|
"#{thing.id} #{thing.url}"
end.join("\n")
# This DOES work (the only difference is that the map uses curlies instead of do/end).
puts things.to_a.sort_by(&:id).map { |thing|
"#{thing.id} #{thing.url}"
}.join("\n")
x = function()
y = function()
local table = 5
end
local old_table = table
y()
assert(table == old_table and table ~= 5)
end
x()
function wrap(f)
return function()
-- Storing the result of the wrapped function is the source of the
-- problem.
result = f()
return result
end
end
function f()