This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Remap the tab key to do snippets, autocompletion or indentation depending on | |
" the context (cobbled together by Gary Bernhardt; partly based on | |
" http://www.vim.org/tips/tip.php?tip_id=102) | |
" | |
" Because this uses the private 'Jumper' function in snippetsEmu, you'll need | |
" to edit '/.vim/plugin/snippetsEmu.vim' to make it public. To do that, just | |
" replace all occurrences of '<SID>Jumper' with just 'Jumper'. There were only | |
" two occurrences in my copy. | |
" | |
" The g:snippetsEmu_key variable must be defined, but not to a function key. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BowlingScorer: | |
def __init__(self, rolls): | |
rolls = rolls[:] | |
self.score = sum(self.score_frame(rolls) for _ in range(10)) | |
def score_frame(self, rolls_left): | |
roll1 = rolls_left.pop(0) | |
if roll1 == 10: | |
return 10 + rolls_left[0] + rolls_left[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def santa(people): | |
return dict(zip(people, reversed(people))) | |
def describe_santa(): | |
bob, george, judy = 'bob jones', 'george jetson', 'judy smith' | |
def takes_lists_of_people(): | |
santa([bob, george]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loop through git revisions, counting lines of Python | |
# code, unit test code, cucumber code, and media. The | |
# paths and filenames are specific to my project; if | |
# you want to use this, you'll have to change them. | |
reverse() { | |
sed 'x;1!H;$!d;x' | |
} | |
(echo 'rev,python code,unit test,cucumber,media' && | |
git rev-list HEAD | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tests/test_entity.py b/tests/test_entity.py | |
index c3c4aec..8410b9d 100644 | |
--- a/tests/test_entity.py | |
+++ b/tests/test_entity.py | |
@@ -209,6 +209,15 @@ class TestMatchesDict(unittest.TestCase): | |
creator=['Matt', 'Nobody'], | |
tags=['fun', 'boring']) == self.e | |
+ #def test_order_independence_of_query(self): | |
+ # assert not self.e.matches_dict(creator=['Matt'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Limits of TDD | |
#date 2009-11-09 21:47 | |
#tags python,tdd | |
<p> | |
My <a href="/2009/11/how_i_started_tdd.html">last post</a> about TDD | |
generated some great responses, some of which were skeptical. A few common | |
complaints about TDD were brought up, and posed with civility, so I'd like | |
to address them. | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
failbowl:repo grb$ cloc . | |
1472 text files. | |
1061 unique files. | |
883 files ignored. | |
http://cloc.sourceforge.net v 1.06 T=36.0 s (11.3 files/s, 1457.1 lines/s) | |
-------------------------------------------------------------------------------- | |
Language files blank comment code scale 3rd gen. equiv | |
-------------------------------------------------------------------------------- | |
HTML 196 818 14 30174 x 1.90 = 57330.60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def live_cell_count(x, y): | |
square_coords = [(x-1, y-1), | |
(x+0, y-1), | |
(x+1, y-1), | |
(x-1, y+0), | |
(x+1, y+0), | |
(x-1, y+1), | |
(x+0, y+1), | |
(x+1, y+1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have a repo with two commits | |
failbowl:temp(master) grb$ git shortlog | |
Gary Bernhardt (2): | |
commit 1 | |
commit 2 | |
# I destroy the second commit | |
failbowl:temp(master) grb$ git reset --hard HEAD^ | |
HEAD is now at 7454aa7 commit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How would you rather write your tests? | |
# Tell it to @garybernhardt (or [email protected]) | |
# 1) Hypothetical RSpec-inspired Python library (PSpec?) that does violence to nature | |
with describe('my class'): | |
with it('adds numbers'): | |
sum = MyClass.add(1, 1) | |
sum.should == 2 | |
# Actually, I think the only acceptable name for the above library would be "withit" |
OlderNewer