Skip to content

Instantly share code, notes, and snippets.

View arjones's full-sized avatar

Gustavo Arjones arjones

View GitHub Profile
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|
# 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
# 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.
db.html.find().forEach( function(o) { print(o.url + "\t" + o.encoding + "\n" + o.tokens + "\n\n\n"); } );
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)
#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):
@arjones
arjones / gist:784413
Created January 18, 2011 13:15
Kestrel Producer/Consumer example in Java
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();
@arjones
arjones / .gitignore
Created July 8, 2011 19:21 — forked from karmi/.gitignore
Donut Chart from ElasticSearch Terms Facet
.DS_Store
tmp/
@arjones
arjones / .gitignore
Created July 8, 2011 21:33 — forked from karmi/.gitignore
Visualizing timelines with Protovis and date histogram facet in ElasticSearch
.DS_Store
tmp/
@arjones
arjones / gist:1123656
Created August 3, 2011 20:19
Sample collection handling
// 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._