Skip to content

Instantly share code, notes, and snippets.

View mmhmxx's full-sized avatar

Maciej Matysiak mmhmxx

View GitHub Profile
@mmhmxx
mmhmxx / aws_otp.sh
Last active February 11, 2019 11:44
aws_otp – get the one-time-password for AWS authentication.
# Requirements:
# * oathtool – install it with brew.
# * AWS-MFA password item in your keychain, under "login" keychains.
# Name: AWS-MFA
# Kind: application password
# Account: your_account (change below)
# Where: AWS-MFA
# Value: taken from the MFA setup on your AWS account, a 64-characters string (capital letters and ciphers)
#
# Usage:
@mmhmxx
mmhmxx / update_repos.sh
Created August 9, 2018 14:57
A function for updating all git repositories in the current directory.
ugit() {
local REPOS=($(find . -maxdepth 2 -type d -name '.git' |sed 's+/.git$++g' |sort))
[[ ${#REPOS} -eq 0 ]] && {
echo "There are no git repositories in $(pwd)"
kill -INT $$
}
echo -e "Git repositories in current directory: ${#REPOS[@]}.\n"
local NON_MASTERS=''
for r in ${REPOS}; do
cd ${r}
@mmhmxx
mmhmxx / tf.sh
Last active August 26, 2019 17:33
tf – a wrapper around Terraform
# A wrapper around Terraform: runs terraform with given command in an environment taken from current directory.
#
# Workflow:
# cd webops-terraform/$component/$environment
# tf a|apply
# tf g|get
# tf i|init
# tf l|landscape # plan piped through landscape: https://github.com/coinbase/terraform-landscape
# tf o|output
# tf p|plan
@mmhmxx
mmhmxx / aws_env.sh
Last active February 14, 2019 10:25
aws_env – get or refresh your AWS credentials for the SANDBOX environment.
# Usage: aws_env
# This function will:
# . set your AWS credentials for the current shell.
# or
# . refresh your credentials if the existing ones will expire within 5 minutes.
# The Sandbox environment is hardcoded (but we don't need credentials for any other environment).
aws_env() {
local DATE_NOW=$(date -j -f "%F %T" "$(date +'%F %T')" "+%s")
[[ -n ${AWS_ENV_EXPIRES} ]] && {
@mmhmxx
mmhmxx / keybase.md
Created June 18, 2018 09:40
Keybase identity proof.

Keybase proof

I hereby claim:

  • I am mmhmxx on github.
  • I am mmhmxx (https://keybase.io/mmhmxx) on keybase.
  • I have a public key ASBmZu88hkpgyOcQ1-0IdZF4aI9M3grD1ivtIamvK2FBkQo

To claim this, I am signing this object: