I hereby claim:
- I am stuart-warren on github.
- I am stuartwarren (https://keybase.io/stuartwarren) on keybase.
- I have a public key ASBU_9soGfTFWe11KNVYZlZE5JY1tCqwgMfFvtM1iuNZFgo
To claim this, I am signing this object:
#!/usr/bin/env python3 | |
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer # python 3.7 | |
from prometheus_client import Histogram, generate_latest # pip install prometheus_client | |
LATENCY = Histogram('webhook_request_latency_seconds', 'Time for a request webhook.', ['path','method']) | |
REQUESTS = Counter('webhook_total', 'webhooks requests.', ['path','method']) | |
def request_metrics(func): | |
def wrapper(self): | |
with LATENCY.labels(self.path, self.command).time(): |
#!/usr/bin/env python | |
from http import HTTPStatus | |
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer | |
import base64 | |
import json | |
import logging | |
import os | |
import os.path | |
import ssl |
#!/bin/sh | |
# report which files in current git repo are changed most often | |
# useful for technical debt prioritisation | |
git log --name-only --oneline | sort | uniq -c | sort -nr | |
# with bars instead of numbers | |
git log --name-only --oneline | sort | uniq -c | sort -n | tail -n 20 | xargs -I{} python -c "input = '{}'; out = input.split(' '); bar = '#' * int(out[0]); print(f'{out[1]}\t{bar}')" | column -t |
# watch the current directory for changes to files | |
# order the files by size and output the files in 3 columns | |
# highlight changes between outputs | |
watch -d 'du -sh * | sort -hr | pr -3 -t' |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env bash | |
compgen -c git- |
#!/usr/bin/env bash | |
/usr/bin/curl -sf -H "Authorization: Bearer $(</var/run/secrets/kubernetes.io/serviceaccount/token)" \ | |
--cacert "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" \ | |
"https://${KUBERNETES_PORT_443_TCP_ADDR}/version" | |
# OR | |
/usr/bin/nc -w3 -z ${KUBERNETES_SERVICE_HOST} ${KUBERNETES_SERVICE_PORT} |
# assumes vendored deps, using eg glide | |
compile: | |
image: golang:1.7-alpine3.5 | |
variables: | |
PKG: "github.com/stuart-warren/mypackage" | |
stage: compile | |
script: | |
- mkdir -p /go/src/$(dirname $PKG) | |
- ln -s ${PWD} /go/src/${PKG} | |
- GOOS=linux go build -o yourbinary ${PKG} |
$ brew install fswatch | |
$ alias pywatch='fswatch -r -0 --monitor=poll_monitor $(find . -name *.py) | xargs --null -n1 -I{}' | |
$ alias gowatch='fswatch -r -0 --monitor=poll_monitor $(find . -name *.go) | xargs --null -n1 -I{}' | |
$ pywatch python setup.py test | |
$ gowatch go test -cover |
#!/usr/bin/env bash | |
get-configmap-template() { | |
echo '{"apiVersion": "v1","kind": "ConfigMap","metadata": {"name": ""},"data": {}}' | |
} | |
populate-configmap() { | |
jq --arg filename "$(basename $1)" --arg filecontent "$(<$1)" '.data += {($filename): $filecontent}' | |
} |