Skip to content

Instantly share code, notes, and snippets.

View charleseff's full-sized avatar

Charles Finkel charleseff

  • San Francisco, CA
View GitHub Profile
class c {
exec { "test":
}
}
class{ 'foo': before => Exec['blah']}
class foo(before => Exec['blah']) {
....
}
@charleseff
charleseff / gist:8327591
Created January 9, 2014 00:57
Is there a better way to do this?
$attrs_first = {
command => "/foo",
}
if $condition {
$more_attrs = {require => Class['bar']}
$attrs = merge($attrs_first, $more_attrs)
} else {
$attrs = $attrs_first
}
class Account < ActiveRecord::Base
NewWithOwner < Struct.new(:foo) do
def fetch
# returns an Account obj
end
end
CreateWithSchema < Struct.new(:foo) do
def fetch
# returns an Account obj
[31] pry(main)> @count = 1
=> 1
[32] pry(main)> t = Thread.new {begin; loop{sleep 1}; ensure @count +=1; end}
=> #<Thread:0x00000102e47ca0 run>
[33] pry(main)> t.kill
=> #<Thread:0x00000102e47ca0 aborting>
[34] pry(main)> @count
=> 2
@charleseff
charleseff / after_commit_with_transactional_fixtures.rb
Created October 21, 2011 23:45 — forked from dcuddeback/after_commit_with_transactional_fixtures.rb
Patch ActiveRecord to fire after_commit callbacks at the appropriate time during tests with transactional fixtures.
module ActiveRecord
module ConnectionAdapters
module DatabaseStatements
#
# Run the normal transaction method; when it's done, check to see if there
# is exactly one open transaction. If so, that's the transactional
# fixtures transaction; from the model's standpoint, the completed
# transaction is the real deal. Send commit callbacks to models.
#
# If the transaction block raises a Rollback, we need to know, so we don't