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 | |
alias docker-ip="docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'" | |
function _docker-ip() { | |
# No need to worry about spaces in this output, because | |
# docker only allows names in the form [a-zA-Z0-9][a-zA-Z0-9_.-]* | |
local pos_comps=$(docker ps --format "{{.ID}} {{.Names}}") | |
# $COMP_WORDS array with the current line | |
# $COMP_WORD the current word we're comping |
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
$python3 test.py | |
a | |
A | |
À La Garçonne | |
b | |
B | |
$python2 test.py | |
a | |
A | |
À La Garçonne |
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 dateutil.parser, datetime, pytz | |
def printy(thing): | |
print repr(thing) | |
x = datetime.datetime.utcnow() | |
printy(x) | |
x = pytz.utc.localize(x) | |
printy(x) | |
x = x.isoformat() |
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 |
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
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
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
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
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
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 = "*${ |
OlderNewer