Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# You need: curl, jq, and ipcalc to run this.
# You should already have cut, sort and uniq if you're on OS X or Linux.
RANGES=$(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq .prefixes | jq '.[] | select(.region=="us-east-1")' | jq 'select(.service=="EC2")' | jq .ip_prefix | cut -d '"' -f 2 | sort | uniq)
for range in $RANGES
do
MIN=$(ipcalc -bn $range | grep "HostMin" | cut -d ':' -f 2)
@pwyliu
pwyliu / upload-ssec.sh
Created March 19, 2017 20:31 — forked from imbradbrown/upload-ssec.sh
Uploading to Amazon S3 from curl with Server Side Encrpytion - Customer Provided Key used. Note that this uses the Amazon Access Keys which should be used with care.
#!/bin/bash
## file to upload.
S3_UPLOAD_FILE=some/path/file.txt
## Specify the bucket name here. This can be found in the S3 console
S3_BUCKET=bucket name here
## The desired path relative to the root of the bucket. All folders must be forward slash '/' separated
S3_DESTINATION_FILE=folder/folder2/file.txt
import time
def rate_limited(max_rate):
"""
max_rate is in seconds
"""
min_interval = 1.0 / float(max_rate)
def decorate(func):
@pwyliu
pwyliu / lumberjack-suse
Last active August 29, 2015 13:56 — forked from shadabahmed/logstash-cert.sh
SLES/Suse init script for lumberjack (logstash-forwarder). Tested on SLES 11 SP1 with lumberjack 0.3.1.
#! /bin/sh
# BEGIN INIT INFO
# Provides: lumberjack
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@pwyliu
pwyliu / dynamic-puppet-environments.sh
Last active December 27, 2015 01:19 — forked from gaahrdner/dynamic-puppet-environments.sh
build script for jenkins + puppet + dynamic envs combo
#!/bin/bash
# Forked from https://gist.github.com/gaahrdner/4088204
# This script takes the following arguments:
# * -r the repository URL for your puppet modules
# * -p the destination directory to check out all the branches into
# * -d delete directories from destination that don't exist in repo
function die {
log $*
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO