I hereby claim:
- I am seako on github.
- I am seako (https://keybase.io/seako) on keybase.
- I have a public key ASAhRer4e4zz5ykwt06S9Huk2MyWE0QMRWWghwMOevxaLQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
require 'benchmark' | |
class LocalLambda | |
def local_lambda | |
a_lambda = -> { 1 } | |
a_lambda.call | |
1 | |
end | |
def nested_definition |
tweaking the colors of mbostock's Color Flood III
Prim’s algorithm is used to flood a 960×500 canvas with color.
Compare to Wilson’s algorithm and randomized breadth-first traversal.
RSpec::Matchers.define :be_an_ordering_of do |all_records, condition| | |
match do |ordered_records| | |
should_be_an_ordering(all_records, ordered_records, &condition) | |
end | |
end | |
def should_be_an_ordering(all_records, ordered_records, &condition) | |
flunk "There are no records" if all_records.empty? | |
flunk "Your ordered records are the same as the default ordering" if all_records == ordered_records |
def should_be_a_subset(superset, records_selected_by_scope, &condition) | |
flunk "Your superset is empty" if superset.empty? | |
flunk "Your scope did not select any records" if records_selected_by_scope.empty? | |
records_selected_by_block, records_excluded_by_block = superset.partition(&condition) | |
flunk "Your test condition did not select any records" if records_selected_by_block.empty? | |
flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty? | |
records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id) | |
end |