Skip to content

Instantly share code, notes, and snippets.

#! /bin/sh
echo "hello, skills!"
date -u "$@"
@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 ()
{
@ddgenome
ddgenome / kaniko-gvisor-test.bash
Last active February 28, 2020 18:50
Run various versions of kaniko against runc and various versions of gVisor
#!/bin/bash
# test kaniko under gvisor
declare Pkg=kgtest
declare Version=0.1.0
set -o pipefail
# usage: msg MSG
function msg () {
@ddgenome
ddgenome / rbac-noaccess.ts
Created January 15, 2019 16:56
Kubernetes RBAC role, service account, and role binding for no access to in-cluster Kubernetes API
import * as k8s from "@kubernetes/client-node";
import { DeepPartial } from "ts-essentials";
const serviceAccount: DeepPartial<k8s.V1ServiceAccount> = {
apiVersion: "v1",
kind: "ServiceAccount",
metadata: {
name: "noaccess",
},
};
const role: DeepPartial<k8s.V1Role> = {
@ddgenome
ddgenome / atomist-link-image-webhook-codeship.bash
Created May 22, 2018 18:12
Atomist Link Image Webhook - Codeship
@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 / cli-publish.yml
Last active February 3, 2017 05:19
Rug CLI configuration for publishing Rug archives
# Set up the path to the local repository
local-repository:
path: "${user.home}/.atomist/repository"
# Set up remote repositories to query for Rug archives. Additionally one of the
# repositories can also be enabled for publication (publish: true).
remote-repositories:
maven-central:
publish: false
url: "http://repo.maven.apache.org/maven2/"
@ddgenome
ddgenome / cli.yml
Created January 31, 2017 02:36
Default Rug CLI configuration
# Set up the path to the local repository
local-repository:
path: "${user.home}/.atomist/repository"
# Set up remote repositories to query for Rug archives. Additionally one of the
# repositories can also be enabled for publication (publish: true).
remote-repositories:
maven-central:
publish: false
url: "http://repo.maven.apache.org/maven2/"
@ddgenome
ddgenome / k8.bash
Last active July 5, 2019 08:00
Kubernetes bash functions
# bash kubernetes functions
# kubectl with kubeconfig
function k () {
kubectl --kubeconfig=kubeconfig "$@"
}
# exec shell in pod
function k8sh () {
local p="$1"
shift
@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