Skip to content

Instantly share code, notes, and snippets.

View udondan's full-sized avatar
🤠

Daniel Schroeder udondan

🤠
View GitHub Profile
@rmwpl
rmwpl / tf-prompt.sh
Created January 11, 2018 16:07
Terraform bash prompt, to be used with bash-git-prompt
#!/bin/bash
__terraform_ps1()
{
# get current workspace
WORKSPACE=$(terraform workspace show)
if $(pwd | /bin/grep -q 'terraform'); then
if [ -n "$WORKSPACE" ]; then
echo -ne "${White}(terraform: "
@rkrzr
rkrzr / auto_tags.py
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
@lestephane
lestephane / Dockerfile
Created September 10, 2017 19:35
Dockerized terraform bundler
FROM golang:alpine
RUN apk update && apk upgrade && \
apk add --no-cache git zip
ARG TERRAFORM_VERSION
RUN git clone --single-branch --branch v${TERRAFORM_VERSION} https://github.com/hashicorp/terraform.git /go/src/github.com/hashicorp/terraform
RUN cd $GOPATH/src/github.com/hashicorp/terraform && echo $GOPATH && go install ./tools/terraform-bundle
@hareeqi
hareeqi / change_swagger_host.js
Last active December 13, 2018 14:29
dynamic host for swagger ui 3.x
// not the most elgant way but it works
// in the console post the function below and call changeSwagger("http","localhost:5050","/my_path/)
function changeSwagger (scheme,host,path) {
var newspec = ui.spec().toJSON().resolved
newspec.scheme = [scheme] || newspec.scheme
newspec.host = host || newspec.host
newspec.basePath = path || newspec.basePath
ui.getStore().dispatch({type:'set_scheme',payload: {scheme: newspec.scheme[0]}})
@hakobe
hakobe / client.go
Created September 23, 2016 16:33
golang unix domain socket
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@romellem
romellem / commit-msg
Created June 13, 2016 16:11
Git hook - Post-commit spell check (using `aspell`)
#!/bin/bash
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "Aspell not installed - unable to check spelling" >&2
exit
else
WORDS=$($ASPELL --mode=email --add-email-quote='#' list < "$1" | sort -u)
fi
if [ -n "$WORDS" ]; then
printf "\e[1;33m Possible spelling errors found in commit message:\n\e[0m\e[0;31m%s\n\e[0m\e[1;33m Use git commit --amend to change the message.\e[0m\n\n" "$WORDS" >&2
@mechcozmo
mechcozmo / IAM Permissions List.md
Last active February 15, 2024 20:35
A list of IAM permissions you can use in policy documents. Collected from the myriad of places Amazon hides them. (incomplete)
@BryanSchuetz
BryanSchuetz / concat.liquid
Created May 5, 2016 16:20
Concat arrays in Jekyll(liquid)
{% assign all_hosts = "" | split: "" %}
{% for host in site.data.shared_hosts %}
{% assign all_hosts = all_hosts | push: host %}
{% endfor %}
{% for host in site.data.paas_hosts %}
{% assign all_hosts = all_hosts | push: host %}
{% endfor %}
@xiongchiamiov
xiongchiamiov / why.sh
Last active March 14, 2023 04:19
Use this when Amazon gives you an "Encoded authorization failure message" and you need to turn it into something readable. If you only get a request id... you're out of luck.
function decode-authorization-failure-message {
if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<'EOT'
Usage: decode-authorization-failure-message <message>
Use this when Amazon gives you an "Encoded authorization failure message" and
you need to turn it into something readable.
EOT
return 1
fi