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
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
.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
object MD5 { | |
def hash(s: String) = { | |
val m = java.security.MessageDigest.getInstance("MD5") | |
val b = s.getBytes("UTF-8") | |
m.update(b, 0, b.length) | |
new java.math.BigInteger(1, m.digest()).toString(16) | |
} | |
} |
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 the Towers of Hanoi example from the prolog tutorial [1] | |
* converted into Scala, using implicits to unfold the algorithm at | |
* compile-time. | |
* | |
* [1] http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_3.html | |
*/ | |
object TowersOfHanoi { | |
import scala.reflect.Manifest |
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
import org.apache.lucene.queryParser.QueryParser | |
import org.apache.lucene.search._ | |
import org.apache.lucene.analysis._ | |
import org.apache.lucene.analysis.en.EnglishAnalyzer | |
import org.apache.lucene.analysis.tokenattributes._ | |
import org.apache.lucene.util.Version.LUCENE_35 | |
case class TextQuery(analyzer: Analyzer) { | |
val parser = new QueryParser(LUCENE_35 , "dummyfield", analyzer) | |
def fromString(searchTerms: String) = { |
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
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences. | |
# Instructions: | |
# Go to TextMate > Preferences... | |
# Click Advanced | |
# Select Folder References | |
# Replace the following: | |
# File Pattern |
OlderNewer