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
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "", | |
"Effect": "Deny", | |
"NotPrincipal": { | |
"AWS": [ | |
"arn:aws:iam::99999999999:role/AppRole", | |
"arn:aws:iam::99999999999:role/AdminRole" |
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
server { | |
listen 80 default_server; | |
location = /banana/ { | |
return 200 'this is a banana.\n'; | |
} | |
location / { | |
return 200 'not proxied.\n'; | |
} |
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; for test in defaultdict setdefault check_in; do echo -n "${test} "; python3 -m timeit -s "from test import test_${test} as test_func" "test_func()"; done | |
defaultdict 1000 loops, best of 3: 999 usec per loop | |
setdefault 1000 loops, best of 3: 1.89 msec per loop | |
check_in 1000 loops, best of 3: 1.27 msec per loop |
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
variable domain {} | |
locals { | |
split_domain = "${split(".", var.domain)}" | |
split_upper_domain = "${slice(local.split_domain, 1, length(local.split_domain))}" | |
upper_domain = "${join(".", local.split_upper_domain)}" | |
} | |
output sni_name { | |
value = "*${ |
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
var resp_body = ''; | |
await new Promise((resolve, reject) => { | |
var request = https.request(post_options, res => { | |
res.on('data', chunk => {resp_body += chunk}); | |
res.on('error', err => { | |
console.log("Error in POST:", err); | |
reject(err); | |
}); |
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 random | |
_DEF = object() | |
def bogo_range(start, end=_DEF, step=1): | |
if end is _DEF: | |
end = start | |
start = 0 | |
if not isinstance(end, int): | |
raise TypeError( |
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 datetime | |
import pytz | |
def rfc822_dt_format(dt): | |
assert isinstance(dt, datetime.datetime) | |
if dt.tzinfo is None: | |
dt.replace(tzinfo=pytz.utc) | |
return dt.strftime('%a, %d %b %Y %H:%M:%S %z') |
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 datetime import datetime | |
from dateutil.tz import tzoffset, tzutc | |
import re | |
THE_RE = re.compile( | |
"^" | |
"([0-9]{4})" | |
"-" | |
"([0-9]{2})" |
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 | |
from __future__ import print_function | |
import sys | |
if sys.version_info.major >2: | |
xrange = range | |
last = [] | |
with open("numbers", "r") as fandle: | |
for line in fandle: |
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 bash | |
set -eu -o pipefail | |
HOST=172.17.0.6 | |
REDIS_CMD=(redis-cli -h "$HOST" scan) | |
CMD_EXTRA=() | |
if [[ ! -z ${1:-} ]]; then CMD_EXTRA+=(MATCH "$1"); fi | |
if [[ ! -z ${2:-} ]]; then CMD_EXTRA+=(COUNT "$2"); fi |
NewerOlder