DO Repeat Yourself
There is one very powerful phrase that describes the 'why?' very well: "Wax-on, wax-off!"
define await_external_event | |
alpha | |
bravo | |
storage_wait timeout: '7d' | |
charly unless: '${f:external_event_happened_in_last_7_days}' |
define branch_and_wait | |
alpha | |
bravo | |
concurrence | |
sequence | |
storage | |
charlie_alpha | |
sequence | |
storage | |
charlie_bravo |
# For future reference | |
# ActiveRecord | |
class Doc < ActiveRecord::Base | |
before_save do | |
# i am a proc, I have self as a reference to the object | |
self.attribute_x = nil | |
end | |
before_save { |x| |
(0..9999).map{|x|"%.4i"%x}.each_slice(10){|x|puts x.join("\t")} |
Me too - so I just did it. I tried if my browser would behave as expected. And it did!
I went to the first tab I wanted to close by clicking on it with the mouse. Then, with the shift-button down, I clicked on the last tab. Now I held one hand before my eyes (peeking between 2 fingers) and hit ctrl+w.
It closed all those tabs. As one would expect.
Wow
def test_with_numbers | |
pdef = Ruote.define do | |
set 'commission' => 2.310000 | |
set 'scommission' => '2.310000' | |
echo 'a', :if => '${f:commission} > 0' | |
echo '.' | |
echo 'b', :unless => '${f:commission} > 0' |
require 'tmpdir' | |
require 'ruote' | |
# | |
# blah | |
# | |
# Note: using ruote 2.3.0 (master), not too difficult to port to 2.2.0. | |
# | |
class ConvertFilesParticipant | |
include Ruote::LocalParticipant |
class PreferedImplementation < Ruote::ProcessObserver | |
def on_launch(wfid, workitem, variables) # stash and pdef could also be there | |
$stderr.puts "Hey! #{wfid} started with #{workitem.fields}" | |
end | |
def on_end(wfid, workitem) | |
$stderr.puts "#{wfid} finaly made it! (the workitem ended up as #{workitem.fields})" | |
end | |
def on_flunk(wfid, workitem, error) |
class RuoteObserver | |
def initialize(context, options={}) | |
end | |
def on_msg(msg) | |
case msg['action'] | |
when 'launch' | |
msg['launched_at'] = Time.now | |
when 'terminated' | |
Project.logger.debug "{#{msg['wfid']}} [#{msg['workitem']['wf_name']}] took %.2fs" % (Time.now - msg['launched_at']) |