This file contains 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
function allTests(thisFnWrapsAllYourTests) { | |
var successes = 0; | |
var failures = []; | |
var scopes = []; | |
var msgInScope = function(msg) { | |
return scopes.concat([msg]).join(": "); | |
} | |
var doTheseListsMatch = function(expected, actual) { |
This file contains 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
def has_cycle?(items) # hash: { id => parent_id, id => nil } | |
return false if items.size < 2 | |
items = items.dup | |
items.keys.each do |starting_point| | |
visited_items = [] | |
item = starting_point | |
while item.present? | |
return true if visited_items.include?(item) |
This file contains 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
interface UGen<T> { | |
T val(); | |
} | |
interface Movie { | |
void update(); | |
void draw(PGraphics g); | |
} | |
class MovieBag implements Movie { |
This file contains 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 HasFakeBooleanColumns | |
def self.wallpaper_over_fake(column_name) | |
define_method(column_name) do | |
self.attributes(column_name) == 'true' | |
end | |
define_method("#{column_name)=".to_sym) do |value| | |
self.update_attribute(column_name, value == 'true') | |
end | |
end |
This file contains 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
var getRatingText = (function() { | |
var ratingText = { | |
singular: { | |
"Closed": L("1_person_voted_to_get_this_issue_fixed", "1 person voted to get this issue fixed"), | |
"Archived": L("1_person_voted_to_get_this_issue_fixed", "1 person voted to get this issue fixed"), | |
default: L("1_person_wants_this_fixed", "1 person wants this fixed") | |
}, | |
plural: { | |
"Closed": L("people_voted_to_get_this_issue_fixed", "%s people voted to get this issue fixed"), |
This file contains 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
# Turn a PEG on its head! Generate some compliments. | |
class Complimenter | |
def compliments | |
phrases | |
end | |
def phrases | |
phrase + ". " + maybe { phrases } | |
end |
This file contains 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
def missing(message) | |
if message.is_a? Symbol | |
puts "The environment is missing #{message.to_s.upcase}" | |
else | |
puts message | |
end | |
end | |
desc "Check the environment for proper setup" | |
task :checkenv do |
This file contains 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
class HasDependents | |
def initialize(dependent_class=Kid) | |
@dependent = dependent_class.new | |
@dependent.parent = self | |
end | |
end | |
class Kid | |
attr_writer :parent | |
end |
This file contains 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
(function(undefined) { | |
// In here, undefined is back to normal, | |
// because we passed the function no params! | |
})(); |
This file contains 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
=begin | |
It's easy to mistakenly say: | |
describe 'my feature', type: 'feature' do | |
... | |
end | |
...when you really mean: | |
describe 'my feature', type: :feature do |
NewerOlder