Skip to content

Instantly share code, notes, and snippets.

View scottsbaldwin's full-sized avatar

Scott Baldwin scottsbaldwin

View GitHub Profile
@scottsbaldwin
scottsbaldwin / gist:1512378
Created December 22, 2011 23:51
Reset file permissions from template resource
# permissions BEFORE configuring template resource
# C:\inetpub\myapp>icacls Web.config
# Web.Debug.config NT SERVICE\TrustedInstaller:(I)(F)
# NT AUTHORITY\SYSTEM:(I)(F)
# BUILTIN\Administrators:(I)(F)
# BUILTIN\Users:(I)(RX)
template 'C:\inetpub\myapp\Web.config' do
source "Web.config.erb"
end
@scottsbaldwin
scottsbaldwin / gist:1636069
Created January 18, 2012 21:59
Deploy script for a war on tomcat 6
#!/bin/bash
if [ "$1" == "" ]
then
echo "Usage: $0 [dir]"
exit 1
fi
if [ ! -e "$1/MYWAR.war" ]
then
@scottsbaldwin
scottsbaldwin / gist:1678957
Created January 25, 2012 21:39
gource on your svn repo
#!/bin/sh
# Refer to:
# http://code.google.com/p/gource/wiki/Videos
# http://code.google.com/p/gource/wiki/SVN
# http://code.google.com/p/gource/wiki/MacSupport
# http://code.google.com/p/gource/wiki/Controls
REVISION=108603
TITLE="Our chef-repo"
@scottsbaldwin
scottsbaldwin / gist:1711374
Created January 31, 2012 16:13
Vagrantfile
Vagrant::Config.run do |config|
config.vm.define :lb do | lb_config|
lb_config.vm.box = "lb"
#lb_config.vm.forward_port "http", 80, 8080
lb_config.vm.forward_port "haproxy", 22002, 22002
lb_config.vm.network "192.168.2.11"
lb_config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
chef.validation_key_path = "ORGNAME-validator.pem"
@scottsbaldwin
scottsbaldwin / gist:1711378
Created January 31, 2012 16:14
mac os x postgresql
$ brew install postgresql
...
# Create/Upgrade a Database
If this is your first install, create a database with:
initdb /usr/local/var/postgres
To migrate existing data from a previous major version (pre-9.1) of PostgreSQL, see:
http://www.postgresql.org/docs/9.1/static/upgrading.html
@scottsbaldwin
scottsbaldwin / gist:1713960
Created January 31, 2012 23:51
rails mysql setup
$ gem install mysql2
Set this before running rake db:migrate
$ export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
config/database.yaml:
development:
adapter: mysql2
@scottsbaldwin
scottsbaldwin / adsearch
Created February 1, 2012 21:37
active directory search
#!/bin/sh
if [ "$1" == "" ]
then
echo "USAGE: $0 [search_term]"
exit
fi
HOST=foo.bar
ADMIN_USERNAME=DOMAIN\user
@scottsbaldwin
scottsbaldwin / pipelinecause.rb
Created February 3, 2012 17:33
Get build cause for Go pipeline (including material changes)
require 'rexml/document'
require 'open-uri'
include REXML
user = "YOUR_USER_NAME"
password = "YOUR_PASSWORD"
pipeline_name = "YOUR_PIPELINE_NAME"
def get_xml_from_url(url, auth=[])
remote_file = open(url, :http_basic_authentication => auth)
@scottsbaldwin
scottsbaldwin / linearregression.rb
Created February 3, 2012 23:14
Ruby Linear Regression Calculator
# Adapted from a C# example here:
# http://stackoverflow.com/questions/43224/how-do-i-calculate-a-trendline-for-a-graph
# And thanks to John Esser for helping figure out how to
# calculate the targets to stabilize a negative slope!
class LinearRegression
attr_accessor :slope, :intercept
# Pass in an array of values to get the regression on
@scottsbaldwin
scottsbaldwin / pipelinecause-simple.rb
Created February 6, 2012 16:36
Go Pipeline Cause - Simplified (no materials check)
# Based on feedback from the Go development team:
# url = "#{ENV['GO_SERVER_URL']}pipelines/#{ENV['GO_PIPELINE_NAME']}/#{ENV['GO_PIPELINE_COUNTER']}/#{ENV['GO_STAGE_NAME']}/#{ENV['GO_STAGE_COUNTER']}.xml"
# and lookup //approvedBy/text()
require 'rexml/document'
require 'net/http'
require 'time'
include REXML