Skip to content

Instantly share code, notes, and snippets.

View jpowell's full-sized avatar

Justin Powell jpowell

View GitHub Profile
@jpowell
jpowell / email_tokenizer.rb
Created February 9, 2012 16:58
simple tokenizers for ruby
class EmailTokenizer < StringTokenizer
def initialize text
super text, /(\s|,|;)+/
end
def self.filter array=[]
result = []
array.each do |item|
result << item.downcase if item =~ /.+@.+/
end
@jpowell
jpowell / translation_utility.rb
Created January 3, 2012 21:57
I18n scoped wrapper for rails & ActiveRecord
class TranslationUtility
attr_accessor :options
def initialize scope_or_object, opts={}
@options = {
:scope => get_scope(scope_or_object),
:raise => true
}.merge(opts)
end