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
when you read: | |
with [:foo, :bar], :baz | |
does that mean: | |
with(:foo AND :baz) OR with(:bar AND :baz) | |
or does it mean: | |
with(:foo AND :bar) OR with(:baz) | |
i.e. would the nested args array indicate a logical OR or a logical AND? |
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 http://weblog.jamisbuck.org/2006/3/9/integration-testing-in-rails-1-1 | |
require "#{File.dirname(__FILE__)}/../test_helper" | |
class StoriesTest < ActionController::IntegrationTest | |
fixtures :accounts, :ledgers, :registers, :people | |
def test_signup_new_person | |
new_session do |bob| | |
bob.goes_to_login |
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
ActionController::Routing::Routes.draw do |map| | |
map.from_plugins | |
map.filter 'force_html' | |
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
Rails::Initializer.class_eval do | |
def load_application_initializers_with_plugin_initializers | |
if gems_dependencies_loaded | |
plugin_loader.load_plugin_initializers | |
end | |
load_application_initializers_without_plugin_initializers | |
end | |
alias_method_chain :load_application_initializers, :plugin_initializers | |
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
function __git_dirty { | |
local dirty RED NO_COLOR | |
RED="\033[0;31m" | |
NO_COLOR="\e[0m" | |
dirty=$(git diff-index --cached --quiet HEAD 2>/dev/null || echo "⚡") | |
if [ ! -z "$dirty" ]; then | |
echo "${RED}${dirty}${NO_COLOR}"; | |
return; | |
fi | |
dirty=$(git diff-index --quiet HEAD 2>/dev/null || echo "⚡") |
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
git clone [repo url] # checkout the codebase | |
git pull # to update your local copy, do that once in a while | |
[do your changes] | |
git add . # "stage" all changes for being committed | |
git commit -m "[msg]" # commit your changes, replace [msg] with a short description of your changes | |
git push # pushes your commit to the public repository |
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
# German version | |
# NOTE: We actually say "Scissors-Rock-Paper" ("Schere-Stein-Papier"), in this order | |
# see http://de.wikipedia.org/wiki/Schere,_Stein,_Papier | |
Stein | |
Papier | |
Schere | |
Los geht's! | |
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
# how do you test that form fields submit the parameters that you expect? | |
# the following works. is there any simpler way? | |
class ActiveSupport::TestCase | |
def params_from_form(html, id = nil) | |
id, html = 'test', %(<form id="test">#{html}</form>) unless html =~ /<form / | |
session = Webrat::Session.new | |
scope = Webrat::Scope.new(session) { @response_body = html } | |
Webrat::Locators::FormLocator.new(session, scope.dom, id).locate.send(:params) | |
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
<form> | |
<select type="text" name="filters[body][][scope]"><option name="contains">contains</option></select> | |
<input type="text" name="filters[body][][query]" value="foo"> | |
<select type="text" name="filters[body][][scope]"><option name="starts_with">starts_with</option></select> | |
<input type="text" name="filters[body][][query]" value="bar"> | |
<input type="submit" id="submit" value="submit"> | |
</form> | |
# when send through browser (safari, firefox) | |
{"body"=>[{"scope"=>"contains", "query"=>"foo"}, {"scope"=>"starts_with", "query"=>"bar"}]} |
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
{ | |
:af => { :_plural => lambda { |n| n == 1 ? :one : :other } }, | |
:am => { :_plural => lambda { |n| (0..1).include?(n) ? :one : :other } }, | |
:ar => { :_plural => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : (3..10).include?(n % 100) ? :few : (11..99).include?(n % 100) ? :many : :other } }, | |
:az => { :_plural => lambda { |n| :other } }, | |
:be => { :_plural => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : (2..4).include?(n % 10) && !(12..14).include?(n % 100) ? :few : n % 10 == 0 || (5..9).include?(n % 10) || (11..14).include?(n % 100) ? :many : :other } }, | |
:bg => { :_plural => lambda { |n| n == 1 ? :one : :other } }, | |
:bh => { :_plural => lambda { |n| (0..1).include?(n) ? :one : :other } }, | |
:bn => { :_plural => lambda { |n| n == 1 ? :one : :other } }, | |
:bo => { :_plural => lambda { |n| :other } }, |