Skip to content

Instantly share code, notes, and snippets.

View joshuaclayton's full-sized avatar

Josh Clayton joshuaclayton

View GitHub Profile
var polygonIncludes = function(points) {
return function() {
var point = [this.grid_lat, this.grid_lng];
var sides = points.length;
var map = function( elems, callback, arg ) {
var ret = [], value;
// Go through the array, translating each of the items to their
// new value (or values).
for ( var i = 0, length = elems.length; i < length; i++ ) {
class Polygon
attr_reader :points
attr_reader :sides
def initialize(points)
@points = points
calculate_sides
end
def points=(points)
When /^all pending Resque jobs are processed$/ do
# run jobs
end
(function() {
function objectToSpecIt(expectation, args) {
var args = $.makeArray(args),
matcherAndArgs = [args.shift()];
$.each(args, function(i, item) { matcherAndArgs.push(item); });
return SpecIt.expectations(this)[expectation].apply(this, matcherAndArgs);
}
function nativeShould() { return objectToSpecIt.call(this, "should", arguments); }
function nativeShouldNot() { return objectToSpecIt.call(this, "shouldNot", arguments); }
--type-add=ruby=.haml,.rake,.rsel,.builder
--type-add=html=.html.erb,.html.haml
--type-add=js=.js.erb
--type-add=css=.sass,.less
--type-set=cucumber=.feature
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc
--ignore-dir=coverage
---
:backtrace: false
gem: --no-ri --no-rdoc
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:update_sources: true
:verbose: true
Then /^I should see the following rows:$/ do |table|
assert_select "table" do
table.raw.each do |row|
assert_select "tr" do
row.each do |column|
assert_select "td", :text => column.to_s
end
end
end
end
def time_distance(seconds = 0)
days, hours, minutes = 0,0,0
in_days = seconds / (60*60*24)
days = in_days.floor
hours = ((in_days % days) * 24).floor
minutes = ((((in_days % days) * 24) % hours) * 60).floor
"#{days}d #{hours}h #{minutes}m"
end
# new IRB session, memcached 1.4.1 - looks like it marshalled the data incorrectly?
>> gem "memcache-client", "1.7.4"
=> true
>> require 'memcache'
=> true
>> mc = MemCache.new("localhost:11211")
=> <MemCache: 1 servers, ns: nil, ro: false>
>>
?> text = %(
get: ["Throttle:exp:"]
class Person
def self.region(str, &blk)
self.class_eval(&blk)
end
end
class Joe < Person
def name; "Joe"; end
region "speaking" do