Skip to content

Instantly share code, notes, and snippets.

View tdantas's full-sized avatar
🏠
Working from home

Thiago Dantas tdantas

🏠
Working from home
View GitHub Profile
@tdantas
tdantas / app.rb
Created June 28, 2012 22:09 — forked from cpatni/app.rb
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@tdantas
tdantas / gist:1588474
Created January 10, 2012 10:58 — forked from dshaw/gist:378192
(function(window,document,undefined){ ... })(this,this.document);
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
@tdantas
tdantas / mongo.rb
Created November 8, 2011 22:53 — forked from rodriguezartav/mongo.rb
config/initializers/mongo.rb it setups mongomapper to be used locally and in heroku with MongoHQ
MongoMapper.config = {
Rails.env => { 'uri' => ENV['MONGOHQ_URL'] ||
"mongodb://localhost/rubyconf_simple_app-#{Rails.env}-1" } }
MongoMapper.connect(Rails.env)
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect if forked
end