Skip to content

Instantly share code, notes, and snippets.

View josevalim's full-sized avatar

José Valim josevalim

View GitHub Profile
# José Valim <jose.valim@gmail.com>
# http://josevalim.blogspot.com/
# http://www.pagestacker.com/
#
# This render_sibling paste is Rails 2.2 compatible.
# For Rails 2.1 render_sibling, please check here: http://gist.github.com/19674
module RenderSiblingHelper
# What?
#
# ab -n 1000 -c 5 localhost:3000/main/get_with_component
Requests per second: 51.04 [#/sec]
Time per request: 97.969 [ms]
# ab -n 1000 -c 5 localhost:3000/main/get_with_sibling
Requests per second: 57.35 [#/sec]
Time per request: 87.188 [ms]
# ab -n 1000 -c 5 localhost:3000/main/get_with_partial
Requests per second: 59.04 [#/sec]
# José Valim <jose.valim@gmail.com>
# http://josevalim.blogspot.com/
# http://www.pagestacker.com/
#
# This render_sibling paste is Rails 2.1 compatible.
# For Rails 2.2 render_sibling, please check here: http://gist.github.com/19631
module RenderSiblingHelper
# What?
#
diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb
index ff44849..f3a4f09 100644
--- a/actionpack/lib/action_controller/routing/route_set.rb
+++ b/actionpack/lib/action_controller/routing/route_set.rb
@@ -170,18 +170,24 @@ module ActionController
def #{selector}(*args)
#{generate_optimisation_block(route, kind)}
+ locale = #{route.segment_keys.include?(:locale) ? '{ :locale => I18n.locale || I18n.default_locale }' : '{}'}
+
<!-- DisMaxRequestHandler allows easy searching across multiple fields
for simple user-entered phrases.
see http://wiki.apache.org/solr/DisMaxRequestHandler
-->
<requestHandler name="dismax" class="solr.DisMaxRequestHandler" >
<lst name="defaults">
<str name="echoParams">explicit</str>
<float name="tie">0.01</float>
<str name="qf">
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
@josevalim
josevalim / snippet.sh
Created January 17, 2009 15:35 — forked from drnic/snippet.sh
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
def self.destroy_fixtures(table_names)
NestedScenarios.delete_tables(table_names)
end
end
module Test #:nodoc:
module Unit #:nodoc:
class TestCase #:nodoc:
superclass_delegating_accessor :scenario_path
module Remarkable # :nodoc:
module ActiveRecord # :nodoc:
module Matchers # :nodoc:
class EnsureConfirmationOfMatcher < Remarkable::Matcher::Base
include Remarkable::ActiveRecord::Helpers
def initialize(*attributes)
load_options(attributes.extract_options!)
@attributes = attributes
end
# actionpack/lib/action_controller/rescue.rb
#
module ActionController
class Base
protected
# Attempts to render a static localized error page based on the <tt>status_code</tt>
# thrown, or just return headers if no such files exists. For example, if a 500 error
# is being handled Rails will first attempt to render the file based on the current
# locale such as <tt>public/500.pt-BR.html</tt>. If it does not exist, attempts to
describe ProjectsController do
describe "responding to GET show" do
receives :find, :on => Project, :with => { :id => '37' }, :and_returns => mock_project
get :show, :id => '37'
should_assign_to(:project)
describe "mime XML" do
mime Mime::XML
#