Skip to content

Instantly share code, notes, and snippets.

# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#!/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
@pwyliu
pwyliu / Dockerfile
Created March 2, 2016 01:01
A sample dockerfile
FROM ubuntu-debootstrap:precise
# Install repo
RUN apt-get -qq update && \
apt-get -qq install curl apt-transport-https --no-install-recommends && \
curl ${REPO_KEY} | apt-key add - && \
echo "deb ${REPO_URL} precise main" >> /etc/apt/sources.list && \
rm -rf /var/lib/apt/lists/* && rm -rf /usr/share/man/* && rm -rf /usr/share/doc/*
# Install service
@pwyliu
pwyliu / Client.md
Last active August 29, 2015 14:02
modsec test logs and setup

This is what the clients sees. In this case the client was Chrome 32.0.1700.77.

Modsec on, Custom-Header is not passed

HTTP/1.1 200 OK
Server: nginx/1.6.0
Date: Wed, 04 Jun 2014 18:07:40 GMT
Content-Type: application/json
Content-Length: 36
import time
def rate_limited(max_rate):
"""
max_rate is in seconds
"""
min_interval = 1.0 / float(max_rate)
def decorate(func):
@pwyliu
pwyliu / engage.sh
Last active August 29, 2015 13:57
set up a ubuntu workstation
#!/bin/bash
set -e
PUPPET_URL="https://apt.puppetlabs.com"
PUPPET_DEB="puppetlabs-release-trusty.deb"
GITHUB_PROJECT="puppet-nachoboss"
GITHUB_URL="https://github.com/pwyliu/$GITHUB_PROJECT.git"
wget "$PUPPET_URL/$PUPPET_DEB"
sudo dpkg -i ${PUPPET_DEB}
@pwyliu
pwyliu / graylog2-server.conf.erb
Last active August 29, 2015 13:57
erb templates for graylog2 upstart scripts
#!upstart
description "graylog2-server"
start on started mongodb
stop on runlevel [016]
console log
respawn
respawn limit 10 5
@pwyliu
pwyliu / README.md
Last active February 4, 2018 16:01
Dashing widget that shows KACE K1000 service desk open ticket count

##Preview screenshot

##Description Shows open ticket count from the KACE K1000 service desk. You can set up teams based on KACE appliance usernames and display a widget per team, or you can display a global count. Or both!

##Dependencies

@pwyliu
pwyliu / keybase.md
Last active August 29, 2015 13:56
keybase.io identity statement

Keybase proof

I hereby claim:

  • I am pwyliu on github.
  • I am pwyliu (https://keybase.io/pwyliu) on keybase.
  • I have a public key whose fingerprint is AED1 C680 D030 4CE0 3C4C 4573 FAE8 07B3 EE1F 2CA3

To claim this, I am signing this object: