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 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 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 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 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 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 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 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>"; |
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
require 'rubygems' | |
require 'v8' | |
cxt = V8::Context.new | |
# context switch test | |
start = Time.now | |
1000.times { cxt.eval('true') } |
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
require 'rubygems' | |
require 'json' | |
require 'v8' | |
input = 'suggestions.txt' | |
suggestions = [] | |
p "Loading suggestions..." | |
File.open(input, 'r').each { |line| suggestions << line.strip } |
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
require 'rubygems' | |
require 'sinatra' | |
require 'json' | |
require 'v8' | |
input = 'suggestions.txt' | |
suggestions = [] | |
File.open(input, 'r').each { |line| suggestions << line.strip } |