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 IndexProxy(object): | |
""" | |
Proxies access to a multidimensional sequence. | |
When the constructor is provided with a sequence of dimension N, | |
item access with iterables of length <= N will retrieve the subsequence | |
or item at the depth corresponding to the distance. For example: | |
ip = IndexProxy(multiseq) | |
ip[1,4] == multiseq[1][4] |
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
#!/usr/bin/env python | |
import argparse | |
import requests | |
SPACEPASTE_URL = 'http://bpaste.net/' | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
'file', |
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
registry = {} | |
def registered(cls): | |
registry[cls.__name__] = cls | |
return cls | |
@registered | |
class Foo(object): | |
def introduce(self): |
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
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 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 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 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 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 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 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) | |
OlderNewer