This file contains hidden or 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
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] |
This file contains hidden or 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
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] |
This file contains hidden or 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
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] |
This file contains hidden or 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
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] |
This file contains hidden or 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 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') |
This file contains hidden or 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) | |
(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) |
This file contains hidden or 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
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; |
This file contains hidden or 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 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) |
This file contains hidden or 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
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) |
This file contains hidden or 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
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(): |