This file contains hidden or 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
// From http://front-end-testing-talk.elabs.se/ | |
// Seen at RailsConf 2011 | |
// Typical jQuery | |
$('#whiskies li').each(function() { | |
var li = $(this); | |
var price = li.attr('data-price'); | |
var addLink = $('<a class="add-to-cart" href="#">Add to cart</a>'); | |
addLink.appendTo(li); |
This file contains hidden or 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 Parent | |
include Mongoid::Document | |
field :pants | |
field :shirts | |
embeds_many :children | |
end | |
class Child | |
include Mongoid::Document |
This file contains hidden or 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 DiagnosticReport | |
include Mongoid::Document | |
embeds_many :marker_values | |
end | |
class MarkerValue | |
include Mongoid::Document |
This file contains hidden or 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 escaped_unicode(s) | |
s.unpack("U*").map do |v| | |
if v == 10 | |
'\n' | |
elsif v < 256 | |
v.chr | |
else | |
'\u{'+v.to_s(16)+'}' | |
end | |
end.join |
This file contains hidden or 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 Game | |
include Mongoid::Document | |
field :title | |
references_and_referenced_in_many :players | |
end | |
class Player | |
include Mongoid::Document | |
field :name |
This file contains hidden or 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 Game | |
include Mongoid::Document | |
field :title | |
references_and_referenced_in_many :players | |
end | |
class Player | |
include Mongoid::Document | |
field :name |
This file contains hidden or 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 Game | |
include Mongoid::Document | |
field :title | |
referenced_in :dungeon_master, :class_name => 'User' | |
references_and_referenced_in :players, :class_name => 'User' | |
end | |
class User | |
include Mongoid::Document |
This file contains hidden or 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 Game | |
include Mongoid::Document | |
field :title | |
references_and_referenced_in_many :players | |
end | |
class Player | |
include Mongoid::Document | |
field :name |
This file contains hidden or 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
# double closures - what does it mean!? | |
def if_braintree_disabled(default): | |
def generate_decorator(f): | |
def decorator(*args, **kwargs): | |
if not settings.LIVE_SITE and not settings.BRAINTREE_ENABLED: | |
return default | |
else: | |
return f(*args, **kwargs) | |
return decorator | |
return generate_decorator |
This file contains hidden or 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
<html> | |
<head> | |
</head> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
function dump_object(obj, seed) { | |
var s = seed; | |
s += "<p>" + obj + "</p>"; |