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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
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
def setup | |
@compiled_templates = ActionView::Base::CompiledTemplates | |
# first, if we are running the whole test suite with ReloadableTemplates | |
# try to undef all the methods through ReloadableTemplate's interfaces | |
unless ActionView::Base.cache_template_loading? | |
ActionController::Base.view_paths.each do |view_path| | |
view_path.paths.values.uniq!.each do |reloadable_template| | |
reloadable_template.undef_my_compiled_methods! | |
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
From d599036f67b36203b1e98ece6b4635a1dd588204 Mon Sep 17 00:00:00 2001 | |
From: thedarkone <nobody> | |
Date: Thu, 12 Feb 2009 19:35:14 +0100 | |
Subject: [PATCH] Port fast reloadable templates from rails-dev-boost. | |
--- | |
actionmailer/test/abstract_unit.rb | 1 + | |
actionmailer/test/mail_service_test.rb | 2 +- | |
actionpack/lib/action_controller/rescue.rb | 2 +- | |
actionpack/lib/action_view.rb | 1 + |
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
$:.unshift "lib" | |
require 'i18n' | |
require "benchmark" | |
def with_fast?; defined?(I18n::Backend::Fast); end | |
str = 'abc {{a}}, {{b}}' | |
f = I18n::Backend::Fast.new if with_fast? |
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
module ChainSetup | |
def setup | |
super | |
first = I18n::Backend::Simple.new | |
# first.store_translations(:en, translations) | |
I18n.backend = I18n::Backend::Chain.new(first, I18n.backend) | |
end | |
def test_using_chain_backend | |
assert_equal I18n::Backend::Chain, I18n.backend.class |
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 -KU | |
$:.unshift(File.join(File.dirname(__FILE__), "../lib")).unshift('lib') | |
require 'i18n' | |
require 'benchmark' | |
f = I18n::Backend::Fast.new | |
I18n.backend = f | |
interpolation = 'abc {{a}}, {{b}}' |
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 -wKU | |
puts RUBY_DESCRIPTION | |
$:.unshift File.expand_path("../lib", File.dirname(__FILE__)) | |
require 'i18n' | |
require 'benchmark' | |
require 'yaml' | |
str = "This is a custom blank message for {{model}}: {{attribute}}" |
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
h = {} | |
v = 1 | |
threads = Array.new(my_cpu_count = 4) do | |
Thread.new do | |
2_000_000.times {|i| h[i] = v} | |
end | |
end | |
threads.map(&:join) |
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
## Original | |
def reverse_sql_order(order_query) | |
order_query.join(', ').split(',').collect { |s| | |
if s.match(/\s(asc|ASC)$/) | |
s.gsub(/\s(asc|ASC)$/, ' DESC') | |
elsif s.match(/\s(desc|DESC)$/) | |
s.gsub(/\s(desc|DESC)$/, ' ASC') | |
else | |
s + ' DESC' | |
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
module Trigo | |
[:sin, :cos, :tan].each do |trigo_fun| | |
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ | |
def #{trigo_fun}(angle) | |
_trigo(:#{trigo_fun}, angle) | |
end | |
RUBY_EVAL | |
end | |
private |
OlderNewer