This file contains 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 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 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 | |
# replace any with a specific interface you want to monitor or just use any to capture all interfaces | |
tcpdump -i any 'dst port 53' >> /var/log/dnsqueries.log | |
#### If using supervisord, use this template for setting up the program entry: | |
# [program:dnsworker] | |
# command=bash dnsquerylogger.sh | |
# autostart=true | |
# autorestart=true |
This file contains 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
# Command to run pt online schema change | |
pt-online-schema-change \ | |
D=<dbname>,t=<table_name>,h=<hostname>,u=<username> \ | |
--alter="<alter sql>" \ | |
--ask-pass \ | |
--execute \ | |
--max-load 100 \ | |
--critical-load 120 |
This file contains 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
--- Simple table to keep track of delete chunks | |
create table _delete_log | |
( | |
log varchar(200) null, | |
createdAt timestamp null | |
); | |
------------ Stored proc definition --------------- | |
DROP PROCEDURE IF EXISTS delete_chunks; | |
DELIMITER $$ |
This file contains 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 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 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 inspect my-sibling-dind-container --format '{{ .NetworkSettings.IPAddress }}') | |
-- Make sure both run on the same "network" (bridge by default in most cases) |
This file contains 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
### example for setting up a make workflow that can tag images based on the git tag | |
### the trailing ; are important: runs the commands in the same "shell" and the $$tag variable flows through | |
docker-build: | |
@echo "Latest 3 tags: "; \ | |
git ls-remote --sort='v:refname' --tags ./. | tail -n 3; \ | |
read -p "Enter New Tag:" tag; \ | |
echo "Releasing new tag: $$tag"; \ | |
git tag $$tag; \ | |
git push origin $$tag -f; \ |
This file contains 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
#!/usr/bin/env bash | |
###### ERROR TRAP - DONT WRITE OTHER COMMANDS BEFORE THIS ############ | |
set -eEx | |
function HANDLE_ERROR() { | |
echo "SCRIPT FAILED" | |
echo "FAILED AT: $(caller)" | |
# Do any other commands here | |
exit 1 | |
} |
NewerOlder