Skip to content

Instantly share code, notes, and snippets.

View mgoodness's full-sized avatar

Michael Goodness mgoodness

View GitHub Profile
@mgoodness
mgoodness / access_dbs.py
Created July 14, 2015 13:41
Script to check file sizes and send email if approaching max_size
#!/usr/bin/python
import os
import smtplib
import time
from email.mime.text import MIMEText
access_dbs = [
{'location':'/srv/data/apps/Access/Data/Jobtrack/JobTrackData.mdb',
@mgoodness
mgoodness / rsync-snapshot.sh
Created July 14, 2015 20:32
Script for backing up from multiple locations via rsync using hardlinks
#!/bin/bash
# *** Accepts two optional arguments
# -tDATE: today's date (ISO-8601, yyyy-mm-dd)
# -yDATE: yesterday's date (ISO-8601, yyyy-mm-dd)
#
# Use these if a nightly backup is missed.
# "Yesterday's date" should be the date of the last successful backup.
# Otherwise --link-dest will fail and rsync will do a full copy
# instead of a diff.
@mgoodness
mgoodness / reflect.py
Created November 10, 2015 17:19
Python HTTP server that echos GET requests
#!/usr/bin/env python
# Reflects the requests from HTTP GET methods
# Written by Nathan Hamiel (2010), modified by Michael Goodness (2015)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from argparse import ArgumentParser
from urlparse import urlparse
import daemon
import socket
@mgoodness
mgoodness / aws-credentials
Last active August 18, 2016 14:17
Example AWS credentials file for Java SDK-compatible role assumption
[default]
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>
[prod]
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<PROD_ROLE_NAME>
source_profile = default
[stage]
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<STAGE_ROLE_NAME>
@mgoodness
mgoodness / aws-config
Last active August 18, 2016 14:17
Example AWS config file
[profile default]
output = json
region = us-east-1
[profile prod]
output = json
region = us-east-1
[profile stage]
output = json
@mgoodness
mgoodness / fish_right_prompt.fish
Created October 11, 2016 13:45
Add the current Kubernetes context to the right-hand side of your Fish Shell prompt
function fish_right_prompt
set -l k8s_color (set_color blue)
set -l k8s_context (kubectl config current-context)
echo -e -n -s $k8s_color "($k8s_context)"
end

Keybase proof

I hereby claim:

  • I am mgoodness on github.
  • I am mgoodness (https://keybase.io/mgoodness) on keybase.
  • I have a public key ASDT8fGpKWmps-o_HhjIM5NNTlPN3CQFs48vZEHFhOa5eQo

To claim this, I am signing this object:

@mgoodness
mgoodness / kube-rotate.sh
Last active November 11, 2017 09:13
Bash script for draining & terminating EC2 Kubernetes nodes
#!/usr/bin/env bash
k8s_node=$(echo $1 | cut -f2 -d '/')
kubectl drain --force --ignore-daemonsets --delete-local-data ${k8s_node}
if [[ $? -eq 0 ]]; then
kubectl delete node ${k8s_node}
fi
@mgoodness
mgoodness / update-tectonic-license.fish
Created November 13, 2017 18:03
Fish shell function for updating the CoreOS Tectonic license Secret
function update-tectonic-license -d 'Updates the Tectonic license secret' -a license_file contexts
set -l license_secrets tectonic-license tectonic-license-secret
set -l current_context (kubectl config current-context)
if test -z "$license_file"
echo "usage: update-tectonic-license <path/to/license_file> [<contexts>]"
end
if test -z "$contexts"
set contexts (kubectl config view -o go-template="{{ range .contexts }}{{ .name | println }}{{ end }}")
@mgoodness
mgoodness / count-ingress.fish
Created December 14, 2017 16:37
Outputs the number of Ingresses (>=5) in each Namespace, plus Annotations
function count-ingress
for namespace in (kubectl get ns -o name | cut -d/ -f2)
set -l product_name (kubectl get ns $namespace -o json | jq -r '.metadata.annotations."ticketmaster.com/name"')
set -l tech_owners (kubectl get ns $namespace -o json | jq -r '.metadata.annotations."ticketmaster.com/tech-owner"')
set -l count (kubectl -n $namespace get ing --no-headers --ignore-not-found | wc -l | tr -d ' ')
if test $count -ge 5; echo $namespace \($product_name - $tech_owners\): $count; end
end
end