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 | |
parser = re.compile('(?:[0-9\.]+)') | |
lambda x: [float(item) for item in parser.findall(repr(x))] |
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
amodulename = 'modulename' | |
try: | |
import pyximport | |
pyximport.install() | |
except: | |
print('Cython import failed; {0} will use the legacy (pure Python) mode.'.format(amodulename)) | |
from modulenamevanilla import class1, class2, class3 | |
else: | |
try: |
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
#!/bin/sh | |
< $1 grep \\citation | cut -c 10- | sed -e "s/[{},]/\n/g" | sed -e "/^$/d" | sort -u |
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
#!/bin/bash | |
HOST=$1 | |
TABLE=$2 | |
IP=$(getent hosts $HOST | cut -d \ -f 1) | |
CURRENT=$(ip rule | grep $IP | cut -d \ -f 4) | |
PRIORITY=1000 | |
if [ $CURRENT ]; then | |
echo Resetting rule for $HOST with IP $IP |
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
#!/bin/bash | |
TUNNEL="tun0" | |
TABLE="tablename" | |
OUTADDR=$(ip addr | grep $TUNNEL | sed -nr 's/.*peer ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/p') | |
ip route add default via $OUTADDR dev $TUNNEL table $TABLE |
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
#!/bin/bash | |
TUNNEL="tun0" | |
TABLE="tablename" | |
ROUTE=$(ip route list table $TABLE) | |
ip route del $ROUTE table $TABLE |
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
#!/bin/sh | |
# /etc/init.d/SpiderOak | |
### BEGIN INIT INFO | |
# Provides: SpiderOsk | |
# Required-Start: $network $syslog $remote_fs | |
# Required-Stop: $network $syslog $remote_fs | |
# Should-Start: $named $time | |
# Should-Stop: $named $time | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |
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
cylon = lambda plan: iter(lambda: plan, None) | |
if __name__ == '__main__' | |
for i, skinjob in enumerate(cylon(6)): | |
print('%d:\t%d'%(i+1, skinjob)) | |
if i >= 11: | |
break |
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 | |
def findMatches(source, substr): | |
matches = [] | |
for root, dirnames, filenames in os.walk(source): | |
for filename in filenames: | |
if filename.find(substr) > -1: | |
matches.append(os.path.join(root, filename)) | |
return matches |
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 CommonReducer(dict): | |
''' | |
Object based on 'dict' that implements the binary addition (obj1 + obj1) and | |
accumulation (obj += obj2). These operations pass through to the entries in | |
the commonReducer. | |
Instances of commonReducer are also callable, with the syntax: | |
cr(key, value) | |
this is equivalent to cr += {key: value}. | |
''' |
OlderNewer