Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
class Pop
def initialize(h={}, &block)
default_options(h)
puts "indide #{self.class} #{doop.inspect}"
instance_eval &block if block
end
def self.default_options
@@default_options
end
class Pop
def initialize(h={}, &block)
options(h)
puts "indide #{self.class} #{options.inspect}"
instance_eval &block if block
end
def self.default_options(h={})
@default_options ||= h
end
# It would be nice to have a simple way to describe metrics I want to monitor on my server.
# Perhaps a dsl would help out here
# ---
# Lets think about the API first.
# How would you express your intent in english?
# Perhaps:
# Get the load and send an email when it is greater than 1.
# ---
# Basic pool spec
# Shows global settings for the clouds
pool :application do
instances 1..3
keypair "#{ENV["HOME"]}/.ec2oncourse/r_and_d.pem"
verbose true
ami 'ami-7cfd1a15'
# testing false
cloud :pp1 do
@fairchild
fairchild / gist:86790
Created March 27, 2009 17:27
simple provisioning script
require 'rubygems'
require 'open4'
require 'ec2'
class Ec2
aws_keys = {}
aws_keys = YAML::load( File.open('/etc/poolparty/aws_keys.yml') ) rescue 'No aws_keys.yml file. Will try to use enviornment variables'
ACCESS_KEY_ID = aws_keys[:access_key] || ENV['AMAZON_ACCESS_KEY_ID'] || ENV['AWS_ACCESS_KEY']
SECRET_ACCESS_KEY = aws_keys[:secret_access_key] || ENV['AMAZON_SECRET_ACCESS_KEY'] || ENV['AWS_SECRET_ACCESS_KEY']
@fairchild
fairchild / gist:87070
Created March 28, 2009 08:52
an alternative method to share command sets. Not complete
require 'rubygems'
require 'ec2'
module BootStrapper
class Ec2
aws_keys = {}
aws_keys = YAML::load( File.open('/etc/poolparty/aws_keys.yml') ) rescue 'No aws_keys.yml file. Will try to use enviornment variables'
ACCESS_KEY_ID = aws_keys[:access_key] || ENV['AMAZON_ACCESS_KEY_ID'] || ENV['AWS_ACCESS_KEY']
SECRET_ACCESS_KEY = aws_keys[:secret_access_key] || ENV['AMAZON_SECRET_ACCESS_KEY'] || ENV['AWS_SECRET_ACCESS_KEY']
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
GRAY="\[\033[1;30m\]"
LIGHT_GRAY="\[\033[0;37m\]"
WHITE="\[\033[1;37m\]"
LIGHT_BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
@fairchild
fairchild / snippet.rb
Created March 31, 2009 19:19
.autotest
# ~.autotest
require 'autotest/redgreen'
# require 'autotest/timestamp'
# require 'autotest/growl'
# require 'autotest/html_report'
def summary_to_hash(summary_string)
res = Hash.new
@fairchild
fairchild / array_select_with_hash.rb
Created April 1, 2009 02:38
select elements from an array, using the hash for conditions
@remote_instances_list =[
{:status=>'running', :ip=>'10'},
{:status => 'pending', :ip=>'not.assigned'},
{:status=>'running', :ip=>'192', :bogus=>nil}
]
class Array
# Example nodes.select_with_hash(:status=>'running')
def select_with_hash(conditions={})
select do |node|
# Just some rough ideas on how request URLs might be mapped to class::module.method
class Server
module Get
def load(req, resp)
path_vars "/:duration/:units/:averaged" #this could parse local vars out of req.path
resp.body = Server.uptime
resp
end
end