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 | |
if [ -z "$1" ]; then | |
echo "Please provide a name for the new vm" | |
exit 1 | |
fi | |
export NAME="$1" | |
export UU=$(uuidgen) | |
echo $NAME $UU |
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
def concurrent_map(func, *iterm, **kwargs): | |
""" | |
threaded version of map() | |
Usage: | |
>>> my_data = [1,2,3,4,5] | |
>>> def my_func(x): | |
... return x*x | |
... | |
>>> concurrent_map(my_func, my_data) | |
[1, 4, 9, 16, 25] |
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 | |
current_dir = os.path.dirname(os.path.abspath(__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
def widthprint(lst, width=5): | |
for n, i in enumerate(lst): | |
if n % width == 0: | |
print('') | |
print i, |
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
try: | |
import requests | |
except ImportError: | |
def install_package(dep): | |
# If you don't have pip, you're screwed. | |
from pip.commands.install import InstallCommand | |
dep_l = [dep] | |
inst = InstallCommand() | |
opts, args = inst.parser.parse_args() | |
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
#!/usr/bin/env python | |
""" | |
ListeningSocketHandler | |
====================== | |
A python logging handler. | |
logging.handlers.SocketHandler is a TCP Socket client that sends log | |
records to a tcp server. | |
This class is the opposite. |
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
# /etc/pam.d/nginx | |
auth required /lib/security/pam_krb5.so | |
account required /lib/security/pam_krb5.so |
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 urllib2 | |
def run_webscript(script_url): | |
script_file = os.path.basename(script_url) | |
with urllib2.urlopen(script_url) as u: | |
with open(script_file, 'w') as s: | |
s.write(u.read()) | |
execfile(script_file, dict(__file__=script_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
function screen_it { | |
NL=`echo -ne '\015'` | |
SCREEN_NAME=${SCREEN_NAME:-screeened} | |
screen -S "$SCREEN_NAME" -X screen -t $1 | |
sleep 1.5 | |
screen -S "$SCREEN_NAME" -p $1 -X stuff "$2""$NL" | |
} |
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 | |
echo -n "Passphrase:" | |
read -sr p | |
gpg -d --batch --passphrase "$p" "$0" | python | |
exit $? | |
-----BEGIN PGP MESSAGE----- | |
Version: GnuPG v2.0.19 (GNU/Linux) |
OlderNewer