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
print qq/Hello\n/; # same as: print "Hello\n"; | |
print q/He owes $5.00/; # same as: print 'He owes $5.00', "\n"; | |
@states=qw( E T A L ); # same as ("E", "T", "A","L") | |
$today = qx(date); # same as $today = `date`; |
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
python -c 'import string; CHARS=string.digits + string.ascii_lowercase; b36e = lambda integer,encoded="": encoded if integer<=0 else b36e(integer//36, CHARS[integer%36] + encoded); import sys; print b36e(int(sys.argv[1], 16))' ACEBACEACE |
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
# request CA via the host | |
openssl s_client -showcerts -connect www.example.com:443 < /dev/null | openssl x509 -outform PEM 2>/dev/null | |
# awk statement for wrangling | |
awk '/----BEGIN CERTIFICATE----/ { flag = 1; ++ctr } flag && ctr < 2 { print } /-----END CERTIFICATE-----/ { flag = 0 }' out | openssl x509 -noout -sha256 -fingerprint | |
# good luck though, not all servers give or have the CA accessible wtf. |
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
python -c "import sys,hashlib; print(hashlib.sha256(open(sys.argv[1], 'rb').read()).hexdigest())" <filename> |
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
echo '{"foo": true}' | python -c "from jwt.api_jws import PyJWS;from cryptography.hazmat.backends import default_backend;from cryptography.hazmat.primitives.serialization import load_pem_private_key; jws=PyJWS(); pk = load_pem_private_key(open('key.pem').read(), password=None, backend=default_backend()); import sys; msg = jws.encode(sys.stdin.read(), pk, algorithm='RS512'); print msg" |
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
# SimpleHTTPServer oneliner | |
openssl req -new -x509 -keyout /dev/stdout -out /dev/stdout -days 365 -nodes -subj "/C=XX/O=Default Company Ltd" 2>/dev/null > yourpemfile.pem ; python -c 'import sys, BaseHTTPServer, SimpleHTTPServer; import ssl; httpd = BaseHTTPServer.HTTPServer(("0.0.0.0", 4443), SimpleHTTPServer.SimpleHTTPRequestHandler); httpd.socket = ssl.wrap_socket (httpd.socket, server_side=True, certfile=sys.argv[1]); httpd.serve_forever()' yourpemfile.pem |
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 | |
# original url: http://www.jamescoyle.net/how-to/1073-bash-script-to-create-an-ssl-certificate-key-and-request-csr | |
set -e | |
set -x | |
domain="${1-$(cat /etc/hostname)}" | |
commonname="$domain" | |
# if the domain is a freakin IP it must also specify an IP SAN | |
# hopefully you have a python |
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
ansible localhost -i <(echo "localhost") -c local -m setup |
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
from collections import defaultdict | |
from itertools import imap | |
from boto import dynamodb | |
from magnitude import mg | |
REGION='us-west-1' | |
conn = dynamodb.connect_to_region(REGION) | |
WANT_PROPS = ( |
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
wget http://stedolan.github.io/jq/download/linux64/jq | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \ | |
"Name=instance-state-name,Values=running" \ | |
| jq -r \ | |
".Reservations[] | .Instances[] | .InstanceId" \ | |
aws ec2 describe-volumes --filters \ | |
"Name=status,Values=available" \ | |
| jq -r ".Volumes[] | .VolumeId" \ |
NewerOlder