Skip to content

Instantly share code, notes, and snippets.

@serkanh
serkanh / gist:166b1db35f84a4f80478
Created July 20, 2015 14:21
Sublime-3-GoSublime user settings.
{
// you may set specific environment variables here
// e.g "env": { "PATH": "$HOME/go/bin:$PATH" }
// in values, $PATH and ${PATH} are replaced with
// the corresponding environment(PATH) variable, if it exists.
"env": {"GOPATH": "$HOME/go", "PATH": "$GOPATH/bin:$PATH" },
"fmt_cmd": ["goimports"],
description "Vault server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
chdir /home/vault
env VAULT_ADDR=http://127.0.0.1:8200
script
@serkanh
serkanh / gist:1d155119960c34944789
Created January 15, 2016 15:13
s3 multibucket delete
aws s3 ls | grep "s3file" | awk '{print $3}' | xargs -I {} aws s3 rb s3://{}
# ~/.tmuxinator/test.yml
name: blackbook
root: /Users/shaytac/hearst/Track2/
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
@serkanh
serkanh / hipchat-v2.sh
Created July 21, 2016 18:57 — forked from danriti/hipchat-v2.sh
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
@serkanh
serkanh / gist:64c91898187e2ab03ae9cdc5e1d81114
Last active October 13, 2018 23:20
to get decoded user data from ec2 instances
#/bin/bash
trap exit INT
INSTANCES=$( aws --profile=HA ec2 describe-instances --query 'Reservations[].Instances[].InstanceId[]' | sed -e 's/\[//g' -e 's/\]//g')
SUM=0
echo $INSTANCES
for i in $( echo $INSTANCES | sed -e 's/"//g' -e 's/,//g' -e 's/\[//g' -e 's/\]//g' ) ;do
echo "---------------------------$i-------------------------------\n"
aws --profile=HA ec2 describe-instances --instance-ids $i --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value' --output text
aws --profile=HA ec2 describe-instance-attribute --instance-id $( echo $i | sed -e 's/"//g' -e 's/,//' -e 's/\[//g' -e 's/\]//g' ) --attribute userData \
| jq '.UserData.Value' | sed 's/"//g' | base64 --decode
@serkanh
serkanh / gist:c75a323218cc220f8ea188066838faaa
Last active August 7, 2019 03:49
aws user-data script to monitor memory & volume utilization of ec2 instances
#/bin/bash
sudo yum install unzip wget perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA -y
wget -O ~ec2-user/CloudWatchMonitoringScripts-1.2.1.zip http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip
cd ~ec2-user && unzip CloudWatchMonitoringScripts-1.2.1.zip
chown ec2-user:ec2-user ~ec2-user/aws-scripts-mon
rm CloudWatchMonitoringScripts-1.2.1.zip
crontab -l > ~ec2-user/mycron
echo "*/5 * * * * ~ec2-user/aws-scripts-mon/mon-put-instance-data.pl --disk-space-util --disk-path=/ --from-cron" >> ~ec2-user/mycron
echo "*/5 * * * * ~ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-used --mem-avail --swap-used" >> ~ec2-user/mycron
crontab ~ec2-user/mycron
@serkanh
serkanh / gist:7c537d37964ff032241993078e9788af
Last active October 20, 2016 14:40
use local wireshark ui for remote capture via ssh
wireshark -k -i <( ssh dest-host sudo /usr/sbin/tcpdump -i eth0 -w - )
@serkanh
serkanh / gist:23c73bdb1fc294ee9105f33ccc1f304e
Created November 14, 2016 19:20
Save tmux session via ascii cinema
asciinema rec -c "tmux attach -t 3"
@serkanh
serkanh / gist:d95f891b3f903746eb1533a113afb87b
Created November 28, 2016 19:01
zshrc export function for aws credentials
expawskeys(){
if [ -z "$1" ];then
echo "Profile prefix is required! ex: HA, jumpstart etc..."
fi
FILE="$HOME/.aws/credentials"
KEYS=$(cat ${FILE} | grep "\[$1\]" -A2 | tail -2 | cut -f2 -d= | xargs)
export AWS_ACCESS_KEY_ID=$(echo ${KEYS} | cut -f1 -d' ')
export AWS_SECRET_ACCESS_KEY=$(echo ${KEYS} | cut -f2 -d' ')
}