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
response.should have_tag("form#my_form") do | |
have_tag('input#hidden_input_id[type=hidden][value=?]', 'secret') | |
end | |
# matches the following HTML: | |
# <form id="my_form" method="POST" action="create"> | |
# <input id="hidden_input_id" value="secret" type="hidden" /> | |
# </form> |
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
require 'rubygems' | |
require 'rbench' | |
require 'json' | |
TIMES = 1000 | |
json = '{"foo1":"bar1","foo2":"bar2","foo3":"bar3"}' | |
ruby = "{'foo1'=>'bar1', 'foo2'=>'bar2', 'foo3'=>'bar3'}" |
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::AbstractRequest.parse_query_parameters('foo[foo][0]=99') # => {"foo"=>{"foo"=>{"0"=>"99"}}} | |
ActionController::AbstractRequest.parse_query_parameters('foo[foo][]=99') # => {"foo"=>{"foo"=>["99"]}} |
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
# Initial implementation can be found here: http://github.com/newtonapple/rturk | |
# API Doc: http://docs.amazonwebservices.com/AWSMechTurk/latest/AWSMechanicalTurkRequester/ | |
RTurk.setup(AWSAccessKeyId, AWSAccessKey, :sandbox => true) | |
hit_type = RTurk.RegisterHITType(:title => "Python") do |hit_type| | |
hit_type.assignments = 500 | |
hit_type.description = "Python Programming!" | |
hit_type.question("http://localhost:3000/mturk") | |
hit_type.keywords = 'python, programming' |
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
RTurk.setup(AWSAccessKeyId, AWSAccessKey, :sandbox => true) | |
hit = RTurk::Hit.create(:title => "New Upload 3 Documents") do |hit| | |
hit.assignments = 500 | |
hit.description = "no copytrighted materials!" | |
hit.question("http://localhost:3000/mturk") | |
hit.reward = 0.10 | |
hit.qualifications.add :approval_rate, { :gt => 85 } | |
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
require 'rubygems' | |
require 'rake' | |
require 'activerecord' | |
CURRENT_ENV = ENV['RAILS_ENV'] || 'development' | |
ROOT_PATH = File.dirname(__FILE__) | |
DB_CONFIG = YAML.load_file(File.join(ROOT_PATH, 'config', 'database.yml')) | |
namespace :db do | |
namespace :structure do |
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
require 'rubygems' | |
require 'rbench' | |
require 'digest/md5' | |
require 'digest/sha1' | |
MD5 = Digest::MD5 | |
SHA1 = Digest::SHA1 | |
TIMES = 100 | |
short_string = 'this is a short string' |
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
require 'rbench' | |
require 'activesupport' | |
require 'syslog' | |
require 'logger' | |
buffered = ActiveSupport::BufferedLogger.new('buffered.log') | |
logger = Logger.new('logger.log') | |
syslog = Syslog.open('rb_syslog') | |
TIMES = 5 |
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
Snow Leopard for Ruby Developers | |
## Official Rails Guide to upgrading Snow Leopard | |
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard | |
## MacPorts: | |
reference page: http://www.macports.org/install.php | |
download macports: http://distfiles.macports.org/MacPorts/MacPorts-1.8.0-10.6-SnowLeopard.dmg | |
## Afte installing macports do this: |
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
## ENV | |
environment do | |
<<-ENV_CODE | |
config.active_record.timestamped_migrations = false | |
config.active_record.schema_format = :sql | |
# ENV['RAILS_ASSET_ID'] = '' # turn off assets timestamp | |
ENV_CODE | |
end |