Skip to content

Instantly share code, notes, and snippets.

View joshuaclayton's full-sized avatar

Josh Clayton joshuaclayton

View GitHub Profile
module Ahoy
def self.included(base)
base.public_instance_methods.select {|m| m.to_s =~ /ar/ }.each do |method_name|
base.class_eval("alias #{method_name.gsub("ar", "arrr")} #{method_name}")
end
end
end
module GeoKit
module Geocoders
class FakeGeocoder < Geocoder
def self.locations
@locations ||= {}
end
def self.geocode(location)
loc = GeoLoc.new
if locations.key?(location)
/Users/joshuaclayton/.rvm/ruby-1.8.6-p383/bin/ruby -I"lib:test" "/Users/joshuaclayton/.rvm/gems/ruby/1.8.6/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/aaws_test.rb" "test/unit/category_test.rb" "test/unit/helpers/item_helper_test.rb" "test/unit/item_listing_test.rb" "test/unit/item_test.rb" "test/unit/presenters/categories_presenter_test.rb" "test/unit/presenters/category_presenter_test.rb" "test/unit/presenters/items_presenter_test.rb" "test/unit/presenters/user_presenter_test.rb" "test/unit/presenters/users_presenter_test.rb" "test/unit/user_sentinel_test.rb" "test/unit/user_test.rb" -v
Loaded suite /Users/joshuaclayton/.rvm/gems/ruby/1.8.6/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
test: AAWS should have correct default settings. (AAWSTest): .
test: AAWS should use the correct URI. (AAWSTest): .
test: Amazon Authentication should occur when finding items. (AAWSTest): .
test: Amazon Authentication should occur when searching items. (AAWSTest): .
test: Amazon Authentication should properl
blueprint/screen.css
30:h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
32:h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
35:p {margin:0 0 1.5em;}
36:p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
37:p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
40:blockquote {margin:1.5em;color:#666;font-style:italic;}
46:address {margin:0 0 1.5em;font-style:italic;}
48:pre {margin:1.5em 0;white-space:pre;}
50:li ul, li ol {margin:0 1.5em;}
class ListItemPresenter
delegate :id, :class, :errors, :to_param, :new_record?, :respond_to?, :is_a?,
:to => :@list_item
def initialize(options = {})
options.assert_valid_keys(:list_item, :customer, :source)
@list_item = options[:list_item]
@customer = options[:customer]
@source = parse_source(options[:source])
end
module Admin::CustomerHelper
def customer_breadcrumbs(customer)
link_to(h(customer.name), [:edit, :admin, customer]) + " &#187; "
end
end
Factory.define(:product) do |product|
product.association :creator, :factory => :product_admin_user
product.association :product_template
product.product_variant do |p|
Factory(:product_variant, :product_template => p.product_template)
end
product.sequence(:name) {|n| "Product #{n}" }
product.sequence(:part_number) {|n| "Part Number #{n}" }
require "hmac"
require "hmac-sha2"
# reference:
# http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/index.html?BasicAuthProcess.html
# http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/index.html?Query_QueryAuth.html
module AmazonSignature
def sign_request(params)
params.reverse_merge!(:Timestamp => timestamp, :Version => "2009-07-01")
params.merge!(:Signature => build_signature(params, "GET"))
module GitCommands
class ShellError < RuntimeError; end
@logging = ENV['LOGGING'] != "false"
def self.run cmd, *expected_exitstatuses
puts "+ #{cmd}" if @logging
output = `#{cmd} 2>&1`
puts output.gsub(/^/, "- ") if @logging
expected_exitstatuses << 0 if expected_exitstatuses.empty?
# Rakefile
task :stats => "stats:stats_fix"
namespace :stats do
# Fix statistics calculation to allow file type regex be included
task :stats_fix do
require "code_statistics"
class CodeStatistics
private
def calculate_statistics