Skip to content

Instantly share code, notes, and snippets.

@itsamenathan
itsamenathan / supported_workspaces.tf
Created May 29, 2018
Terraform workspace checking
View supported_workspaces.tf
variable "supported_workspaces" {
default = ["dev", "beta", "prod"]
}
resource "null_resource" "is_workspace_supported" {
count = "${contains(var.supported_workspaces, terraform.workspace) ? 0 : 1}"
"\n\n!!!! ERROR !!!!\nYou are getting this error because you are trying to use an unsupported workspace. \nSupported workspaces are: [${join(", ", var.supported_workspaces)}]. You are currently using the \"${terraform.workspace}\" workspace. \nPlease see the README file for information on how to configure a workspace." = true
}
@itsamenathan
itsamenathan / get_tags.sh
Created Apr 7, 2017
Get docker image tags from Gitlab Registry
View get_tags.sh
#/bin/bash
set -e
AUTH_URL="https://gitlab.com/jwt/auth"
SERVICE="container_registry"
SCOPE="repository:group_name/image_name:pull"
AUTH="some_passowrd"
TOKEN=$(curl -s -H "Authorization: Basic ${AUTH}" "${AUTH_URL}?service=${SERVICE}&scope=${SCOPE}" | jq '.token' -r )
View gist:fcd8f5d5ec7e780ffe96ec723d16e766
#!/bin/bash
set -x
set -e
case "$1" in
start)
echo "start"
USER="$2"
IP="$3"
View poorman.ntp
date -s "$(curl -s --head http://google.com | awk '/^Date/ {$1=""; print $0}')"
@itsamenathan
itsamenathan / logging
Last active Aug 29, 2015
bash logging functions
View logging
# Colors
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"
@itsamenathan
itsamenathan / git_commit
Last active Aug 29, 2015
Change git commit time
View git_commit
#!/bin/bash
if [ -z "$1" ]; then
echo "Didn't pass in option for date -d"
exit 1
fi
newdate=$(date -d "$1")
export GIT_AUTHOR_DATE=$newdate
export GIT_COMMITTER_DATE=$newdate
git commit
@itsamenathan
itsamenathan / grep -q
Created May 27, 2014
if with grep -q
View grep -q
word=Linux
letter_sequence=inu
if echo "$word" | grep -q "$letter_sequence"
# The "-q" option to grep suppresses output.
then
echo "$letter_sequence found in $word"
else
echo "$letter_sequence not found in $word"
fi
View keybase.md

Keybase proof

I hereby claim:

  • I am itsamenathan on github.
  • I am nathan (https://keybase.io/nathan) on keybase.
  • I have a public key whose fingerprint is B256 11F7 868D 408F 451D 21CA 882A C17B 7EA7 3818

To claim this, I am signing this object:

View if_command_exists.sh
if hash foo 2>/dev/null; then
echo "foo"
else
echo "no foo"
fi
You can’t perform that action at this time.