Skip to content

Instantly share code, notes, and snippets.

View willthames's full-sized avatar

Will Thames willthames

View GitHub Profile
### Keybase proof
I hereby claim:
* I am willthames on github.
* I am willthames (https://keybase.io/willthames) on keybase.
* I have a public key ASCL0vq92IOe-sdvgb55oOmSEp2Ihrle7nPR13ReEBxs0Ao
To claim this, I am signing this object:
# This is untested, and only really works if number of zones evenly divides number of instances
- name: create number_of_instances across a list of zones
ec2:
desired_count: "{{ number_of_instances / (zones | length) }}"
az: "{{ item % (zones | length) }}"
loop: "{{ number_of_instances | range }}"
@willthames
willthames / 2019 results
Last active February 27, 2019 07:58
Austin Scooter trip stats
# YYYY/MM/DD TRIPS DEVICES TRIPS/DEVICE DURATION DURATION/TRIP
2019/01/01 7488 3240 2.31111 95470.9 12.7498
2019/01/02 988 711 1.38959 8022 8.11943
2019/01/03 5595 2645 2.11531 62385.7 11.1503
2019/01/04 9671 3612 2.67746 124206 12.8432
2019/01/05 13724 4319 3.17759 209968 15.2993
2019/01/06 9652 3629 2.65969 149453 15.4842
2019/01/07 8049 3289 2.44725 99603.7 12.3747
2019/01/08 8760 3465 2.52814 99411.2 11.3483
2019/01/09 8176 3305 2.47383 83849.4 10.2556
nsenter -n -t <pid>
tcpdump -i eth0 -w /tmp/${HOST}.pcap
#!/bin/bash
set -eu
if [ $# -lt 2 ] ; then
echo "Usage: $0 [--profile profile] [--region region] [--key key] [--filter filterkey] user host [port]"
exit
fi
while true; do
apiVersion: v1
kind: ConfigMap
metadata:
name: test-rules
namespace: monitoring
data:
node.rules.yml: |-
{{ lookup('template', 'template.j2')|indent(4) }}
@willthames
willthames / manifest.yml
Created September 26, 2019 05:20
typical kubernetes deployment
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
{{ kube_deployment_labels | to_nice_yaml(indent=2) | indent(4) }}
name: {{ kube_resource_name }}
namespace: {{ kube_resource_namespace }}
spec:
revisionHistoryLimit: 3
replicas: {{ kube_deployment_replicas }}
local tokenize = {}
function tokenize.tokenize(uri)
-- URLs that end in an ID
for _, path in ipairs({“/api/jobs, “/api/resources”}) do
if string.find(uri, path .. "/[^/]*") then
return string.gsub(uri, path .. "/.*", path .. "/{id}")
end
end
return uri
local tokenize = {}
function tokenize.tokenize(uri)
-- URLs that end in an ID
for _, path in ipairs({“/api/jobs, “/api/resources”}) do
if string.find(uri, path .. "/[^/]*") then
return string.gsub(uri, path .. "/.*", path .. "/{id}")
end
end
return uri
log_by_lua_block {
local tokenize = require('tokenize')
ngx.var.tokenized_uri = tokenize.tokenize(ngx.var.uri)
}
opentracing_operation_name "$request_method $tokenized_uri";