- Open Source Cloud – compute nodes and object storage
- openstack-cookbooks – stable ([email protected]/opscode.org)
- dellcloudedge – bare metal openstack installer
- voxeldotnet – cookbooks for launching swift in production with spiceweasel
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
test "getters/setters for shipping methods should work" do | |
listing = Factory.create(:listing) | |
assert !listing.shipping_methods.include?('CATBUS') | |
assert !listing.ship_via_catbus | |
listing.ship_via_catbus = true | |
assert listing.ship_via_catbus | |
assert listing.shipping_methods.include?('CATBUS') | |
listing.ship_via_catbus = false | |
assert !listing.ship_via_catbus | |
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
# This and the next method are unfortunately 'magic' | |
# They set default paramaters for these two find_or_create_by_ method_missing methods | |
def self.find_or_create_by_email(params) | |
params = { email: params } unless params.is_a?(Hash) | |
super(params.reverse_merge( | |
password: Digest::MD5.hexdigest("#{rand(1024)}Time.now"), | |
username: Digest::MD5.hexdigest("#{rand(1024)}Time.now") | |
)) | |
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
require 'fog' | |
desc "Tell us how much space is in use on S3" | |
namespace :s3 do | |
task usage: :environment do | |
size = 0 | |
connection = Fog::Storage.new( | |
provider: 'AWS', | |
aws_access_key_id: ENV['aws_access_key_id'], |
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
# Unfortunately the Rails 2 version of DJ doesn't support before/after hooks. This hacks those in | |
# Stick this in an initalizer, and then any before(job) and after(job) methods in your Job classes will get called | |
module Delayed | |
module Backend | |
module ActiveRecord | |
class Job < ::ActiveRecord::Base | |
def invoke_job | |
payload_object.before(self) if payload_object.respond_to?('before') | |
payload_object.perform |
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
ruby-1.9.2-p0 adella:benchmarks$ ruby -v | |
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0] | |
ruby-1.9.2-p0 adella:benchmarks$ php -v | |
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55) | |
Copyright (c) 1997-2010 The PHP Group | |
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies | |
ruby-1.9.2-p0 adella:benchmarks$ cat foo.rb | |
msg = "Hello world" |
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
module Ancestry | |
# https://github.com/stefankroes/ancestry | |
module InstanceMethods | |
# Clone an object and all children | |
# => replacing values with those from attributes if present | |
# => setting parent to new parent if present | |
# => setting the "original_id_field_name" if present to the id of the original object | |
# | |
# Example use_case: |
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
// Form dirtyness tracking | |
$('form *').change( function() { | |
window.formDirty = true; | |
}); | |
$('form input').click( function() { | |
if (this.name == "commit") { | |
window.formDirty = false; | |
} | |
}); | |
window.onbeforeunload = function() { |
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
# Addon for classes using https://github.com/stefankroes/ancestry | |
# Create the full tree for this root/parent/child if it doesnt yet exist | |
# .save! is required to generate ancestry fields so that .children works | |
def self.find_or_create_tree_by_name(root_name = nil, parent_name = nil, child_name = nil) | |
if root_name.present? | |
root = self.find_or_create_by_name(root_name) | |
root.save! | |
if parent_name.present? | |
parent = root.children.find_or_create_by_name(parent_name) | |
parent.save! |
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
module DeviseHelper | |
def devise_error_messages! | |
unless resource.errors.empty? | |
content_tag :div, :id => "error_explanation", :escape => false do | |
content_tag(:h2, "The following errors were encountered:") + | |
content_tag(:ul, resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join.html_safe) | |
end.html_safe | |
end | |
end | |
end |