Skip to content

Instantly share code, notes, and snippets.

class Hash
def selekt
inject({}) {|hsh,(k,v)|
hsh[k] = v if yield(k,v)
hsh
}
end
end
@jasoncodes
jasoncodes / config.ru
Created May 18, 2010 11:29 — forked from toolmantim/config.ru
Serving simple static sites using Rack
# Rackup file for serving up a static site from a "public" directory
#
# Useful for chucking a static site on Heroku
class IndexRewriter
def initialize(app) @app = app end
def call(env)
env["PATH_INFO"].gsub! /\/$/, '/index.html'
@app.call(env)
end
#!/usr/bin/env ruby
# A couple of Searchlogic searches. Both are identical from a code
# perspective. With one, the user supplies a '.' (period) as part of the
# search query. This search blows up because it's generating an invalid SQL
# statement. I say it shouldn't. The error in question is:
#
# Mysql::Error: Not unique table/alias: 'users':
#
# SELECT `companies`.`id` AS t0_r0,