Skip to content

Instantly share code, notes, and snippets.

View dstokes's full-sized avatar

Drew Stokes dstokes

View GitHub Profile
WSDL
!
"addition"
"custom
"division"
"example"
"example"config
"expample"
"fibonacci"]acl
"fibonacci"]captcha
@dstokes
dstokes / redis-monitor.sh
Last active December 19, 2019 03:25
StatsD Redis Monitor in 10LOC
#!/bin/bash
#
# Report redis usage data to statsd
# Metric Format: <env>.<hostname>.<redis>.<metric>
#
# Add to crontab for periodic monitoring
#
STATSD_HOST=<host>
STATSD_PORT=8125
@dstokes
dstokes / gist:3651554
Created September 6, 2012 05:13
Tmux Battery Indicator

Battery indicator for the tmux status line (add to ~/.tmux.conf)

Displays the charge percentage and a unicode lightning bolt when the battery is charging. Makes use of the pmset command for battery information.

Tested on MacOSX Mountain Lion

set -g status-right "batt: #(pmset -g batt | awk 'NR==2 {gsub(/;/,\"\"\\); \
 print (match($3,/^ch/\\) ? \"\⚡ \":\"\"\\) $2}') | %h-%d %H:%M "
@dstokes
dstokes / Dockerfile
Created August 24, 2017 22:52
Hello Kubernetes!
FROM alpine
COPY server.sh /srv/server.sh
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "/srv/server.sh"]
@dstokes
dstokes / elb-ssl.sh
Created June 12, 2017 23:13
Print SSL certificate names associated with ELB & ALB
#!/bin/bash
# setup ssl certificate formatter
exec 3> >(awk '$2 != "None" {split($2, a, "/"); $2=a[length(a)]; print; system("")}')
# inspect nlb
aws elb describe-load-balancers \
--query 'LoadBalancerDescriptions[].{Name: LoadBalancerName, SSLCertificate: ListenerDescriptions[?Listener.Protocol==`HTTPS`].Listener.SSLCertificateId | [0]}' \
--output text >&3
@dstokes
dstokes / main.py
Created May 31, 2017 22:01
Github to Codebuild Lambda Function
import boto3, json
def lambda_handler(event, context):
client = boto3.client('codebuild')
for e in event['Records']:
source = e['EventSource']
if source == 'aws:sns':
message = json.loads(e['Sns']['Message'])
project = message['repository']['name']
@dstokes
dstokes / siege_urls.sh
Created February 13, 2017 21:41
Generate randomized urls for Siege
#!/bin/bash
#
# Generate random urls for Siege
#
# $1: url
# $2: count
if [[ -z $1 ]]; then
echo "Usage: $0 http://my.site 1000"
@dstokes
dstokes / wtf.sh
Last active November 18, 2016 22:28
Cloudtrail calls by key ID
#!/bin/bash
shopt -s lastpipe
exec 3> >(egrep '^EVENTS' | egrep -o '{.+}' | json -gac 'this.userIdentity && this.userIdentity.accessKeyId == "<UR_KEY>"')
NEXT=""
TOKEN=""
COUNT=0
while [ -n "$TOKEN" ] || [ $COUNT -eq 0 ]; do
test -n "$TOKEN" && NEXT="--next-token '$TOKEN'"
@dstokes
dstokes / dns-check.sh
Created November 7, 2016 23:53
Test Dead Route53 DNS Records
#!/bin/bash
DOMAIN=$1
PORT=$2
TYPES=(A CNAME)
# resolve zone id
ZONE=$(aws route53 list-hosted-zones --query 'HostedZones[?Name==`'$DOMAIN'.`].Id' --output text)
if [[ -z "$ZONE" ]]; then
echo "Unrecognized domain: $1" >&2
@dstokes
dstokes / functions.sh
Created January 24, 2014 17:15
NPM failover in bash
# description:
# implement npmjs registry failover in your shell
#
# setup:
# npm install -g npm-delegate
#
# usage:
# npms install through
# npms i through async
#