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 'benchmark/ips' | |
Benchmark.ips do |x| | |
code1 = -> { catch(:foo) { throw(:foo, 'catch/throw') } } | |
x.report("catch a throw") { | |
value = code1.call | |
} | |
code2 = -> { begin; raise RuntimeError; rescue RuntimeError; 'raise/rescue' end } | |
x.report("rescue and exception") { |
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 'nokogiri' | |
require 'open-uri' | |
# Get a Nokogiri::HTML:Document for the page we're interested in... | |
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) | |
# Do funky things with it using Nokogiri::XML::Node methods... | |
#### |
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
/** | |
* Create revision for existing translation. | |
*/ | |
function module_update_7005(&$sandbox) | |
{ | |
if (!isset($sandbox['progress'])): | |
$sandbox['progress'] = 0; | |
$sandbox['current_type'] = 0; | |
$sandbox["entity_type"] = array(); | |
$sandbox['max'] = db_query('SELECT COUNT(*) FROM {entity_translation}')->fetchField(); |