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 ConfigParser | |
class SanerConfigParser(ConfigParser.SafeConfigParser): | |
def __init__(self, defaults=None, dict_type=dict, allow_no_value=False): | |
ConfigParser.SafeConfigParser.__init__(self, dict_type=dict_type, | |
allow_no_value=allow_no_value) | |
self.mydefaults = defaults or {} | |
no_default = object() |
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 contextlib | |
import os | |
import subprocess | |
import tempfile | |
class SshTunnelDefinition: | |
def __init__(self, host, user=None, executable='ssh', localforwards=(), | |
remoteforwards=(), port=None, options=None): | |
self.executable = executable |
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
argparse (all classes) | |
abc.ABCMeta | |
collections.Counter | |
fractions.Fraction | |
plistlib.Dict and plistlib.Plist | |
random.Random | |
unittest.TextTestResult and unittest.FunctionTestCase | |
weakref.KeyedRef | |
zipfile.ZipExtFile | |
ctypes.py_object |
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 signal | |
def wait_for_subprocs(procs, cb=lambda proc: 0): | |
# do-nothing handler for SIGCHLD, just so it's something other than SIG_DFL. | |
# otherwise, Python won't interrupt syscalls. | |
oldhandler = signal.signal(signal.SIGCHLD, lambda *_: None) | |
try: | |
while procs: | |
signal.pause() | |
aliveprocs = [] |
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
# export2csv.py | |
# | |
# export random database stuff to csv | |
from __future__ import with_statement | |
import csv | |
def export2csv(cursor, outf): | |
""" | |
cursor should have an executed query already |
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/tools/dockerz/Dockerfile b/tools/dockerz/Dockerfile | |
new file mode 100644 | |
index 0000000..0eafb35 | |
--- /dev/null | |
+++ b/tools/dockerz/Dockerfile | |
@@ -0,0 +1,17 @@ | |
+FROM ubuntu:trusty | |
+MAINTAINER <pcannon@epochlabs.com> | |
+ | |
+RUN apt-get -y update \ |
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 | |
import contextmanager | |
@contextlib.contextmanager | |
def have_pidfile(fname): | |
f = open(fname, 'w') | |
f.write('%d\n' % os.getpid()) | |
f.flush() | |
s = os.fstat(f.fileno()) | |
dev, ino = s.st_dev, s.st_ino |
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 socket | |
from subprocess import check_output | |
from sys import stdout | |
from os import getpid | |
def info_about_socket(s, out=stdout): | |
""" | |
Write some information about the status and state of a socket object | |
to the file-like object 'out' (stdout, by default). |
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
awk '{x[$1]=x[$1]?(x[$1] VSEP OFS $2):$2}END{for(e in x){print e,x[e]}}' VSEP=, |
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
# ParallelBatcher.py | |
# | |
# Job pipeline for Twisted Matrix | |
# the paul 2011 | |
# | |
# Sort of goes between defer.DeferredList and plain Deferred chaining. | |
# When you have lots of jobs to do which take time (most likely because | |
# they have to wait on some network action) but you don't want to do | |
# them all at the same time (maybe the remote network action is CPU- or | |
# bandwidth-intensive and you want to avoid overloading the remote |
OlderNewer