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
# A brutal hack to allow Rails 3.2.2's asset pipeline to precompile files with | |
# only 1 extension (like foo.less, bar.sass, etc.). The problem is when you use | |
# `@import` to keep your code reasonably DRY, and rely on variables declared in | |
# an @imported file. Sprockets, rather than skipping these files and only including | |
# then when they are @imported, will still try to compile them, and fails when it | |
# hits an undefined variable. | |
module Sprockets | |
class StaticCompiler | |
def compile | |
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
diff --git a/Gemfile b/Gemfile | |
index 7764763..dec33fd 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -1,26 +1,26 @@ | |
source 'https://rubygems.org' | |
-gem 'rails', '3.2.2' | |
+# gem 'rails', '3.2.2' |
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
Geocoder ActiveRecord: | |
0.020000 0.000000 0.020000 ( 7.083117) | |
Geocoder Postgres: | |
0.010000 0.000000 0.010000 ( 0.044410) |
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
# coding: utf-8 | |
require "spanish" | |
class String | |
def rhymes_with?(string) | |
mine = Spanish.get_syllables(to_s).last.rime.map(&:to_s) | |
yours = Spanish.get_syllables(string).last.rime.map(&:to_s) | |
mine == yours | |
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
# coding: utf-8 | |
require "spanish" | |
class String | |
def rhymes_with?(string) | |
mine = Spanish.get_syllables(to_s).last.rime.map(&:to_s) | |
yours = Spanish.get_syllables(string).last.rime.map(&:to_s) | |
mine == yours | |
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
=begin | |
As far as we can tell, Active Record doesn't currently let you add an ORDER | |
at the end of all all ORDER clauses. | |
This isn't usually a problem since you can just concatenate ORDERs in the, well, | |
order you want. | |
But in the case of default scopes, for example, it's sometimes useful to force | |
an ORDER to always come last. |
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 Module | |
def self.included(base) | |
raise "FAIL" | |
end | |
def self.extended(base) | |
raise "FAIL" | |
end | |
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
# coding: utf-8 | |
# Before running this, make sure you run the downloader script to get all the | |
# HTML files from www.cnc.gov.ar. Then, download and extract AR.txt from | |
# Geonames at http://download.geonames.org/export/dump/AR.zip | |
require "utf8_utils" | |
require "unicode" | |
$pattern = /center">([\d]*)<\/d.*\n.*ss="txtTabla">(.*)<\/s.*\n.*Tabla">(.*)<\/s.*\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
#!/usr/bin/env ruby | |
=begin | |
= Geographic Searches With Postgres's Earthdistance and Cube Extensions | |
This program shows how to easily create a Postgres database that uses the Cube | |
and Earthdistance extensions to perform fast queries on geographic data. | |
Briefly, the problem this code solves is "show me all places within 50 | |
kilometers of New York City." |
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
$ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-3.1.rb bundle exec rake bench | |
------------------------------------------------------------------------ | |
Using ruby 1.9.3 AR 3.1.3 with sqlite3 (in-memory) | |
Rehearsal --------------------------------------------------------------- | |
find (without FriendlyId) 0.380000 0.000000 0.380000 ( 0.394020) | |
find (in-table slug) 0.450000 0.010000 0.460000 ( 0.473896) | |
find (external slug) 0.940000 0.000000 0.940000 ( 0.971482) | |
insert (without FriendlyId) 0.860000 0.010000 0.870000 ( 0.916956) | |
insert (in-table-slug) 2.630000 0.070000 2.700000 ( 2.769267) | |
insert (external slug) 4.600000 0.080000 4.680000 ( 4.690644) |