Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠

Brian Scott bscott

🏠
View GitHub Profile
@bscott
bscott / ridley.rb
Created November 19, 2013 20:58
Ridley
ridley.data_bag.find("listsvc").find("DEV"){ |dbi| dbi["0"]["deploy"] = true; dbi.save }
data_bag = ridley.data_bag.find("listsvc")
data_bag_item = data_bag.item.find("DEV")
data_bag_item["0"]["deploy"] = true
data_bag_item.save
@bscott
bscott / chef.js
Created November 4, 2013 16:53
http://localhost:8081/chef?type=json
app.get('/chef', function(req, res) {
var conf = appUtil.parseConfig();
appUtil.getChefNodes(function(result) {
if (req.query.type && (req.query.type == 'xml')) {
res.set('Content-Type', 'text/xml');
res.render('xml.ejs', {baseUrl: 'http://localhost:8080', user: conf['chef']['node_name'], org: conf['chef']['organization'], nodeItems:result});
} else if (req.query.type == 'json') {
res.set('Content-Type', 'application/json');
res.json('nodeItems:result');
} else {
@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;
@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 / 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 / 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 / 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 / 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 / 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/;