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 / 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')
@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 / plot.sh
Last active August 29, 2015 14:20
apache bench & gunplot
ab -n 400 -c 10 -g "perf-data.tsv" "http://example.com/"
gnuplot <<- EOF
# Let's output to a jpeg file
set terminal png size 1000,600
# This sets the aspect ratio of the graph
set size 1, 1
# The graph title
set title "Benchmark testing"
# Where to place the legend/key
@j1n6
j1n6 / nginx-openresty-ubuntu-build-dependencies.sh
Created March 17, 2016 10:03 — forked from markselby/nginx-openresty-ubuntu-build-dependencies.sh
Build Nginx OpenResty version on Ubuntu.This is part of the high performance caching blog on writebox.co.uk
# Build dependencies for OpenResty.
sudo apt-get install build-essential libpcre3-dev libssl-dev libgeoip-dev
# Install standard Nginx first so that you get the relevant service scripts installed too
sudo apt-get install nginx
# If you want to access Postgres via Nginx
sudo apt-get install libpq-dev
$ cat ~/src/foo.bar.com/furoshiki/vagrant/salt/salttest/debian-jessie/Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian-jessie"
config.landrush.enabled = true
# my-states is a collection of custom states
/my-states
/ntp
/docker
/syslog-ng
# Kubernetes formula is a collection of implmeentations specific for kubernetes
# The aim is to keep a copy of their implmeentation in the same my-states tree without causing conflicts with
# exsiting state implmenetation.
# I'm expecting to make some changes to the kube states to ensure requiring by relative path
@j1n6
j1n6 / Saltfile
Last active June 6, 2016 09:36
Script and schema to manage Salt Fomulars dependencies from third party formula using git
# A yaml format file to pull dependencies into your own salt state
dependencies:
# local formular namespace will be called ntp
ntp:
# git repository
source: [email protected]:saltstack-formulas/ntp-formula.git
# copy sub directory as the root state
source_path: ntp
# version of the git repository
$ sudo apt-get update
$ sudo apt-get install nfs-common
$ sudo mount -t nfs4 -o vers=4.1 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).<fs-id>.efs.<region>.amazonaws.com:/ ~/efs-mount-point
@j1n6
j1n6 / install_tmk_tools.sh
Created February 14, 2017 20:16
Customizing keymap for HHKB Hasu's Bluetooth TMK controller
brew tap osx-cross/avr
# take long time to compile
brew install avr-libc
brew install dfu-programmer
# turn hhkb to bootloader mode
# LShift + RShift + Fn + p
# prepare tmk keymap and download HEX `keymap.hex` file
@j1n6
j1n6 / output.sh
Created April 4, 2017 11:50
Azure error output for role creation
Command arguments ['role', 'definition', 'update', '--role-definition', '{REMOVE SENSITIVE DATA}', '--name', 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', '--scope', '/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx']
Current active cloud 'AzureCloud'
{'active_directory': 'https://login.microsoftonline.com',
'active_directory_graph_resource_id': 'https://graph.windows.net/',
'active_directory_resource_id': 'https://management.core.windows.net/',
'batch_resource_id': 'https://batch.core.windows.net/',
'gallery': 'https://gallery.azure.com/',
'management': 'https://management.core.windows.net/',
'resource_manager': 'https://management.azure.com/',
'sql_management': 'https://management.core.windows.net:8443/'}