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
class String | |
def ngram(level, *stopwords) | |
result = [] | |
ranges = 0.upto(level-1).collect{|i|0..i} | |
data = self.gsub(/(\,|\.|\;)/,'').split.reject{|word| stopwords.flatten.include?(word)} | |
ranges.each do |range| | |
while range.max < data.size | |
result << data[range].join(' ') | |
range = range.min.succ..range.max.succ | |
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
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
# storage on lib/gasper/logger/formatter.rb | |
# Usage | |
# LOGGER = Logger.new('log/development.log', 'daily') | |
# LOGGER.formatter = Gasper::Logger::Formatter.new | |
# LOGGER.progname = 'mongodb-json-proxy' | |
# | |
module Gasper | |
module Logger | |
class Formatter | |
# YYYY:MM:DD HH:MM:SS.MS progname(pid) level: message |
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 "rubygems" | |
require "superfeedr" | |
require 'time' | |
## You can have all the XMPP logging by changing the Skates log level | |
Skates.logger.level = Log4r::DEBUG | |
## | |
# Don't ever forget that all this is ASYNCHRONOUS... |
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
# Usage: | |
# rails new YOUR_APP_NAME -m http://gist.github.com/633287.txt | |
# | |
# gems sources | |
add_source :gemcutter | |
add_source 'http://gems.github.com' | |
# gems | |
gem 'capistrano' |
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
// Place your application-specific JavaScript functions and classes here | |
// This file is automatically included by javascript_include_tag :defaults | |
jQuery.ajaxSetup({ | |
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | |
}) | |
$(document).ready(function() { | |
// All non-GET requests will add the authenticity token | |
// if not already present in the data packet | |
$(document).ajaxSend(function(event, request, settings) { |
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
# Here is where we reap the benefits of the modularity in Rails 3. | |
# What this says is that we want to use RSpec as the test framework and we want to generate fixtures | |
# with our generated specs, but we don't want to generate view specs and | |
# that instead of fixtures, we actually want to use factory girl and | |
# we want the factories to be put into spec/factories. Whew! So does this all work? | |
config.generators do |generator| | |
generator.test_framework :rspec, :fixture => true, :views => true | |
generator.fixture_replacement :factory_girl, :dir => "spec/factories" | |
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
LETRAS='áéíóúñüça-z' | |
LETRASM='ÁÉÍÓÚÑÜA-Z' | |
# Palabra Palabra|de|del | |
NOMBRES_PROPIOS_RE="(?:[#{LETRASM}][#{LETRAS}#{LETRASM}]{2,}(?:[ ,](?:[#{LETRASM}][#{LETRASM}#{LETRAS}]+|(?:(?:de|la|del)(?= [#{LETRASM}])))){1,})" | |
class Document | |
include Mongoid::Document | |
field :title, String | |
field :content, 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
PROVINCIA | MUNICIPIO | INTENDENTE | PARTIDO POLITICO | RELECTO | |
---|---|---|---|---|---|
Buenos Aires | Adolfo Alsina | Alberto GUTT | Frente para la Victoria | Si | |
Buenos Aires | Adolfo Gonzáles Chaves | José MARTINEZ | Partido Vecinal | No | |
Buenos Aires | Alberti | Leonel Omar ZACCA | Frente para la Victoria | Si | |
Buenos Aires | Almirante Brown | Ruben Dario GIUSTOZZI | Frente para la Victoria | No | |
Buenos Aires | Avellaneda | Jorge FERRARESI | Frente para la Victoria | Si | |
Buenos Aires | Ayacucho | Dario DAVID | Frente para la Victoria | Si | |
Buenos Aires | Azul | Omar Arnaldo DUCLÓS | Frente Coalición Cívica | Si | |
Buenos Aires | Bahía Blanca | Cristian BREITENSTEIN | Frente para la Victoria | Si | |
Buenos Aires | Balcarce | José Enrique ECHEVERRÍA | Frente para la Victoria | No |
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
# encoding: utf-8 | |
Encoding.default_internal = "UTF-8" | |
Encoding.default_external = "UTF-8" | |
=begin | |
REFERENCES | |
ticket: https://www.pivotaltracker.com/story/show/20034615 |
OlderNewer