Skip to content

Instantly share code, notes, and snippets.

def concatenate(self, files, target, compress=False, progress=1):
"""
Concatenate all the lines from files into the target.
If compress is True, compress the file using gzip. Defaults to False.
If progress is an integer, log an INFO message every N files (where
N is the integer passed). Defaults to 1.
Returns target.
from setuptools import setup, find_packages
from pip.req import parse_requirements
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
REQUIREMENTS = os.path.join(BASE_DIR, 'requirements.pip')
DEPENDENCIES = [unicode(package.req)
for package in parse_requirements(REQUIREMENTS)]
setup(
install_requires = DEPENDENCIES,
-delete
Delete files; true if removal succeeded. If the removal failed, an error message is issued. If -delete fails, find's exit status will be nonzero (when it eventually exits). Use of
-delete automatically turns on the -depth option.
Warnings: Don't forget that the find command line is evaluated as an expression, so putting -delete first will make find try to delete everything below the starting points you speci‐
fied. When testing a find command line that you later intend to use with -delete, you should explicitly specify -depth in order to avoid later surprises. Because -delete implies
-depth, you cannot usefully use -prune and -delete together.
def obscure(string, replacement = '*'):
"""
Return string with all characters except the first obscured with the
given replacement character (default: *).
"""
import re
return re.sub(r'(?<!\A).', replacement, string)
In [9]: urlparse.urlunparse(['http', '', '/config', '', '', ''])
Out[9]: 'http:///config'
In [10]: urlparse.urlunparse(['mysql', '', '/config', '', '', ''])
Out[10]: 'mysql:/config'
@plathrop
plathrop / rename.sh
Last active December 14, 2015 13:48
#!/usr/bin/env bash
set -e
indir=${1}
outdir=${2}
case "$(arch)" in
i686) bits="32";;
x86_64) bits="64";;
In [10]: [foo for foo in xrange(10)]
Out[10]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In [11]: foo
Out[11]: 9
plathrop@spark.local tmp➔ for host in $(python -c 'print "\n".join(["apiservices-a%03i" % (i + 1) for i in range(6)])'); do echo $host; ssh -o StrictHostKeyChecking=no ${host}.krxd.net ./test-cassandra.py; echo "end $host"; done
apiservices-a001
OrderedDict([(u'fp:44c1a380-770f-11df-93f2-0800200c9a66', 'Ho58bsDg')])
OrderedDict([(u'fp:79816aa8-435a-471a-be83-4b3e0946daf2', 'H2JcfO5N')])
OrderedDict([(u'fp:91a8784a-ff7b-47cf-bbd7-f0e72d77b632', 'H9xnh8U0')])
OrderedDict([(u'fpex:54983c83-8810-4a6b-9ff1-81f7349ce967', 'Ht_PoXSR')])
OrderedDict([(u'fp:54983c83-8810-4a6b-9ff1-81f7349ce967', 'H0Qhj1FU')])
OrderedDict([(u'fp:7c727c7f-01f2-46b1-bafa-55662a7e6db8', 'H0Ynm2p-,HxfvaITJ,HxuBWZvq')])
OrderedDict([(u'fp:54983c83-8810-4a6b-9ff1-81f7349ce967', 'H0Qhj1FU')])
OrderedDict([(u'fp:79816aa8-435a-471a-be83-4b3e0946daf2', 'HR71sBdZ,H2JusNe0,HR71blpF')])
Package: *
Pin: release a=lucid-backports
Pin-Priority: 100
### From: http://git.itanic.dy.fi/?p=linux-stable;a=commitdiff_plain;h=9b17038d06c8ca74ca510d1a546a5dfd67f86e25
###
# From: Jan Kara <jack@suse.cz>
# Date: Thu, 13 Jan 2011 23:45:48 +0000 (-0800)
# Subject: writeback: avoid livelocking WB_SYNC_ALL writeback
# X-Git-Tag: v2.6.37.1~145
# X-Git-Url: http://git.itanic.dy.fi/?p=linux-stable;a=commitdiff_plain;h=9b17038d06c8ca74ca510d1a546a5dfd67f86e25
#
# writeback: avoid livelocking WB_SYNC_ALL writeback
#