Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get -y update
apt-get -y install build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev
apt-get -y install ruby1.9.3 ruby-switch
ruby-switch --set ruby1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc
#!/usr/bin/env bash
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get -y update
apt-get -y install build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev
apt-get -y install ruby1.9.3 ruby-switch
ruby-switch --set ruby1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc
class SaveFromAfterCommitBlockTest < ActiveRecord::TestCase
class TopicWithSaveInCallback < ActiveRecord::Base
self.table_name = :topics
after_commit :cache_topic, :on => :create
def cache_topic
puts "******************* calling this stuff again #{cached.inspect}"
unless cached
self.cached = true
self.save
class User < ActiveRecord::Base
attr_accessible :name
after_commit :wow, :on => :create, :unless => :no_commit
attr_accessor :no_commit
def wow
puts "Calling wow"
self.no_commit = true
self.save
puts "Done called wow"
class User < ActiveRecord::Base
attr_accessible :name
attr_accessible :options, :name
serialize :options
def options
self[:options] ||= {}
end
end
module AfterCommitPatch
def transaction(options = {})
rolled_back = false
begin
super
rescue ActiveRecord::Rollback => e
rolled_back = true
end
invoke_commit_objects unless rolled_back
end
require "eventmachine"
require "mailfactory"
mail = MailFactory.new
mail.to = '[email protected]'
mail.from = '[email protected]'
mail.subject = 'hi!'
mail.text = 'hello world'
mail.html = '<h1>hello world</h1>'
binding.pry()
if !klass.accessible_attributes.blank?
if klass.accessible_attributes.include?(key)
params[key] = value
end
else
if !klass.protected_attributes.include?(key)
params[key] = value
end
end
ab -n 5000 -c 30
---- rvm 1.9.3 -----
First run:
-------------------------------
Requests per second: 115.66 [#/sec] (mean)
Time per request: 86.459 [ms] (mean)
| | ,---------,
K. .H |r'''|'''Y|
/ *'.* \ || | ||
/ \ ||===|===||
/.- -. \ || | ||
/ |-| _/-/ \ |L.__|__.J|
/ \)_) (_() \ '---------'
_________________________
-__LLLLLLLLLLLLLLLLL__-