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 'prawn' | |
require 'benchmark' | |
pdf = Prawn::Document.new | |
cell = Prawn::Table::Cell.make( pdf, "Some text" ) | |
n = 100_000 | |
Benchmark.bm do |x| | |
x.report("cached") { n.times { cell.send(:styled_width_of_single_character) } } |
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
JRuby-Lint version 0.3.1 | |
For more on gem compatibility see http://wiki.jruby.org/C-Extension-Alternatives | |
./Gemfile:8: [gems, warning] Found gem 'mysql2' which is reported to have some issues: | |
Use activerecord-jdbc-adapter instead along with jdbc-mysql. | |
./Gemfile:52: [gems, warning] Found gem 'thin' which is reported to have some issues: | |
Thin might compile and run but is not recommended. Try any one of the following JRuby-based servers: Trinidad, Mizuno, Kirk, TorqueBox or Puma. | |
./Gemfile:53: [gems, warning] Found gem 'unicorn' which is reported to have some issues: | |
Try any one of the following JRuby-based servers: Trinidad, Mizuno, Kirk, mobile or Puma. | |
./Gemfile:69: [gems, warning] Found gem 'nokogiri' which is reported to have some issues: | |
For best results, use the pure-Java version of Nokogiri (default after v1.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
# | |
# Based heavily on the deployment recipe dicussed in the article at | |
# http://ariejan.net/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn | |
# but tweaked to fit our setup... | |
# | |
# NO WARRANTY, IMPLIED OR OTHERWISE | |
# | |
# Multistage setup | |
set :stages, %w(production staging) |
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
# Save some data when a feature failed | |
After('@javascript') do |scenario| | |
# Only failed, and only if we can render | |
if scenario.failed? && page.driver.respond_to?(:render) | |
# Get a name | |
name = case scenario | |
when Cucumber::Ast::OutlineTable::ExampleRow | |
[ scenario.scenario_outline.name, scenario.name ].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
#!/usr/bin/env ruby | |
# | |
# Shotgun approach (read: slow and dirty hack) to help find unused helpers in a Rails application | |
# | |
puts "Loading all source files into memory :(" | |
source = {} | |
Dir["app/**/**/*.*"].each do |f| | |
source[ f ] = File.readlines( f ) |
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
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGBUS | |
[[Backtrace]] | |
0 rbx 0x00000001000221f1 _ZN8rubiniusL12segv_handlerEi + 241 | |
1 libSystem.B.dylib 0x00007fff8237f1ba _sigtramp + 26 | |
[[System Info]] | |
sysname: Darwin |
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
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGSEGV | |
[[Backtrace]] | |
0 rbx 0x00000001000221f1 _ZN8rubiniusL12segv_handlerEi + 241 | |
1 libSystem.B.dylib 0x00007fff809681ba _sigtramp + 26 | |
2 ??? 0x00007fff5fbf6b70 0x0 + 140734799768432 | |
3 rbx 0x00000001002689cb rbx_yield_stack + 267 | |
4 ??? 0x0000000102d7fec6 0x0 + 4342677190 |
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
Ruote.process_definition :name => 'Test' do | |
sequence do | |
# Loop, depending on the amqp participant to set 'completed' once it has successfully processed the | |
# workitem. | |
_loop :break_if => "${f:completed}" do | |
# This remote participant will either set a field called 'completed' to true when it is done, | |
# or set 'error' with the exception. | |
amqp_participant :activity => "Do something" |
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 | |
# | |
# Migrate from old assigns[]= to assign() | |
Dir["spec/**/*_spec.rb"].each do |file| | |
changed = File.readlines( file ).map do |line| | |
pattern = /assigns\[(:[\w\d_]+)\] = (.+)$/ | |
if line =~ pattern | |
puts "Match: #{line}" | |
puts "Assign: #{$1}" |