Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
module Rack
#
# A Rack middleware for automatically removing the format token at the end
# of a request path and adding its media type to the HTTP_ACCEPT header.
#
# MIT-License - Rein Henrichs
#
class FormatAccepts
def initialize(app)
@app = app
# Basic pool spec
# Shows global settings for the clouds
pool :party do
# instances 1..3
# set_master_ip_to '174.129.221.207'
keypair "#{ENV["HOME"]}/.poolparty/pool_dsa_key"
verbose true
# ami 'ami-7cfd1a15'
# using :vmrun
pool :involver_rails do
cloud :nginx do
instances 2..2 # binds against 2 elastic IPs
has_package "nginx"
proxy {:source_port=>80, :destination_port=>8080, :destination_cloud=>:app}
end
cloud :app do
# Example of a Rack application that takes advantage to body.each to simulate
# a real-time data feed.
#
# Anyone may use this code AT YOUR OWN RISK.
require 'rack'
require 'ebb'
#This class simulates a server waiting for events. it will yield a line with one of the HTTP Request
#headers every half second. If things work right you should see you browser window slowely fill with
cloud-start -s config/clouds.rb
Starting cloud app (/home/yann/.ec2/testpoolparty)
0 running instances (1 - 1)
/usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:261:in `ec2_error?': The key pair 'testpoolparty' does not exist (EC2::InvalidKeyPairNotFound)
from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:199:in `make_request'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:173:in `make_request'
from /usr/lib/ruby/gems/1.8/gems/grempe-amazon-ec2-0.3.8/lib/EC2.rb:224:in `response_generator'
from /usr/lib/rub
require 'rubygems'
$:.unshift "#{File.dirname(__FILE__)}/../lib"
require "poolparty"
pool :ap do
instances 1
access_key "XXXXXX"
secret_access_key "XXXXXXX"
cloud :app_stack do
#!/bin/bash
echo -n "Pick a color (blue, yellow, red ): "
read -e COLOR
echo It is a $COLOR day
@fairchild
fairchild / gist:150855
Created July 20, 2009 20:01 — forked from retr0h/gist:98308
content_type filter for sinatra
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'}
before do
request_uri = case request.env['REQUEST_URI']
when /\.css$/ : :css
when /\.js$/ : :js
else :html
end
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8'
end
require 'sinatra'
EC2_HOME = '~/.ec2'
use Rack::Auth::Basic do |username, password|
[username, password] == ['some_user', 'some_pass']
end
get "/" do
@links = %w{describe_ec2s restart_all_ec2s shutdown_all_ec2s}.map { |cmd|
export JAVA_HOME=/Library/Java/Home #/usr on ubuntu
#export EC2_HOME=~/opt/ec2
export PATH=$EC2_HOME/bin:$PATH
export EC2_CONTEXTS_DIR=~/.ec2
export EC2_CONFIG_DIR=$EC2_CONTEXTS_DIR/current
ec2-switch-context() {
unset EC2_URL
unset S3_URL
unset EC2_PRIVATE_KEY