<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Pragmatic life -- a blog by Michael Grosser</title>
	<atom:link href="http://grosser.it/feed/" rel="self" type="application/rss+xml" />
	<link>http://grosser.it</link>
	<description>Building web applications and fighting the daily madness</description>
	<lastBuildDate>Mon, 17 Jun 2013 14:40:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='grosser.it' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>My Pragmatic life -- a blog by Michael Grosser</title>
		<link>http://grosser.it</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://grosser.it/osd.xml" title="My Pragmatic life -- a blog by Michael Grosser" />
	<atom:link rel='hub' href='http://grosser.it/?pushpress=hub'/>
		<item>
		<title>Ruby: retrying multiple times without loops and retry counters</title>
		<link>http://grosser.it/2013/06/05/ruby-retrying-multiple-times-without-loops-and-retry-counters/</link>
		<comments>http://grosser.it/2013/06/05/ruby-retrying-multiple-times-without-loops-and-retry-counters/#comments</comments>
		<pubDate>Wed, 05 Jun 2013 15:59:43 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2208</guid>
		<description><![CDATA[A nice way of not keeping track of retry counter and not using a loop 3.times do begin raise "Nope" rescue puts "Failed" else puts "Success" break endend Tagged: Ruby<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2208&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A nice way of not keeping track of retry counter and not using a loop</p>
<pre>3.times do<br />  begin<br />    raise "Nope"<br />  rescue<br />    puts "Failed"<br />  else<br />    puts "Success"<br />    break<br />  end<br />end</pre>
<br /> Tagged: <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2208&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2013/06/05/ruby-retrying-multiple-times-without-loops-and-retry-counters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Prevent missing type / NameError in polymorphic ActiveRecord associations</title>
		<link>http://grosser.it/2013/04/12/prevent-missing-type-nameerror-in-polymorphic-activerecord-associations/</link>
		<comments>http://grosser.it/2013/04/12/prevent-missing-type-nameerror-in-polymorphic-activerecord-associations/#comments</comments>
		<pubDate>Fri, 12 Apr 2013 17:32:20 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2201</guid>
		<description><![CDATA[ActiveRecord loads the xxx_type in your model, making it blow up when doing includes / using the belongs_to on a missing type. So we make it un-missing. Usage class Waldo &#60; MissingType end Code class MissingType &#60; ActiveRecord::Base default_scope :conditions =&#62; "1 = 2", :limit =&#62; 0 self.table_name = "schema_migrations" def self.primary_key "version" end def [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2201&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>ActiveRecord loads the xxx_type in your model, making it blow up when doing includes / using the belongs_to on a missing type.<br />
So we make it un-missing.</p>
<p><b>Usage</b><br />
<code>
<pre style="font-size:12px;overflow:auto;">
class Waldo &lt; MissingType
end
</pre>
<p></code></p>
<p><b>Code</b><br />
<code>
<pre style="font-size:12px;overflow:auto;">
class MissingType &lt; ActiveRecord::Base
  default_scope :conditions =&gt; "1 = 2", :limit =&gt; 0

  self.table_name = "schema_migrations"

  def self.primary_key
    "version"
  end

  def readonly?
    true
  end
end
</pre>
<p></code></p>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2201&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2013/04/12/prevent-missing-type-nameerror-in-polymorphic-activerecord-associations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Passwordless ssh auth into your vagrant box</title>
		<link>http://grosser.it/2013/02/09/passwordless-ssh-auth-into-your-vagrant-box/</link>
		<comments>http://grosser.it/2013/02/09/passwordless-ssh-auth-into-your-vagrant-box/#comments</comments>
		<pubDate>Sat, 09 Feb 2013 05:25:50 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Rake]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Vagrant]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2192</guid>
		<description><![CDATA[Repeatedly entering password is quiet annoying, luckily most vagrant base boxes come with the same insecure ssh key curl https://raw.github.com/mitchellh/vagrant/master/keys/vagrant &#62; vagrant.key chmod 600 vagrant.key knife solo cook --ssh-identity vagrant.key vagrant@vagrant Tagged: Rake, SSH, Vagrant<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2192&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Repeatedly entering password is quiet annoying, luckily most vagrant base boxes come with the same insecure ssh key <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre style="font-size:12px;overflow:auto;">
curl https://raw.github.com/mitchellh/vagrant/master/keys/vagrant &gt; vagrant.key
chmod 600 vagrant.key
knife solo cook --ssh-identity vagrant.key vagrant@vagrant
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rake/'>Rake</a>, <a href='http://grosser.it/tag/ssh/'>SSH</a>, <a href='http://grosser.it/tag/vagrant/'>Vagrant</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2192&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2013/02/09/passwordless-ssh-auth-into-your-vagrant-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Enqueue into Sidekiq via pure Redis (without loading sidekiq)</title>
		<link>http://grosser.it/2013/01/17/enqueue-into-sidekiq-via-pure-redis-without-loading-sidekiq/</link>
		<comments>http://grosser.it/2013/01/17/enqueue-into-sidekiq-via-pure-redis-without-loading-sidekiq/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 23:44:53 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[Sidekiq]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2178</guid>
		<description><![CDATA[We want to enqueue jobs, but do not want to blow up the app with sidekiq and it&#8217;s dependencies. Usage RawSidekiq.enqueue("XyzJob", [1,2,3], :namespace =&#62; "custom") Code # http://grosser.it/2013/01/17/enqueue-into-sidekiq-via-pure-redis-without-loading-sidekiq require "json" require "redis" require "securerandom" class RawSidekiq def self.enqueue(queue, klass, args, options={}) payload = { 'class' =&#62; klass, 'args' =&#62; args, 'jid' =&#62; SecureRandom.hex(12), #'retry' =&#62; [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2178&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>We want to enqueue jobs, but do not want to blow up the app with sidekiq and it&#8217;s dependencies.</p>
<p><b>Usage</b></p>
<pre style="font-size:12px;overflow:auto;">
RawSidekiq.enqueue("XyzJob", [1,2,3], :namespace =&gt; "custom")
</pre>
<p><b>Code</b></p>
<pre style="font-size:12px;overflow:auto;">
# http://grosser.it/2013/01/17/enqueue-into-sidekiq-via-pure-redis-without-loading-sidekiq
require "json"
require "redis"
require "securerandom"

class RawSidekiq
  def self.enqueue(queue, klass, args, options={})
    payload = {
      'class' =&gt; klass,
      'args' =&gt; args,
      'jid' =&gt; SecureRandom.hex(12),
      #'retry' =&gt; true
    }.to_json

    conn = Redis.new
    conn.multi do
      conn.sadd([options[:namespace], "queues"].compact.join(":"), queue)
      conn.lpush([options[:namespace], "queue", queue].compact.join(":"), payload)
    end
  end
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/redis/'>Redis</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a>, <a href='http://grosser.it/tag/sidekiq/'>Sidekiq</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2178&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2013/01/17/enqueue-into-sidekiq-via-pure-redis-without-loading-sidekiq/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Kill ActiveRecord observers</title>
		<link>http://grosser.it/2013/01/04/kill-activerecord-observers/</link>
		<comments>http://grosser.it/2013/01/04/kill-activerecord-observers/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 22:53:01 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2164</guid>
		<description><![CDATA[Killing observers decreases startup time by not loading all your models makes it possible to preload config/environment.rb and still test models -&#62; spin/zeus makes dependencies obvious replaces ActiveRecord magic with ruby makes your app Rails 4 ready Before: # config/environment.rb config.observers = [:foo_observer] # app/observers/foo_observer.rb class FooObserver &#60; ActiveRecord::Observer observes :user def after_save(user) .... end [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2164&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Killing observers</p>
<ul>
<li>decreases startup time by not loading all your models</li>
<li>makes it possible to preload config/environment.rb and still test models -&gt; spin/zeus</li>
<li>makes dependencies obvious</li>
<li>replaces ActiveRecord magic with ruby</li>
<li>makes your app Rails 4 ready</li>
</ul>
<p>Before:</p>
<pre>
# config/environment.rb
config.observers = [:foo_observer] 

# app/observers/foo_observer.rb
class FooObserver &lt; ActiveRecord::Observer
  observes :user

  def after_save(user)
    ....
  end
end
</pre>
<p>After:</p>
<pre>
# app/models/user.rb
class User &lt; ActiveRecord::Base
  include FooObserver
end

# app/observers/foo_observer.rb
module FooObserver
  class &lt;&lt; self
    def included(base)
      this = self
      base.after_save{|user| this.more_descriptive_name(user) }
    end

    def more_descriptive_name(user)
      ...
    end
  end
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2164&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2013/01/04/kill-activerecord-observers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Upgrading to rails 3.0 &#8212; making sure you use rack headers everywhere</title>
		<link>http://grosser.it/2012/10/19/upgrading-to-rails-3-0-making-sure-you-use-rack-headers-everywhere/</link>
		<comments>http://grosser.it/2012/10/19/upgrading-to-rails-3-0-making-sure-you-use-rack-headers-everywhere/#comments</comments>
		<pubDate>Fri, 19 Oct 2012 15:03:00 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2159</guid>
		<description><![CDATA[Normal headers like Accept or :authorization do not work in rails 3 integration tests and you need to convert everything to HTTP_ACCEPT etc, to help find all those places and make sure you do not introduce new bugs in rails 2 add this: # http://grosser.it/2012/10/19/upgrading-to-rails-3-0-making-sure-you-use-rack-headers-everywhere/ # message can be changed on rails 3, but keep [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2159&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Normal headers like Accept or :authorization do not work in rails 3 integration tests and you need to convert everything to HTTP_ACCEPT etc, to help find all those places and make sure you do not introduce new bugs in rails 2 add this:</p>
<pre style="font-size:12px;overflow:auto;">
# http://grosser.it/2012/10/19/upgrading-to-rails-3-0-making-sure-you-use-rack-headers-everywhere/
# message can be changed on rails 3, but keep the warning, it's so hard to track down missing headers
# maybe try to remove in rails 3.1+
# can be tested by e.g. changing header to Accept instead of HTTP_ACCEPT
class ActionController::Integration::Session
  # headers that are only used by our code and not rails/rack can be whitelisted, but make sure they work on rails 2 and 3
  HEADER_WHITELIST = ['Funky-Headers-You-Have-To-Use']
  def process_with_header_warning(*args)
    if args[3] &amp;&amp; bad = args[3].keys.detect{|k| !k.is_a?(String) || (!HEADER_WHITELIST.include?(k) &amp;&amp; k !~ /^[A-Z_\d]+$/) }
      raise "Header #{bad} will not work on rails 3, please uppercase (Content-Type -&gt; CONTENT_TYPE) and prefix HTTP_ (Accept -&gt; HTTP_ACCEPT)"
    end
    process_without_header_warning(*args)
  end
  alias_method_chain :process, :header_warning
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2159&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2012/10/19/upgrading-to-rails-3-0-making-sure-you-use-rack-headers-everywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails 2: Your integration tests are lying</title>
		<link>http://grosser.it/2012/10/19/rails-2-your-integration-tests-are-lying/</link>
		<comments>http://grosser.it/2012/10/19/rails-2-your-integration-tests-are-lying/#comments</comments>
		<pubDate>Fri, 19 Oct 2012 15:00:09 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2149</guid>
		<description><![CDATA[Integration tests call the whole rack middleware stack, but stubbornly return the last controller response, which can be completely different especially if you use warden or other middleware-tools. See actionpack-2.3.14/lib/action_controller/integration.rb:342 To fix that and prepare for Rails 3 (which also relies on rack response) do this: # test/test_helper.rb if Rails::VERSION::MAJOR == 2 # http://grosser.it/2012/10/19/rails-2-your-integration-tests-are-lying/ # [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2149&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Integration tests call the whole rack middleware stack, but stubbornly return the last controller response, which can be completely different especially if you use warden or other middleware-tools.</p>
<p>See actionpack-2.3.14/lib/action_controller/integration.rb:342</p>
<p>To fix that and prepare for Rails 3 (which also relies on rack response) do this:</p>
<pre style="font-size:12px;overflow:auto;">
# test/test_helper.rb

if Rails::VERSION::MAJOR == 2
  # http://grosser.it/2012/10/19/rails-2-your-integration-tests-are-lying/
  # make integration tests use rack response, so we can test our middlewares
  # and not only the pure controller response

  ActionController::Base.class_eval do
    # this is usually done just-in-time by #process but we need to do it earlier
    include ActionController::Integration::ControllerCapture

    # then we hide last_instantiation from #process
    def self.last_instantiation;end
  end

  ActionController::Integration::Session.class_eval do
    def process_with_rackify(*args)
      process_without_rackify(*args)
    ensure
      # needed e.g. inside of assert_redirect_to
      capture = ActionController::Integration::ControllerCapture::ClassMethods

      # not set by original #process
      @response.redirected_to = @response.headers["Location"] if @response
      if @controller = capture.send(:class_variable_get, :@@last_instantiation)
        @request = @controller.request
        @response.template = @controller.response.template if @controller.response
        @controller.send(:set_test_assigns)
      end
    end
    alias_method_chain :process, :rackify
  end
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2149&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2012/10/19/rails-2-your-integration-tests-are-lying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Making sure you are not creating unwanted actions by including Modules</title>
		<link>http://grosser.it/2012/09/20/making-sure-you-are-not-creating-unwanted-actions-by-including-modules/</link>
		<comments>http://grosser.it/2012/09/20/making-sure-you-are-not-creating-unwanted-actions-by-including-modules/#comments</comments>
		<pubDate>Thu, 20 Sep 2012 22:30:32 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2144</guid>
		<description><![CDATA[This will blow up if someone includes a module with public methods that would count as actions. # application_controller_test.rb class ApplicationControllerTest &#60; ActionController::TestCase class CleanController &#60; ApplicationController end test &#34;should be clean&#34; do assert_equal [], CleanController.action_methods.to_a. reject{&#124;a&#124; a =~ /^_conditional_callback_around_/} end end Tagged: Rails, Ruby, Test<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2144&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This will blow up if someone includes a module with public methods that would count as actions.</p>
<pre style="font-size:12px;overflow:auto;">
# application_controller_test.rb
class ApplicationControllerTest &lt; ActionController::TestCase
  class CleanController &lt; ApplicationController
  end

  test &quot;should be clean&quot; do
    assert_equal [], CleanController.action_methods.to_a.
      reject{|a| a =~ /^_conditional_callback_around_/}
  end
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a>, <a href='http://grosser.it/tag/test/'>Test</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2144&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2012/09/20/making-sure-you-are-not-creating-unwanted-actions-by-including-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Airbrake error backtrace summary</title>
		<link>http://grosser.it/2012/09/08/airbrake-error-summary/</link>
		<comments>http://grosser.it/2012/09/08/airbrake-error-summary/#comments</comments>
		<pubDate>Sat, 08 Sep 2012 15:59:45 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2139</guid>
		<description><![CDATA[We often have an error with a few thousand occurances and want to find out which code paths caused it. Usage Use auth-token from settings page, not your api-key. ruby airbrake_backtraces.rb your-account your-auth-token error-id Output Trace 1: occurred 597 times ...funky backtraces... Trace 2: occurred 119 times ...funky backtraces... Trace 3: occurred 13 times ...funky [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2139&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>We often have an error with a few thousand occurances and want to find out which code paths caused it.</p>
<p><b>Usage</b><br />
Use auth-token from settings page, not your api-key.</p>
<pre style="font-size:12px;overflow:auto;">
ruby airbrake_backtraces.rb your-account your-auth-token error-id
</pre>
<p><b>Output</b></p>
<pre style="font-size:12px;overflow:auto;">
Trace 1: occurred 597 times
...funky backtraces...
Trace 2: occurred 119 times
...funky backtraces...
Trace 3: occurred 13 times
...funky backtraces...
</pre>
<p><b>Code</b></p>
<pre style="font-size:12px;overflow:auto;">
#! /usr/bin/env ruby
# lists all sources of a given error
# http://grosser.it/2012/09/08/airbrake-error-summary
#
# gem install airbrake-api
# USAGE: ruby airbrake_backtraces.rb your-account your-auth-token error-id
# https://your-account.airbrake.io/errors/ID

require "airbrake-api"

AirbrakeAPI.account = ARGV[0] || raise("need airbrake account as ARGV[0]")
AirbrakeAPI.auth_token = ARGV[1] || raise("need airbrake token as ARGV[1], go to airbrake -&gt; settings, copy your auth token")
AirbrakeAPI.secure = true

error_id = ARGV[2] || raise("need error id")
compare_depth = (ARGV[3] || 4).to_i

notices = AirbrakeAPI.notices(error_id, :pages =&gt; 20)
backtraces = notices.select{|n| n.backtrace }.group_by do |notice|
  notice.backtrace.first[1][0..compare_depth]
end

backtraces.sort_by{|k,t| t.size }.reverse.each_with_index do |(key, traces), index|
  puts "Trace #{index + 1}: occurred #{traces.size} times"
  puts key
  puts ""
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2139&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2012/09/08/airbrake-error-summary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
		<item>
		<title>Airbrake search</title>
		<link>http://grosser.it/2012/09/08/airbrake-search/</link>
		<comments>http://grosser.it/2012/09/08/airbrake-search/#comments</comments>
		<pubDate>Sat, 08 Sep 2012 15:46:59 +0000</pubDate>
		<dc:creator>pragmatig</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://grosser.it/?p=2132</guid>
		<description><![CDATA[We need to search for specific errors quiet often, this script helps us find them without having to go through the web interface. Usage auth_token can be found on your settings page, it is NOT the api-key. ruby airbrake_search.rb your-account your-auth-token &#124; grep foo Code #! /usr/bin/env ruby # http://grosser.it/2012/09/08/airbrake-search # search for errors given [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2132&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>We need to search for specific errors quiet often, this script helps us find them without having to go through the web interface.</p>
<p><b>Usage</b><br />
auth_token can be found on your settings page, it is NOT the api-key.</p>
<pre style="overflow:auto;font-size:12px;">
ruby airbrake_search.rb your-account your-auth-token | grep foo
</pre>
<p><b>Code</b></p>
<pre style="overflow:auto;font-size:12px;">
#! /usr/bin/env ruby
# http://grosser.it/2012/09/08/airbrake-search
# search for errors given a name
#
# gem install airbrake-api
# USAGE: ruby airbrake_search.rb your-account your-auth-token | grep SOMETHING
# https://your-account.airbrake.io/errors/ID

require "airbrake-api"

AirbrakeAPI.account = ARGV[0] || raise("need airbrake account as ARGV[0]")
AirbrakeAPI.auth_token = ARGV[1] || raise("need airbrake token as ARGV[1], go to airbrake -&gt; settings, copy your auth token")
AirbrakeAPI.secure = true

page = 1
while errors = AirbrakeAPI.errors(:page =&gt; page)
  errors.each do |error|
    puts "#{error.id} -- #{error.error_class} -- #{error.error_message} -- #{error.created_at}"
  end
  $stderr.puts "Page #{page} ----------\n"
  page += 1
end
</pre>
<br /> Tagged: <a href='http://grosser.it/tag/rails/'>Rails</a>, <a href='http://grosser.it/tag/ruby/'>Ruby</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pragmatig.wordpress.com/2132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pragmatig.wordpress.com/2132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grosser.it&#038;blog=2921704&#038;post=2132&#038;subd=pragmatig&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grosser.it/2012/09/08/airbrake-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/59436ecd4fe6ad7c34f67654d839f05f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pragmatig</media:title>
		</media:content>
	</item>
	</channel>
</rss>
