This file contains hidden or 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
import os | |
class ProgressLineReader(object): | |
def __init__(self, filepath, mode='r'): | |
self.path = filepath | |
self.total_size = os.stat(filepath).st_size | |
self.already_read = 0 | |
self.fobj = open(filepath, mode) | |
This file contains hidden or 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
import re | |
from ConfigParser import NoOptionError | |
class ValidationFailed(Exception): | |
def __init__(self, reason): | |
self.reason = reason | |
def __str__(self): | |
return repr(self) |
This file contains hidden or 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
#!/usr/bin/env python | |
""" | |
Find failed login attempts in auth log, save results in a sqlite database, | |
and print a report. | |
""" | |
from __future__ import print_function | |
import os | |
import re |
This file contains hidden or 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
import unittest | |
import mock # or `from unittest import mock` in py3.3+ | |
import undertest1 | |
import undertest2 | |
class MockDemoTestCase(unittest.TestCase): | |
# we can directly patch givestring's module namespace. |
This file contains hidden or 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
*.py[co] |
This file contains hidden or 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
http://www.pantsareoverrated.com/archive/2011/05/10/hobbes-and-bacon/ | |
http://www.pantsareoverrated.com/archive/2011/05/12/hobbes-and-bacon-002/ | |
http://www.pantsareoverrated.com/archive/2011/10/11/hobbes-and-bacon-03-2/ | |
http://www.pantsareoverrated.com/archive/2011/10/13/hobbes-and-bacon-04-2/ |
This file contains hidden or 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 _Transform: | |
transform = None | |
transargs = () | |
def __call__(self, image): | |
""" | |
Run the transformation and return the tranformed image data | |
""" | |
args = [getattr(self, arg) for arg in self.transargs] | |
return self.transform(image, *args) |
This file contains hidden or 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
Release Me (The Fear) | |
as performed by Cas Haley (arrangement, maybe song?) | |
https://www.youtube.com/watch?v=zRgvtu62sYQ | |
A#m Ddim7 D#m9 G# F# D#m C# Fm | |
e|---1------x-1----x------4------2------6------4------1---| | |
B|---2------6-0----6------4------2------7------6------1---| | |
G|---3------4-1----6------5------3------8------6------1---| | |
D|---3------6-0----4------6------4------8------6------3---| |
This file contains hidden or 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
registry = {} | |
def registered(cls): | |
registry[cls.__name__] = cls | |
return cls | |
@registered | |
class Foo(object): | |
def introduce(self): |
This file contains hidden or 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
#!/usr/bin/env python | |
import argparse | |
import requests | |
SPACEPASTE_URL = 'http://bpaste.net/' | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
'file', |