Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# receive | |
nc -l 0.0.0.0 1234 | openssl aes-256-cbc -salt -d | pv | tar vx - | |
# send | |
tar -c <file or dir> | openssl aes-256-cbc -salt -e | nc -w 3 <host> 1234 |
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 sh | |
# Define your services here. One line per service. | |
services=' | |
php-fpm -F | |
nginx -g "daemon off;" | |
' | |
pids="" | |
die(){ [ -n "$pids" ] && kill $pids 2>/dev/null; wait $pids; } |
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 functools import reduce | |
from contextlib import suppress | |
def copy_key(src_dict, dst_dict, src_key, dst_key): | |
_s, _d = src_dict, dst_dict | |
with suppress(KeyError): | |
if '.' in dst_key: | |
*subkeys, dst_key = dst_key.split('.') | |
dst_dict = reduce(lambda x, y: x.setdefault(y, {}), subkeys, dst_dict) |
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
def merge_records_by_key(dicts1, dicts2, key): | |
"""Updates each dict1 containing key `key` from `dicts1` | |
with the corresponding dict2 from `dicts2` having | |
dict1[key] == dict2[key]. | |
""" | |
if len(dicts1) > len(dicts2): | |
probe, build = dicts1, dicts2 | |
hashmap = {d[key]: d for d in build if key in d} |
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 python3 | |
import sys | |
import re | |
# https://trac-hacks.org/ticket/11050#comment:13 | |
_illegal_unichrs = ((0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F), | |
(0xD800, 0xDFFF), (0xFDD0, 0xFDDF), (0xFFFE, 0xFFFF), | |
(0x1FFFE, 0x1FFFF), (0x2FFFE, 0x2FFFF), | |
(0x3FFFE, 0x3FFFF), (0x4FFFE, 0x4FFFF), |
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 subprocess | |
def diff(one, two): | |
with tempfile.TemporaryDirectory() as tmpdir: | |
f1, f2 = ('%s/%s' % (tmpdir, n) for n in (1,2)) | |
for f, txt in zip((f1, f2), (one, two)): | |
with open(f, 'w') as f: | |
f.write(str(txt)) | |
cmd = ('diff -w %s %s' % (f1, f2)).split() |
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 | |
docker rm $(docker ps -aq -f status=exited) | |
docker rmi $(docker images --quiet --filter "dangling=true") |
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 | |
for d in `docker ps -aq`; do | |
d_name=`docker inspect -f {{.Name}} $d` | |
echo "=========================================================" | |
echo "$d_name ($d) container size:" | |
sudo du -d 2 -h /var/lib/docker/aufs | grep `docker inspect -f "{{.Id}}" $d` | |
echo "$d_name ($d) volumes:" | |
for mount in `docker inspect -f "{{range .Mounts}} {{.Source}}:{{.Destination}} | |
{{end}}" $d`; do |
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
# It works on RedHat, OEL, Centos | |
curl -o /usr/bin/rlwrap https://dl.dropboxusercontent.com/u/21373460/rlwrap_static_x64 && chmod 755 /usr/bin/rlwrap |