Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile
CREATE TABLE dbo.changelog (
change_number INTEGER NOT NULL,
delta_set VARCHAR(10) NOT NULL,
start_dt DATETIME NOT NULL,
complete_dt DATETIME NULL,
applied_by VARCHAR(100) NOT NULL,
description VARCHAR(500) NOT NULL
)
GO
let rec valueFor (property:AType) : obj =
match property.Type with
| AString -> box property.Name
| AnInt -> box 0
| ADouble -> box 0.0
| ABoolean -> box false
| ADateTime -> box DateTime.MinValue
| AClass -> box <| build property.Type
| _ -> box <| new obj()
and build =
LoadError: no such file to load -- lib/github_badges.rb
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:114:in `require'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:114:in `inner_app'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:31:in `call!'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/loader.rb:18:in `call'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/favicon.rb:12:in `call'
/Users/mneedham/.rvm/gems/ruby-1.9.2-head/gems/shotgun-0.8/lib/shotgun/static.rb:14:in `call'
CodeSign error: code signing is required for product type 'Application' in SDK 'Device - iPhone OS 3.2'
Trying to create a little proxy around a class:
class Bar
def self.foo
"mark"
end
end
It works by opening the class:
Say we have a function like this:
def is_awesome(number)
number == 7
end
Which we want to apply across a collection like so:
[1,2,3,4,5].find_all { |number| is_awesome(number) }
if !defined?(Rails::Railtie)
Rails.configuration.after_initialize do
class ::ActionController::Base
include RailsWarden::Mixins::HelperMethods
include RailsWarden::Mixins::ControllerOnlyMethods
end
module ::ApplicationHelper
include RailsWarden::Mixins::HelperMethods
end
Test::Unit::AssertionFailedError in 'HomeController routing should map '/''
The recognized options <{"action"=>"index", "controller"=>"home"}> did not match <{"action"=>:index, "controller"=>:home}>, difference: <{"action"=>:index, "controller"=>:home}>
If you're expecting this failure, we suggest { :get => "/" }.should_not be_routable
def mean(values)
values.inject(&:+) / values.size
end
def sample_variance(values, mean)
values.map { |item| (item - mean) ** 2 }.inject(& :+) / (values.size - 1)
end
values = [437, 93, 933, 197, 163, 278, 258, 318, 181, 0, 253, 133, 1046, 0, 188, 0, 0, 62, 195, 388, 185, 104, 217, 0, 0, 270, 261, 298, 413, 226, 121, 142, 651, 160, 184, 129, 174, 126, 342, 174, 0, 0, 216, 253, 0, 265, 250, 0, 337, 0, 314, 133, 832, 176, 0, 289, 374, 169, 0, 0, 0, 95, 107, 0, 560, 351, 292, 0, 252, 0, 177, 193, 823, 204, 398, 0, 144, 104, 225, 162, 276, 0, 129, 521, 130, 0, 205, 322, 145, 87, 79, 0, 279, 493, 184, 195, 472, 224, 124, 0, 250, 0, 247, 0, 87, 203, 273, 249, 447, 158, 285, 187, 727, 798, 179, 341, 119, 474, 152, 283, 90, 0, 633, 202, 272, 308, 255, 522, 421, 91, 246, 211, 607, 0, 833, 131, 0, 317, 170, 0, 464, 141, 220, 198, 395, 173, 104, 67, 0, 242, 0, 108, 63, 147, 113, 106, 0, 241, 178, 0, 140, 162, 95, 121, 163, 205, 0, 85, 0, 378, 250, 176, 0, 0, 167, 0, 261, 61, 306, 144, 191, 89, 132, 35
# This is how it looks
def calc_price(foo)
price = nil
["list1", "list2"].each do |list|
price_lists = lookup_price_lists # more logic but irrelevant for example
price = get_price_for(price_lists, foo)
return adjust_price(foo, price) unless price.nil?
end
price