This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -n "Pick a color (blue, yellow, red ): " | |
read -e COLOR | |
echo It is a $COLOR day |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |