Skip to content

Instantly share code, notes, and snippets.

View stanchan's full-sized avatar
🏠
Working from home

Stan Chan stanchan

🏠
Working from home
View GitHub Profile
@stanchan
stanchan / nginx_performance.txt
Created December 31, 2016 00:18
Nginx Web Socket Performance Tuning
Baseline for 40 cores 120GB memory VM
vm.swappiness = 0
fs.file-max = 12000500
fs.nr_open = 20000500
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 30
@stanchan
stanchan / sudoers
Created December 21, 2016 16:34
Vagrant Host Updater Changes
# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/local/opt/gnu-sed/libexec/gnubin/sed -i -e /*/ d /etc/hosts
%admin ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
127.0.0.1 - - [14/Dec/2016:05:03:56 +0000] GET /nginx_status HTTP/1.1 "200" 112 0.001 "-" "Ruby" "-"
<% @hosts.each do |host| %>
Host <%= host %>
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
<% end %>
@stanchan
stanchan / RT2870STA.dat.patch
Created October 2, 2016 23:58
Raspberry Pi 2/3 + OpenSprinkler and AlarmDecoder
--- mt7610u_wifi_sta_v3002_dpo_20130916.orig/conf/RT2870STA.dat 2013-09-16 10:03:08.000000000 -0400
+++ mt7610u_wifi_sta_v3002_dpo_20130916/conf/RT2870STA.dat 2016-10-02 17:47:57.553736694 -0400
@@ -4,7 +4,7 @@
CountryRegionABand=7
CountryCode=
ChannelGeography=1
-SSID=11n-AP
+SSID=
NetworkType=Infra
WirelessMode=5
script: |
def gitURL = "{scm-url}"
def getTags = ("git ls-remote -t -h $gitURL refs/tags/*").execute()
def getBranches = ("git ls-remote -t -h $gitURL feature/*").execute()
#return getBranches.text.readLines()
# .collect {{ it.split()[1].replaceAll('refs/heads/', '') }}
# .unique()
# .findAll {{ it.startsWith('<pattern>') }}
# Monkey patch the gem parse_hosts_file method
module Beaker
module Options
#A set of functions to parse hosts files
module HostsFileParser < Beaker::Options
# Read the contents of the hosts.cfg into an OptionsHash, merge the 'CONFIG' section into the OptionsHash, return OptionsHash
# @param [String] hosts_file_path The path to the hosts file
#
# @example
ruby_block "upload-pubkey" do
block do
cert_contents = File.read("/etc/chef/client.pem")
raw_data = { "server" => cert_contents, "loaded" => false }
begin
tls_keys_data_bag = Chef::DataBag.load("tls_keys")
rescue Net::HTTPServerException => e
if e.response.code == "404" then
Chef::Log.error("Creating a new tls_keys data bag")