Skip to content

Instantly share code, notes, and snippets.

View joedougherty's full-sized avatar

Joe Dougherty joedougherty

View GitHub Profile
@joedougherty
joedougherty / post-openvpn-install.log
Created September 26, 2015 17:15
create-vpn-log-2015-2015-09-26_13:15:03
PLAY [create vpn server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ******
ok: [localhost]
TASK: [create-droplet | create digitalocean droplet] **************************
ok: [localhost]
@joedougherty
joedougherty / run.log
Created September 26, 2015 16:31
create-vpn-log-2015-09-26_12:30:28
joe@nor ~/ansible-digitalocean-vpn $ ./create-vpn
PLAY [create vpn server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ******
ok: [localhost]
@joedougherty
joedougherty / nmcli-missing.log
Created September 5, 2015 04:46
playbook run log 2015-05-15
PLAY [create vpn server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ******
ok: [localhost]
TASK: [create-droplet | create digitalocean droplet] **************************
ok: [localhost]
@joedougherty
joedougherty / create-vpn-with-sudo.log
Created August 27, 2015 18:12
Log of ./create-vpn with explicit sudo
PLAY [create vpn server] ******************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [create-droplet | ensure dopy is installed (for digitalocean API)] ******
ok: [localhost]
TASK: [create-droplet | create digitalocean droplet] **************************
ok: [localhost]
@joedougherty
joedougherty / display-ssh-key-ids.py
Created August 26, 2015 17:38
Convert bash script into Python for cross-platform running
import tempfile, os, subprocess
if not 'DO_API_TOKEN' in os.environ:
print("DigitalOcean API token not found. Export DO_API_TOKEN.")
exit(1)
with tempfile.NamedTemporaryFile() as fp:
fp.write("localhost ansible_connection=local")
invocation = "ansible localhost -i {tmpfile} -m digital_ocean -a".format(tmpfile=fp.name).split(' ')
invocation.append('command=ssh list_keys=true')
@joedougherty
joedougherty / hyserver.py
Last active August 29, 2015 14:24
Porting @alienoid's WSGI server code to Hy! Source: http://ruslanspivak.com/lsbaws-part1/
(import socket)
(import [collections [namedtuple]])
(setv bindparams (namedtuple "bindparams" ["host" "port"]))
(setv bp (bindparams "" 8888))
(setv listen_socket (socket.socket socket.AF_INET socket.SOCK_STREAM))
(listen_socket.setsockopt socket.SOL_SOCKET socket.SO_REUSEADDR 1)
(listen_socket.bind bp)
(listen_socket.listen 1)
@joedougherty
joedougherty / encode.sas
Created September 15, 2014 20:03
encode.sas
filename pwfile '~/tmp-passwd';
proc pwencode in="&sysparm" out=pwfile; run;
data _null_;
file stdout;
infile pwfile obs=1 length=l;
input @;
input @1 line $varying1024. l;
put line;
@joedougherty
joedougherty / InlineSAS.py
Created August 29, 2014 14:11
InlineSAS
import subprocess, os, tempfile
def callSAS(sas_str):
f = tempfile.NamedTemporaryFile(delete=False)
f.write(sas_str)
f.close()
invocation = ['sas', '-sysin', f.name]
r = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@joedougherty
joedougherty / popen.py
Created June 16, 2014 17:29
Capture stdout, stderr, and return code from subprocess.Popen
from subprocess import Popen, PIPE
r = Popen(['/path/to/test.sh'], stdout=PIPE, stderr=PIPE)
stdout, stderr = r.communicate()
result = r.wait()
print(stdout, stderr, result)
from pprint import pprint
lens_to_test = range(2,26)
lengths = {}
def all_words():
all_words = []
words = '/usr/share/dict/words'
f = open(words,'r')
for w in f.readlines():