This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| export CONSUL_HTTP_ADDR="https://my-consul-address" | |
| VALUE=$(consul kv get <key>) | |
| if [ "$VALUE" != "locked" ]; then | |
| # Unlocked, check the timeout | |
| TIMEOUT=$(echo $VALUE | jq 'reduce .[] as $num (0; .+$num)') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| HTTP_STATUS_CODE=421 | |
| CF_DISTRIBUTION_NAME=foobar | |
| s3cmd "s3://${S3_BUCKET}/${LOGS_PREFIX}" | |
| ## OR s3cmd "s3://${S3_BUCKET}/${LOGS_PREFIX}/${CF_DISTRIBUTION_NAME}" to download only specific distributions | |
| zcat *.gz | awk 'match($9, /421/) && match($7, /foobar/) { print $7" "$9" "$16" "$10 }' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # exit when any command fails | |
| set -e | |
| current_command=$BASH_COMMAND | |
| last_command="" | |
| # keep track of the last executed command | |
| trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| aws ec2 describe-spot-instance-requests \ | |
| --filters Name=instance-id,Values="$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)" \ | |
| --region us-east-1 | \ | |
| jq -r '.SpotInstanceRequests | if length > 0 then "spot" else "normal" end' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "json" | |
| require "rexml/document" | |
| require "time" | |
| require "unpack_strategy" | |
| require "lazy_object" | |
| require "cgi" | |
| class AbstractDownloadStrategy | |
| extend Forwardable | |
| include FileUtils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ip route get 8.8.8.8 | awk '{print $NF; exit}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker save <image> | bzip2 | pv | ssh user@host 'bunzip2 | docker load' | |
| ## Credits: https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-via-repository |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| CMD="curl --write-out %{http_code} --silent --output /dev/null http://169.254.169.254/latest/meta-data/spot/termination-time" | |
| while true | |
| do | |
| if [ "$(${CMD})" != "404" ]; then | |
| # 2 minute warning received. Do all your cleanup work. | |
| echo "2 minute termination warning. Draining nomad node..." | |
| nomad node-drain -yes -self -enable | |
| echo "Hasta la vista baby, I will be back" | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # send 10% traffic | |
| http-request set-header Host foo.bar.com if { rand(10) eq 0 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/ | |
| # | |
| ARGS=2 | |
| E_BADARGS=99 | |
| if [ $# -ne $ARGS ] # correct number of arguments to the script; | |
| then |