I hereby claim:
- I am mdwhatcott on github.
- I am mdwhatcott (https://keybase.io/mdwhatcott) on keybase.
- I have a public key whose fingerprint is 7F78 8BE6 A44F 4654 DE8D 083B B6B5 11D7 6F72 29F8
To claim this, I am signing this object:
from StringIO import StringIO | |
class MemoryFile(StringIO): | |
""" | |
This abstraction provides context management and line-iteration over the | |
built-in StringIO class, making it more fully behave like a file object. | |
Unfortunately, iteration is not (yet?) memory-efficient for large files. | |
""" | |
def __init__(self, text=''): |
FIRST = 'path to first file' | |
SECOND = 'path to second file' | |
def main(): | |
with open(FIRST) as first, open(SECOND) as second: | |
for line1, line2 in read_parallel(first, second): | |
pass # process lines | |
#! /usr/bin/env python | |
import os | |
import re | |
import shutil | |
from os.path import splitext | |
SOURCE = os.getcwd() + "/www/" | |
TARGET = os.getcwd() + "/compiled/" | |
if not os.path.exists(TARGET): |
def main(): | |
print ' 42 in 32 bits:', bits(42, 32) | |
print '-42 in 32 bits:', bits(-42, 32) | |
print '-42 in 20 bits:', bits(-42, 20) | |
def bits(number, size_in_bits): | |
""" | |
The bin() function is *REALLY* unhelpful when working with negative numbers. |
import sys | |
class Logger(object): | |
""" | |
Write log messages to the console (sys.stdout) and to a log file, | |
all managed as a context manager: | |
>>> with Logger('log_file.txt'): | |
... print "Hello, World!" # goes to stdout and to the log file |
def first_letter_mnemonic(text): | |
words = text.split() | |
letters = [] | |
for word in words: | |
letters.append(word[0]) | |
if word[-1] in ',-': # inline punctuation | |
letters.append(word[-1]) | |
elif word[-1] in '.;:?!': # delimiting punctuation |
// NOTE: This is examples code which never actually became valid because we found a better way. | |
func TestScoring(t *testing.T) { | |
Convey("Subject: Bowling Game Scoring", t, func(c Context, so Assertion) { | |
var game *Game // Whatever you do, don't do this: game := NewGame() | |
// Otherwise nested closures won't reference the correct instance | |
Convey("Given a fresh score card", c, func() { | |
game = NewGame() |
#!/usr/bin/env python | |
""" | |
This script scans the current working directory for changes to .go files and | |
runs `go test` in each folder where *_test.go files are found. It does this | |
indefinitely or until a KeyboardInterrupt is raised (<Ctrl+c>). This script | |
passes the verbosity command line argument (-v) to `go test`. | |
""" | |
package regexps | |
import ( | |
"fmt" | |
"regexp" | |
"testing" | |
. "github.com/smartystreets/goconvey/convey" | |
) |
I hereby claim:
To claim this, I am signing this object: