Skip to content

Instantly share code, notes, and snippets.

View coffeeaddict's full-sized avatar

Hartog C. de Mik coffeeaddict

View GitHub Profile
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|
@coffeeaddict
coffeeaddict / DORY.md
Created October 27, 2012 06:14
An explanation of DORY

DORY

DO Repeat Yourself

But why?

There is one very powerful phrase that describes the 'why?' very well: "Wax-on, wax-off!"

@coffeeaddict
coffeeaddict / gist:3699848
Created September 11, 2012 17:02 — forked from JiriChara/gist:3697487
ALL CREDIT CARD PIN CODES IN THE WORLD / in 1 line :-p
(0..9999).map{|x|"%.4i"%x}.each_slice(10){|x|puts x.join("\t")}
@coffeeaddict
coffeeaddict / close_many_tabs.md
Created September 5, 2012 07:34
Close many tabs (Chromium)

Tired of hitting ctrl+w 20 times in a row?

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'])