Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠

Brian Scott bscott

🏠
View GitHub Profile
@bscott
bscott / em_queue.rb
Created June 18, 2013 06:06
Process Queue via EM
EM.run do
queue = EM::Queue.new
queue_work = Proc.new do |data|
Worker.new.call(data)
EM.next_tick { queue.pop(&queue_work) }
end
queue.pop(&queue_work)
queue.push("here's some data")
@bscott
bscott / top_largest_files
Created August 11, 2013 00:49
Top 10 Largest Files - Linux
du -a /var | sort -n -r | head -n 10
@bscott
bscott / ng_route_by_ip
Created September 6, 2013 05:45
nginx route to backend by source ip.
upstream app_test_4 {
server 10.249.67.97:10128;
server 10.254.73.6:10128;
}
if ($remote_addr = "24.43.7.27") {
proxy_pass http://app_test_4/;
@bscott
bscott / knife-commands
Created September 16, 2013 03:19
knife commands
openssl rand -base64 512 | tr -d '\r\n' > .chef/data_bag_key
knife data bag create --secret-file .chef/data_bag_key credentials rundeck
knife exec -E 'nodes.transform("fqdn:n7prppplamp*") {|n| n.run_list(["role[zend-pep]", "role[deploy_pep_ui]","role[optier-apache]", "recipe[wdpro_logstash::pep_agent]"])}’
@bscott
bscott / find_large_git.rb
Created September 16, 2013 05:31
Find large file sizes
#!/usr/bin/env ruby -w
head, treshold = ARGV
head ||= 'HEAD'
Megabyte = 1000 ** 2
treshold = (treshold || 0.1).to_f * Megabyte
big_files = {}
IO.popen("git rev-list #{head}", 'r') do |rev_list|
rev_list.each_line do |commit|
@bscott
bscott / new_gist_file.js
Created October 3, 2013 04:12
Check environment variables before node.js app starts
var sanity = require('sanity');
sanity.check(['USER', 'MACHTYPE', 'INVISIBLE_FRIENDS', 'AREA_51']);
@bscott
bscott / batman_node.java
Created October 3, 2013 04:37
Batman.JS and NodeJS
Batman = require('./lib/dist/batman.node.js');
var someObject = new Batman.Object();
@bscott
bscott / rewite_git_author.sh
Created October 3, 2013 23:01
Rewrite Author
git filter-branch --env-filter 'if [ $GIT_COMMITTER_EMAIL = Brian.L.Scott@Disney.com ]; then GIT_COMMITTER_EMAIL=brainscott@gmail.com; fi; export GIT_COMMITTER_EMAIL' -f
git filter-branch --env-filter 'if [ $GIT_AUTHOR_EMAIL = Brian.L.Scott@Disney.com ]; then GIT_AUTHOR_EMAIL=brainscott@gmail.com; fi; export GIT_AUTHOR_EMAIL'
@bscott
bscott / num_gen.js
Created October 16, 2013 22:54
Generate 6 digit number
var min = 10000;
var max = 99999;
var num = Math.floor(Math.random() * (max - min + 1)) + min;