Skip to content

Instantly share code, notes, and snippets.

@heisters
heisters / ruote_migrator.rb
Created June 14, 2011 23:29
Trying to update Ruote processes in mid-air
class RuoteMigrator
attr_reader :process_status
def initialize process_status
@process_status = process_status
end
def === other
other = other.pdef if other.respond_to?(:pdef)
process_status.root_expression.tree == other
end
@heisters
heisters / Solarized High Contrast Dark.itermcolors
Created June 8, 2011 21:49
Solarized High Contrast Dark theme for iTerm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.19370138645172119</real>
<key>Green Component</key>
<real>0.15575926005840302</real>
@heisters
heisters / .vimrc
Created March 31, 2011 16:52
my vimrc
set nocompatible " We're running Vim, not Vi!
set hidden
set title
set list
set listchars=tab:»·,trail:·
"set ai sw=2 sts=2 et
set t_Co=256 " lots of colors
set incsearch
syntax on
set scrolloff=2 " make it scroll before I hit the edge
@heisters
heisters / gem_logout.sh
Created March 16, 2011 18:41
Logout of rubygems.org. Hecka hacky.
ruby -e "Gem.configuration.rubygems_api_key = nil"
@heisters
heisters / require.js
Created January 31, 2011 23:30
A robust remote JS dependency manager
var require = (function(){
var requires = {};
return function(filename, callback){
if(typeof(requires[filename]) === "undefined"){
requires[filename] = {
callbacks: [],
state: "initializing",
};
}
$ ruby -rrubygems test/unit/storage.rb -ntest_get_many_schedules -- --redis
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
Fri Nov 12 14:26:32 -0800 2010
Loaded suite test/unit/storage
Started
F
Finished in 0.042717 seconds.
1) Failure:
test_get_many_schedules(UtStorage) [test/unit/storage.rb:191]:
@heisters
heisters / gist:674562
Created November 12, 2010 19:42
migration error
/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
# 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(
@heisters
heisters / parse_ua_strings.rb
Created October 18, 2010 22:05
Get statistics on browser and OS versions from a file of User-Agent strings
#!/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
@heisters
heisters / benchmarks.rb
Created September 8, 2010 19:33
Monkey patches for memory bloat issues in Ruote
# 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