This file contains hidden or 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 | |
# A script for profiling and benching Rails actions, because Rails's default scripts suck. | |
# Examples: | |
# | |
# Run a profile on 10 runs of /widgets/1 | |
# ./action_performance.rb /widgets/1 10 profile | |
# | |
# Run a benchmark on 15 runs of /widgets/1 | |
# ./action_performance.rb /widgets/1 15 bench |
This file contains hidden or 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
<h1><%= @video.title %></h1> | |
<div class="ad"> | |
<%= image_tag(@video.ad_url) %> | |
<p class="description"><%= @video.ad_shortDescription %></p> | |
</div> |
This file contains hidden or 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($){ | |
/* | |
* var sa = new $.SpriteAnimator({ | |
* url: "/images/carousel-spinner-sprites.gif", | |
* duration: 5000, | |
* sprite: {height: 19, width: 18}, | |
* frames: 8 | |
* }); | |
* $("body").append(sa.element); | |
*/ |
This file contains hidden or 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
# Causes a segfault | |
# | |
# $ ruby crash.rb | |
# parsed | |
# selected | |
# crash.rb:12: [BUG] Segmentation fault | |
# ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] | |
# | |
# Aborted |
This file contains hidden or 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 | |
# | |
# Get the lines of code in a file, over time as CSV. | |
require 'rubygems' | |
require 'fastercsv' | |
file = ARGV[0] or abort("Must specify a file") | |
log = `git log --pretty=format:"%H %ai" #{file}` | |
log.split(/[\r\n]/).map do |log_line| | |
commit, date = log_line.split(/ /) |
This file contains hidden or 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 Patient | |
class NestedWaitForError < StandardError; end | |
class << self | |
def lock | |
@lock ||= Mutex.new | |
end | |
def waiting | |
lock.synchronize{@waiting} |
This file contains hidden or 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
# You should kill the Ruby process in between runs to flush out the memory | |
# entirely. | |
puts "memory usage: #{MemoryUsage.get}" | |
n = 5 | |
Benchmark.bm do |r| | |
r.report do | |
n.times do | |
Workflow.engine.context.history.by_process("20100826-behobijunu") | |
end | |
end |
This file contains hidden or 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 | |
require 'rubygems' | |
require 'user-agent' | |
require 'rational' | |
require 'yaml' | |
parsed = nil | |
File.open(ARGV[0], 'r') do |f| | |
parsed = f.each_line.map{|l|Agent.new(l.strip)} | |
end |
This file contains hidden or 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
# db/migrations/2010-11-12_10_54_copy_data_to_new_storage_backend.rb | |
couch = Workflow::Engine.build_couch_storage | |
redis = Workflow::Engine.build_redis_storage | |
# based on http://groups.google.com/group/openwferu-users/browse_thread/thread/8d32d3052eacfba6/423f33bb4b44189f and | |
# Ruote::StorageBase#copy_to | |
# | |
# just limits the types of data that are copied over as compared to copy_to | |
%w( |
This file contains hidden or 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
/home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/base.rb:280:in `[]': can't convert String into Integer (TypeError) | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/base.rb:280:in `filter_schedules' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/base.rb:280:in `select' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/base.rb:280:in `filter_schedules' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/base.rb:143:in `get_schedules' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/composite_storage.rb:123:in `send' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/storage/composite_storage.rb:123:in `get_schedules' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/ruote/worker.rb:141:in `step' | |
from /home/ian/.rvm/gems/ruby-1.8.7-p174/gems/ruote-2.1.10/lib/r |