Skip to content

Instantly share code, notes, and snippets.

@ddgenome
ddgenome / kube-context.bash
Last active May 15, 2020 15:07
Select kubectl context based on regular expression matching
# alias k for kubectl
# usage: k KUBECTL_ARGS...
function k () {
kubectl "$@"
}
# print or switch kubectl kubeconfig contexts
# usage: kc [MATCH_REGEXP]
function kc ()
{
#! /bin/sh
echo "hello, skills!"
date -u "$@"
@ddgenome
ddgenome / travis-ci-git-commit.bash
Last active February 16, 2023 06:13
Make a commit on a branch in a Travis CI build, dealing with detached HEAD state safely
#!/bin/bash
# function to make a commit on a branch in a Travis CI build
# be sure to avoid creating a Travis CI fork bomb
# see https://github.com/travis-ci/travis-ci/issues/1701
function travis-branch-commit() {
local head_ref branch_ref
head_ref=$(git rev-parse HEAD)
if [[ $? -ne 0 || ! $head_ref ]]; then
err "failed to get HEAD reference"
return 1
@ddgenome
ddgenome / aws-creds.bash
Last active February 5, 2024 19:32
Fetch AWS STS keys and set environment variables
#!/bin/bash
# Fetch 24-hour AWS STS session token and set appropriate environment variables.
# See http://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html .
# You must have jq installed and in your PATH https://stedolan.github.io/jq/ .
# Add this function to your .bashrc or save it to a file and source that file from .bashrc .
# https://gist.github.com/ddgenome/f13f15dd01fb88538dd6fac8c7e73f8c
#
# usage: aws-creds MFA_TOKEN [OTHER_AWS_STS_GET-SESSION-TOKEN_OPTIONS...]
function aws-creds () {
local pkg=aws-creds