This file contains hidden or 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 poolparty template | |
| require "poolparty_apache2_plugin" | |
| pool :opensource do | |
| instances 1..1 | |
| port 80 | |
| ami "ami-1cd73375" #Alestic's old base Ubuntu AMI | |
| #ami "ami-7cfd1a15" #Alestic's Ubuntu 8.10 Intrepid base AMI | |
| base_keypair_path ENV["EC2_CONFIG_DIR"] | |
| keypair "poolparty_oncourse_atti" |
This file contains hidden or 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
| # incomplete skeleton distributed hash table making use of DistributedKeyBasedRouter class | |
| class DHT | |
| BASE_DIR='./' | |
| def self.put(value, key=sha1(value) ) | |
| msg = {:action=>'store', :value=>value}.to_yaml | |
| DistributeKeyBasedRouter.new.route(key, msg ) | |
| end | |
| def self.get(key) |
This file contains hidden or 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
| # sample skeleton for a ruby API based on the ideas from http://www.oceanstore.org/publications/papers/pdf/iptps03-api.pdf | |
| class DistributeKeyBasedRouter | |
| def initialize(deliver_to_class, deliver_class_method = :delivered) | |
| @delivery_callback_class = deliver_to_class | |
| @delivery_callback_method = deliver_class_method | |
| end | |
This file contains hidden or 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
| class String | |
| def to_underscored | |
| self.gsub(/::/, '_') #:: has special meaning in graphviz, so we replace it | |
| end | |
| def evaled | |
| eval self | |
| end | |
| end | |
| class ObjectGrapher |
This file contains hidden or 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
| #simple script to check the ping times of various DNS servers | |
| results = Hash.new | |
| dns_servers = %w(4.2.2.1 | |
| 4.2.2.2 | |
| 4.2.2.3 | |
| 4.2.2.4 | |
| 4.2.2.5 | |
| 4.2.2.6 | |
| 68.94.156.1 |
This file contains hidden or 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 poolparty template | |
| pool :clouds do | |
| base_keypair_path ENV["EC2_CONFIG_DIR"] | |
| keypair "poolparty_oncourse_atti" | |
| instances 1..2 | |
| port 80 | |
| # Alestic's base ubuntu AMI | |
| ami "ami-1cd73375" | |
This file contains hidden or 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
| class Box | |
| def options(h={}) | |
| @options ||= self.class.options.merge(h) | |
| end | |
| def self.options(h={}) | |
| @class_options ||= h | |
| end | |
This file contains hidden or 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
| @defaults={ | |
| :access_key => Base.access_key, | |
| :secret_access_key => Base.secret_access_key | |
| } | |
| define_defaults(@defaults) | |
| def self.defaults | |
| @defaults | |
| end |
This file contains hidden or 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
| try it using instance variables | |
| def define_defaults(ops={}) | |
| ops.each do |k, v| | |
| next if k.to_s == 'options' | |
| class_defaults[k.to_sym] = v | |
| instance_variable_set "@#{k}", v | |
| methods_to_define = { | |
| :class_getter => "class << self; def #{k}; class_defaults[:#{k}]; end; end", | |
| # :instance_get_and_set => "def #{k}(i=nil); i ? @__#{k} = i : __options[:#{k}]; end", | |
| :attr_accessor => "attr_accessor :#{k}", |
This file contains hidden or 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
| #TODO: rdoc: this defines methods on poolparty objects from a passed hash of options. | |
| # For example, this is how instance.minimum_runtime is set. See base.rb line 12 for example of default options that are added as methods in this way. | |
| module PoolParty | |
| module Configurable | |
| module ClassMethods | |
| # Provides a class options hash to hold the values that will be set by define_defaults | |
| def class_defaults(h={}) | |
| @defaults ||= h | |
| end |