Skip to content

Instantly share code, notes, and snippets.

View arjones's full-sized avatar

Gustavo Arjones arjones

View GitHub Profile
db.html.find().forEach( function(o) { print(o.url + "\t" + o.encoding + "\n" + o.tokens + "\n\n\n"); } );
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
# RAILS_ROOT/config/initializers/ordered_hash_hacks.rb
class OrderedHash
def method_missing(method_name, *args, &block)
method_name = :_id if method_name == :id
if self.keys.include?(method_name.to_s)
self.send('[]', method_name.to_s)
else
super
end
require 'mongo'
db = ::Mongo::Connection.new('genesis.mongohq.com', 27021).db('DB_DB_DB_DB_DB')
raise "Could not connect!" unless db.authenticate('USER_USER_USER_USER_USER', 'PASS_PASS_PASS_PASS_PASS')
feeds = db.collection('feeds')
comments = db.collection('comments')
query = {"options.language" => "pt"}
feeds.find(query).each do |feed|