Skip to content

Instantly share code, notes, and snippets.

View cdornsife's full-sized avatar

Chris Dornsife cdornsife

  • Chicago, IL
View GitHub Profile
@cdornsife
cdornsife / eks_clusters_to_kubectl.sh
Created December 24, 2024 15:46
Add EKS cluster kubeconfig for each cluster and region.
#!/usr/bin/env bash
for region in us-east-1 us-east-2; do
aws eks list-clusters --region $region --query 'clusters' --output text | tr '\t' '\n' \
| while IFS= read -r line; do
aws eks --region $region update-kubeconfig \
--name "${line}" \
--alias "${line}" \
--profile default
done
#!/bin/bash
# Author: [email protected]
# gofmt -s -w .
set -o errexit
set -o nounset
set -o pipefail
echo "run tests:"
@cdornsife
cdornsife / flag.Value
Last active July 25, 2017 17:12
Handy code to implement string map for pflag
package app
import (
"fmt"
"strings"
)
// See: https://github.com/spf13/pflag/issues/129
// $ mycommand --string-map-option "a=b,c=d"
@cdornsife
cdornsife / build.sh
Created March 6, 2017 20:59
Use a docker build container without a volume mount.
#!/usr/bin/env bash
PROJ=your-image-name
TAG=${1:-latest}
HASH=`date +%s`
BUILD_NAME=${PROJ}-build-${HASH}
rm -rf target
@cdornsife
cdornsife / .zshrc
Created February 20, 2017 17:49
Zsh forever history
#set history size
export HISTSIZE=5000
#save history after logout
export SAVEHIST=5000
#history file
export HISTFILE=~/.zhistory
#append into history file
setopt INC_APPEND_HISTORY
#save only one command if 2 common are same and consistent
setopt HIST_IGNORE_DUPS
@cdornsife
cdornsife / store configs in kubernetes with kubectl
Last active February 16, 2017 21:52
I use this to store cluster creation configs to the cluster itself. This prevents me from having to use S3 or GCS which means I have to write code to deal with each provider. This is provider agnostic.
#! /bin/bash
# tar.gz the config files. Store them as a kubernetes secret in namespace kube-system
set -o errexit
set -o pipefail
set -o nounset
KCTL="kubectl --kubeconfig=/your/kubeconfig.json --namespace=kube-system"
SECRET="my-fancy-configs"
@cdornsife
cdornsife / archive_email.sh
Last active December 24, 2024 16:13
If you wish to archive all emails in postfix using always_bcc, you can use this script to tame your archive email account. This script relies on doveadm to manage the files. Add it to your daily cron.
#! /bin/bash
# change your /etc/postfix/main.cf
# always_bcc = [email protected]
DOMAIN=example.com
ARCHIVE=archive@$DOMAIN
getemail() {
doveadm fetch -u $ARCHIVE hdr mailbox-guid $1 uid $2 | grep "$3" | cut -f 2 -d "<" | cut -f 1 -d ">"
}