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 '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| |
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
# 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 |
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
# 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. |
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
db.html.find().forEach( function(o) { print(o.url + "\t" + o.encoding + "\n" + o.tokens + "\n\n\n"); } ); |
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 'benchmark' | |
require 'logger' | |
class Module | |
def alias_method_chain( target, feature ) | |
alias_method "#{target}_without_#{feature}", target | |
alias_method target, "#{target}_with_#{feature}" | |
end | |
end unless Module.public_method_defined?(:alias_method_chain) |
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
#Author: Marcel Pinheiro Caraciolo | |
#Confusion Matrix Generator | |
#Version: 0.1 | |
#email: caraciol at gmail . com | |
from pprint import pprint as _pretty_print | |
import math | |
class ConfusionMatrix(object): |
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
package net.arjones.sandbox; | |
import net.lag.configgy.Config; | |
import net.lag.kestrel.PersistentQueue; | |
public class KestrelTest { | |
public static void main(String[] args) throws InterruptedException { | |
Config config = new Config(); |
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
.DS_Store | |
tmp/ |
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
.DS_Store | |
tmp/ |
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
// This is a sample of handling collections with Scala | |
// It receives the .xml from your delicious account and generates an output to plot | |
// the count of tags on a timeframe | |
// | |
// Please, if you know better ways to do the same processing, please let me know: @arjones | |
// | |
import scala.xml._ | |
import org.joda.time._ |
OlderNewer