Skip to content

Instantly share code, notes, and snippets.

View ahawkins's full-sized avatar
💭
🌈🏄🏼‍♂️🤙🏻

Adam Hawkins ahawkins

💭
🌈🏄🏼‍♂️🤙🏻
View GitHub Profile
@ahawkins
ahawkins / assert.sh
Last active March 19, 2021 04:15
stdlib.sh
assert::var() {
if [ -z "${1:-}" ]; then
log::error "Argument required"
return 1
fi
set +u
if [ -z "${!1}" ]; then
log::error "${1} required, nothing given"
return 1
@ahawkins
ahawkins / backpor-cycle-times.rb
Last active June 1, 2020 21:06
Backport Cycle Times
#!/usr/bin/env ruby
# vim: set expandtab sts=2 tw=2 sw=2:
$stdout.sync = true
$stderr.sync = true
require 'octokit'
require 'dalli'
require 'json'
require 'time'
@ahawkins
ahawkins / config_map.yml
Last active September 4, 2018 06:34
SycllaDB Kubenetes Examples
apiVersion: v1
kind: ConfigMap
metadata:
name: scylla
data:
readiness-probe: |
#!/usr/bin/env bash
set -euo pipefail
@ahawkins
ahawkins / env.js
Last active August 22, 2018 05:29
let AWS = require('aws-sdk');
let DB = require('./db');
class Configuration {
constructor() {
this.bucket = process.env.S3_BUCKET;
}
get dynamoDBclient() {
return new AWS.DynamoDB({
@ahawkins
ahawkins / create_alarms.sh
Last active January 1, 2019 17:22
Install cron job to report memory utilization to cloudwatch
#!/usr/bin/env bash
set -xeuo pipefail
main() {
# TODO: add all your desired regions here
local -a regions=(ap-south-1)
for region in "${regions[@]}"; do
aws --region "${region}" cloudwatch put-metric-alarm \
@ahawkins
ahawkins / pipeline.yml
Created July 10, 2017 05:27
My Buildkite Pipeline
steps:
- name: ':pray: Test non-production'
command: script/ci/test
agents:
queue: 'elastic'
env:
STAGES: sandbox
branches: '!master'
artifact_paths: 'tmp/log/**/*'
@ahawkins
ahawkins / await-release
Last active February 8, 2018 03:06
Run 7 log analysis and script
#!/usr/bin/env bash
# This script is a workaround for https://github.com/kubernetes/helm/issues/2288.
# helm install --wait should do everything this script does. It should be deleted
# when the bug is fixed.
set -euo pipefail
main() {
local counter=0 release timeout pods
counter=0
while [ "${counter}" -lt "${timeout}" ]; do
pods="$(kubectl get pods \
-l "release=${release}" \
-o 'custom-columns=NAME:.metadata.name,STATUS:.status.phase,Node:.spec.nodeName' \
-n "${KUBE_NAMESPACE}" \
--context "${KUBE_CONTEXT}" \
| tail -n +2
)"
@ahawkins
ahawkins / build
Last active May 4, 2017 17:43
script/build -- Templated helm chart generation
#!/usr/bin/env bash
set -euo pipefail
main() {
local market stage branch build_number src_directory destination_directory
local name version chart_version
version="$(cat VERSION)"
@ahawkins
ahawkins / deployment.yaml
Created May 4, 2017 17:26
kviberg sample deployment template
{{- $stage := .Values.stage }}
{{- range $pod := .Values.topology.pods }}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: '{{ template "fullname" $ }}-{{ $pod.name | replace "_" "-" }}-{{ $pod.tier }}'
labels:
release: "{{ $.Release.Name }}"
chart: '{{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "-" }}'