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 get_unused_port(): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.bind(('localhost', 0)) | |
_, port = sock.getsockname() | |
sock.close() | |
return port |
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
This is the baseline |
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 gunicorn.app.base import BaseApplication | |
from gunicorn.workers.sync import SyncWorker | |
from meinheld.gmeinheld import MeinheldWorker | |
class CustomWorker(object): | |
def handle_quit(self, sig, frame): | |
self.app.application.stop(sig) | |
super().handle_quit(sig, frame) |
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
body { | |
background: #222; | |
color: #a1a1a1; | |
} | |
a { | |
color: #949494; | |
} | |
a:link, a:visited { |
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
# Remove all exited containers | |
docker rm $(docker ps -qa --no-trunc --filter "status=exited") | |
# Remove all images by repository name | |
docker rmi $(docker images -q <repo_name>) | |
# Remove dangling images | |
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) | |
# Remove all networks that start with (older docker) |
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
docker network rm `docker network ls --filter name=tests-* -q` |
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 kubernetes.client import ApiClient, Configuration, CoreV1Api | |
from kubernetes.config import kube_config | |
def build_k8_client(cfg_dict): | |
loader = kube_config.KubeConfigLoader(cfg_dict) | |
config_cls = type.__call__(Configuration) | |
loader.load_and_set(config_cls) | |
Configuration.set_default(config_cls) |
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 | |
export MESSAGE=$(echo -e "\n\n$(git log `git describe --tags --abbrev=0`..HEAD --oneline)") | |
bumpversion \ | |
--message 'Bump version: {current_version} → {new_version}{$MESSAGE}' \ | |
${@:1} |
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 maya | |
from datetime import timedelta | |
def lookup_subtracted_time(days, hours, minutes): | |
delta = timedelta(days=days, hours=hours, minutes=minutes) | |
backdate = (maya.now() - delta).datetime() | |
localtime = backdate.astimezone(maya.get_localzone()) | |
return localtime.isoformat(), delta.total_seconds() / 60 |
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 pike.discovery import py | |
class MiddlewarePlugin(object): | |
def __init__(self, config): | |
self.config = config | |
@classmethod | |
def qualified_name(cls): | |
__, __, module_name = cls.__module__.rpartition('.') |
NewerOlder