Skip to content

Instantly share code, notes, and snippets.

View afirth's full-sized avatar

Alastair Firth afirth

View GitHub Profile
@afirth
afirth / git-matching-branches.pl
Last active August 2, 2018 03:01
looks for git branches whose head is the same ref as HEAD
#!/usr/bin/env perl
##### git-matching-branches #####
# aws codebuild checks out webhook payloads in a detached head state
# This script looks for branches whose head is the same ref as HEAD
# It prints the short branch names, newline separated, and should play nicely with xargs
# e.g. ./git-matching-branches | xargs -n1 -I '{}' cp tarball_version.tar.gz tarball_version-'{}'.tar.gz
#
# N.B. Branches whose name does not satisfy semver 2.0.0 item 9 will cause this script to exit abnormally
# and probably break the build [0-9A-Za-Z.-]
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ack && \
brew install bash && \
brew install bash-completion && \
brew install docker && \
brew install fzf && \
brew install git && \
brew install gnutls && \
brew install graphviz && \
brew install jq && \
@afirth
afirth / gcblogs.sh
Created December 22, 2018 17:44
Tail logs of latest build from google cloud builder
gcloud beta builds list --limit=1 --format=value\(extract\(id\)\) | xargs gcloud beta builds log --stream
@afirth
afirth / latest_github_released_tag.sh
Created January 26, 2019 14:28
get latest github release tag
#!/usr/bin/env bash
set -eux -o pipefail
helmrelease=$(curl -sL "https://api.github.com/repos/helm/helm/releases/latest" | awk -F '"' '/tag_name/{print $4}')
echo using latest helm $helmrelease
@afirth
afirth / github_subpath_download.sh
Created January 26, 2019 14:31
save a subpath of a github repository
#!/usr/bin/env bash
set -eux -o pipefail
tarflags=--strip-components=2
# --wildcards required on linux but not osx
if [ "$(uname)" == "Linux" ]; then
tarflags+=--wildcards
fi
@afirth
afirth / helm.sh
Created January 26, 2019 16:58
tillerless helm
#!/usr/bin/env bash
# this starts a local tiller service with secret storage driver, then runs helm commands against it
# setting $TILLER_NAMESPACE is strongly recommended
# usage: ./helm.sh <valid helm args>
# afirth 2018
set -eu -o pipefail
# default to use if TILLER_NAMESPACE is not set
# kube-system (the default) is not a great idea
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Golang
which go > /dev/null && \
export GOPATH=$(go env GOPATH) && \
export PATH=$GOPATH/bin:$PATH
@afirth
afirth / afirth.zsh-theme
Created May 15, 2019 13:44
afirth zsh theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@afirth
afirth / go get binaries available on path
Last active January 2, 2021 13:51
Make binaries installed with go get available on path
# add to [bash/zsh]rc and source
# Golang
which go > /dev/null && \
export GOPATH=$(go env GOPATH) && \
export PATH=$GOPATH/bin:$PATH
@afirth
afirth / Dockerfile
Created May 29, 2019 15:29
Add jmx_exporter to Camunda BPM
FROM camunda/camunda-bpm-platform:tomcat-7.11.0
## Add prometheus exporter
RUN wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.11.0/jmx_prometheus_javaagent-0.11.0.jar -P lib/
#9404 is the reserved prometheus-jmx port
ENV CATALINA_OPTS -javaagent:lib/jmx_prometheus_javaagent-0.11.0.jar=9404:/etc/config/prometheus-jmx.yaml