Skip to content

Instantly share code, notes, and snippets.

View j1n6's full-sized avatar
🎯
Focusing

Jing Dong j1n6

🎯
Focusing
View GitHub Profile
@j1n6
j1n6 / restore_glacier_to_s3.sh
Created March 23, 2015 14:56
recursively restore glacier file for a path
# You might get a couple of errors:
# 1. This is not Glacier type
# Restore is not allowed, as object's storage class is not GLACIER
# 2. Already requested
# Object restore is already in progress
# 3. This is a path object
# The specified key does not exist.
for key in `aws s3 ls --recursive s3://{BUCKET}/{PATH} | awk '{ print $4}'` ; do echo "==> $key"; aws s3api restore-object --bucket {BUCKET} --key $key --restore-request '{"Days": 1}' ; done
@j1n6
j1n6 / ec2_vpc_id.rb
Created February 9, 2015 18:07
Get vpc id, put file at /usr/lib/ruby/vendor_ruby/facter
require "net/http"
require "facter"
require "facter/ec2"
# vpc-id is in a newer metadata api rev than the usual EC2 facts
Facter.add(:ec2_vpc_id) do
setcode do
if !Facter.value('ec2_instance_id').nil? && !Facter.value('ec2_mac').nil?
mac = Facter.value('ec2_mac')
description "Faye websockets"
start on runlevel [2345]
stop on runlevel [!2345]
#Respawn the process if it crashes
#If it respawns more than 10 times in 5 seconds stop
#respawn
respawn limit 10 5
@j1n6
j1n6 / s3_ip_based_permission.md
Created November 26, 2014 11:39
Allow a single IP to access S3 Bucket

Only allow specific IP address to access this bucket via API or HTTP.

{
	"Version": "2008-10-17",
	"Id": "S3PolicyId1",
	"Statement": [
		{
 "Sid": "IPDeny",
#!/usr/bin/env ruby
require 'socket'
require 'optparse'
# Collect INFO from Redis, report it to Graphite
opts = OptionParser.new do |opts|
opts.banner = "Usage: redis-graphite.rb redis_host[:port] graphite_host [graphite_prefix(e.g. redis.cluster-name.server-identifier)]"
opts.on( '-h', '--help', 'Display this screen' ) do
puts opts
[supervisord]
nodaemon=true
loglevel=debug
[program:bamboo]
redirect_stderr=true
command=/bin/bash -c "MARATHON_ENDPOINT=${MARATHON_ENDPOINT}; BAMBOO_ENDPOINT=${BAMBOO_ENDPOINT}; BAMBOO_ZK_HOST=${BAMBOO_ZK_HOST}; BAMBOO_ZK_PATH=${BAMBOO_ZK_PATH}; /var/bamboo/bamboo -bind="${BIND-:8000}" -config=${CONFIG_PATH-:config/production.example.json}"
@j1n6
j1n6 / clear_osx_cache_example.sh
Last active August 29, 2015 14:08
disable osx cache
# Microsoft Windows
# (Win 7/Vista/XP/Win ME/Win 2000/Win 98)
# - Start -> Run -> type cmd
# At the command prompt, type:
ipconfig /flushdns
# Certain Linux distributions
# Restart the nscd daemon
/etc/rc.d/init.d/nscd restart
@j1n6
j1n6 / shellshock.sh
Last active August 29, 2015 14:07
shellshock script ubuntu update
#!/bin/bash
# Check your release, none LTS need to apply this script
# lsb_release -a
cd /tmp && mkdir src && cd src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#download all patches
for i in $(seq -f "%03g" 0 27); do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done
#!/bin/sh
slapcat -v -l ldap.ldif
@j1n6
j1n6 / gist:5cf15daab8b4bf739fd5
Created June 24, 2014 17:01
rkhunter check command
sudo rkhunter --quiet --checkall --no-mail-on-warning