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
#!/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
# 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 |
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
import typing | |
from collections import OrderedDict | |
def lru_cache2(size=128): | |
cache = OrderedDict() | |
def make_key(x): | |
if isinstance(x, typing.Mapping): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import threading | |
from queue import Empty, Full | |
class QueueClosed(Exception): | |
pass | |
class MyQueue(): |
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
ctnrs=(nginx); fswatch -e '.*/\..*' `grep context docker-compose.yml|awk -F':' '{print $2}'`|while read; do kill -0 "$p" &>/dev/null && kill "$p" && p=; sleep 0.2; docker-compose rm -f -v $ctnrs && docker-compose up --build $ctnrs &; p=$!; done |