<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Deployment Zone</title>
	
	<link>http://www.deploymentzone.com</link>
	<description>"I write C#".gsub(/C#/, 'Ruby')</description>
	<lastBuildDate>Wed, 18 Apr 2012 13:20:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/deploymentzone" /><feedburner:info uri="deploymentzone" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/deploymentzone" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fdeploymentzone" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><item>
		<title>Heroku shared database and Postgres user defined functions</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/4CKteZ5g420/</link>
		<comments>http://www.deploymentzone.com/2012/04/12/heroku-shared-database-and-postgres-user-defined-functions/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 22:00:06 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=353</guid>
		<description><![CDATA[User defined functions on Heroku's shared Postgres database.]]></description>
			<content:encoded><![CDATA[<p>If you're developing an application on Heroku and you need user defined functions you may be alarmed to find out that [as of April 2012] you get error messages while attempting a <tt>CREATE OR REPLACE FUNCTION</tt> on the Heroku shared database.  Fortunately you don't have to go very far to get your functions working - but you will have to be willing to use Heroku's public beta replacement shared database.  Obviously this means its not fit for productions systems - so for a production system you may need to look at one of the other Postgres database providers for Heroku (and the Rails gem <a href="https://github.com/gregbell/active_admin">ActiveAdmin</a> won't work with <a href="https://addons.heroku.com/justonedb">JustOneDB</a>, I know, I've tried).</p>
<p>If you're reading this after April 2012 there's an increased likelihood that Heroku has made the new shared database available as default and this article probably will no longer apply.</p>
<p>In order to migrate your existing shared database to the new public beta version with user defined function support you'll want to backup your existing database - assuming that data is important to you.</p>
<p>We'll use <a href="https://devcenter.heroku.com/articles/pgbackups#creating_a_backup">pgbackups</a> for backing up and restoring as this leaves the data on Heroku/Amazon.  <em>Note:</em> You'll probably want to disable your application if its in a running state before backing up as any data committed after the backup but before the restore by your users would be effectively lost.</p>
<pre class="brush:bash"># shell
$ heroku addons:add pgbackups:basic
$ heroku pgbackups:capture</pre>
<p>If this is your first backup you'll likely end up with a backup that can be identified as "b001" - backup identifiers beginning with a "b" signify that they are a manual backup.</p>
<p>Next we'll add the new <a href="https://devcenter.heroku.com/articles/heroku-shared-postgresql">heroku-shared-postgresql</a> addon which automatically creates a database for us:</p>
<pre class="brush:bash"># shell
$ heroku addons:add heroku-shared-postgresql</pre>
<p>In the output you'll see the identifier of the new shared database all in caps.  Mine was <tt>HEROKU_SHARED_POSTGRESQL_COBALT</tt>; yours may be as well (or perhaps some other _METAL name).</p>
<p>Next restore the new database from your backup:</p>
<pre class="brush:bash"># shell
heroku pgbackups:restore HEROKU_SHARED_POSTGRESQL_COBALT b001</pre>
<p>You'll be asked to confirm.  Finally switch your application from the old database to the new database:</p>
<pre class="brush:bash"># shell
$ heroku pg:promote HEROKU_SHARED_POSTGRESQL_COBALT
</pre>
<p>Now you'll be able to run those migrations that create user defined functions and even connect to your database instance using PSQL!</p>
<pre class="brush:bash"># shell
$ heroku pg:psql HEROKU_SHARED_POSTGRESQL_COBALT</pre>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/4CKteZ5g420" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/04/12/heroku-shared-database-and-postgres-user-defined-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/04/12/heroku-shared-database-and-postgres-user-defined-functions/</feedburner:origLink></item>
		<item>
		<title>Trinidad + “SEVERE: A child container failed during start”</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/Str33UEgK9I/</link>
		<comments>http://www.deploymentzone.com/2012/04/12/trinidad-severe-a-child-container-failed-during-start/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 16:09:45 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[trinidad]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=351</guid>
		<description><![CDATA[Trinidad, JRuby/Rails and SEVERE Tomcat child container messages.]]></description>
			<content:encoded><![CDATA[<p>If you're using <a href="https://github.com/trinidad/trinidad">Trinidad</a> to run your JRuby/Rails application and you get <tt>SEVERE: A child container failed during start</tt> its likely that the JVM isn't getting enough memory.  Maybe you're using Spring and a host of other jars that your application relies upon.  You can get around this by running:</p>
<pre class="brush:bash"># shell
jruby -J-Xmx1024m -S trinidad</pre>
<p>So how do you do this in a production environment?  You could of course pass along the same command line options, or for better configuration management you can use the <a href="https://github.com/trinidad/trinidad_daemon_extension">Trinidad Daemon extension</a>.</p>
<pre class="brush:ruby"># ./Gemfile
  ⋮
  gem 'trinidad'
  gem 'trinidad_daemon_extension'
  gem 'trinidad_logging_extension' # optional, hah! who're we kidding?
  ⋮
</pre>
<p>And then some configuration options:</p>
<pre class="brush:ruby"># ./config/trinidad.yml
jruby_max_runtimes: 1 # also enables threadsafe by convention
libs_dir: lib # by default this is lib/jars - but if you're coming from Warbler you might be accustomed to /lib

extensions:
  logging: # logging always a good idea
    config: lib/resources/log4j.properties
    logging_system: log4j
  daemon:
    jvm_args: '-Xmx1024m'</pre>
<p>Now just <tt>jruby -S trinidad</tt> for your production environment or your dev workstations and the configuration environment will be the same.  And if you've setup everything correctly you can still <tt>be rails s</tt> which also means your Spork/Guard/RSpec world will continue to function as well.</p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/Str33UEgK9I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/04/12/trinidad-severe-a-child-container-failed-during-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/04/12/trinidad-severe-a-child-container-failed-during-start/</feedburner:origLink></item>
		<item>
		<title>Postgres [table value] functions and Rails 3</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/1S6KGV6_mbo/</link>
		<comments>http://www.deploymentzone.com/2012/04/09/postgres-table-value-functions-and-rails-3/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 12:13:50 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=348</guid>
		<description><![CDATA[Postgres parameterized view/table value function and Rails 3.]]></description>
			<content:encoded><![CDATA[<p>Coming from the MSSQL world I'm used to performing some set-based operations on the database backend, especially when it makes performance sense to do so.  If you search for "rails stored procedure" you typically get a lot of nonsense about DHH not liking stored procedures and not a lot of practical examples.</p>
<p>I needed to essentially have a parameterized view (that's what we called it in SQL Server) and I was delighted when I found that Postgres supports it right out of the box - not to mention its superior temporal functions.  The next challenge was Rails of course.  I'm stepping outside of the typical ActiveRecord model pattern here and while I'm sure there are better ways to execute on this here's my first practical working version of integrating a parameterized view (ahem, table returning function) from Postgres into Rails 3.</p>
<p>(And for the curious: yes you can <tt>SELECT * FROM your_function(91) WHERE some_column > 42</tt> just like a parameterized view.)</p>
<p>So first I have my migration in which I create my function:</p>
<pre class="brush:bash">$ rails g migration CreateStockHourlyPerformanceFunction</pre>
<p>Then the actual function itself:</p>
<pre class="brush:ruby"># ./db/migrations/TIMESTAMP_create_stock_hourly_performance_function.rb

class CreateStockHourlyPerformanceFunction < ActiveRecord::Migration
  def up
    execute <<-SPROC
CREATE OR REPLACE FUNCTION stock_hourly_performance(integer) RETURNS TABLE(time_block timestamp, average integer) AS $$
SELECT
  block AS time_block
  ,MAX(block_avg)::integer AS average
FROM
  (SELECT
    date_trunc('hour', created_at) AS created_at_trunc
    ,AVG(value) AS block_avg
  FROM stock_values
  WHERE stock_id = $1
  GROUP BY date_trunc('hour', created_at)) AS x,
  (SELECT
    ('today'::date+'1 hour'::interval*q)::timestamp AS block
  FROM generate_series(0, extract('hour' from localtimestamp)::integer) AS q) AS y
WHERE created_at_trunc > block - '1 hour'::interval AND created_at_trunc <= block
GROUP BY 1 ORDER BY 1
$$ LANGUAGE SQL;
SPROC
  end

  def down
    execute "DROP FUNCTION IF EXISTS stock_hourly_performance(integer)"
  end
end</pre>
<p>Then don't forget to migrate!</p>
<pre class="brush:bash">$ rake db:migrate
$ RAILS_ENV=test rake db:migrate</pre>
<p>And then the other interesting part - how do we integrate with the Rails environment?  I chose not to use ActiveRecord because it doesn't make a lot of sense here.  I have a feeling I'd get better results if I went with <a href="http://datamapper.org/">DataMapper</a> but I'm not ready to configure another data access layer just yet.  Also it turns out that hourly performance won't be the only time we need the Performance class - this class will gain some more static constructor methods over time as the project evolves.</p>
<pre class="brush:ruby"> # ./models/performance.rb
class Performance
  attr_accessor :time_block, :average
  def initialize(time_block, avg)
    @time_block = time_block.is_a?(DateTime) ? time_block : DateTime.parse(time_block)
    @average = avg.to_i
  end
  class << self
    def hourly_for_stock(stock_id)
      result = ActiveRecord::Base.connection.execute("SELECT * FROM stock_hourly_performance(#{stock_id})")
      if result.count == 0
        stock = Stock.select(:par_value).find(stock_id)
        return [Performance.new(DateTime.now.at_beginning_of_day, stock.par_value)]
      end
      result.map { |r| Performance.new(r["time_block"], r["average"]) }
    end
  end
end</pre>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/1S6KGV6_mbo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/04/09/postgres-table-value-functions-and-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/04/09/postgres-table-value-functions-and-rails-3/</feedburner:origLink></item>
		<item>
		<title>Postgres and relative temporal functions</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/nUhfdEC_Xzg/</link>
		<comments>http://www.deploymentzone.com/2012/04/08/postgres-and-relative-temporal-functions/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 13:52:56 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=344</guid>
		<description><![CDATA[Average values hourly using Postgres.]]></description>
			<content:encoded><![CDATA[<p>I'm quickly developing a prototype application and one of the things I needed to do was calculate the hourly average of a given stock in one hour blocks.  </p>
<p>The table is pretty simplistic in that it has a <tt>stock_id</tt> foreign key, a <tt>value</tt> field (representing the current value at that point in time), and of course the <tt>created_at</tt> timestamp field.</p>
<p>Here's my first naive attempt using Postgres:</p>
<pre class="brush:sql">SELECT
	block
	,MAX(block_avg) AS max_avg
FROM
	(SELECT
		date_trunc('hour', created_at) AS created_at_trunc
		,AVG(value) AS block_avg
	FROM stock_values GROUP BY date_trunc('hour', created_at)) AS x,
	(SELECT
		('today'::date+'1 hour'::interval*q)::timestamp AS block
	FROM generate_series(0, extract('hour' from localtimestamp)::integer) AS q) AS y
WHERE created_at_trunc > block - '1 hour'::interval AND created_at_trunc <= block
GROUP BY 1 ORDER BY 1</pre>
<p>I worked into this solution beginning with a mailing list post I found <a href="http://archives.postgresql.org/pgsql-novice/2007-03/msg00002.php">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/nUhfdEC_Xzg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/04/08/postgres-and-relative-temporal-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/04/08/postgres-and-relative-temporal-functions/</feedburner:origLink></item>
		<item>
		<title>Database-less ActiveRecord for Adauth</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/9md7-WSLGBk/</link>
		<comments>http://www.deploymentzone.com/2012/03/12/database-less-activerecord-for-adauth/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 23:58:07 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[activedirectory]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=340</guid>
		<description><![CDATA[Model class that inherits from ActiveRecord::Base but does not back to the database.]]></description>
			<content:encoded><![CDATA[<p>I'm using the <a href="https://github.com/Arcath/Adauth">Adauth</a> gem to perform authentication against our Active Directory for a site that backs to an HBase cluster.  At this point we're not really concerned with storing additional user data, we just want the authentication functionality.</p>
<p>It'd be pretty easy to create a login form with no model except then I'd have to handle exceptional situations (validation!) outside of the typical flow which makes skipping the model ultimately just cost me extra time in the form of more work.  I'm also using <a href="https://github.com/justinfrench/formtastic">Formtastic</a>, specifically <a href="https://github.com/mjbellantoni/formtastic-bootstrap">Bootstrap-Formtastic</a>, and I really like consistency in my application.</p>
<p>So based on <a href="http://adrianhosey.blogspot.com/2009/01/rails-database-less-activerecord-models.html">this article</a> I implemented a database-less ActiveRecord model so I could utilize <tt>semantic_form_for</tt> and remain consistent with the rest of my application.</p>
<pre class="brush:ruby;">#./app/controllers/sessions_controller.rb
class SessionsController < AdAuthController
  before_filter :check_authentication, :except => [ :new, :create, :destroy ]
  ⋮
  class LoginUser < ActiveRecord::Base
    validates :username, :presence => true
    validates :password, :presence => true

    def self.columns
      @columns ||= []
    end
    def self.column(name, sql_type = nil, default = nil, null = true)
      columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
    end

    column :username, :string
    column :password, :string
  end
end
</pre>
<p>And since I'm using an embedded class its important to remember to specify the correct symbol in the parameters:</p>
<pre class="brush:ruby;">#./app/controllers/sessions_controller.rb
  ⋮
  def create
    @login_user = LoginUser.new(params[:sessions_controller_login_user])
    ⋮
  end
  ⋮
</pre>
<p>Because we are backing to a HBase cluster I expect this isn't the last time I'll need to use this approach on our project.</p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/9md7-WSLGBk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/03/12/database-less-activerecord-for-adauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/03/12/database-less-activerecord-for-adauth/</feedburner:origLink></item>
		<item>
		<title>Rake task to convert ERb to Haml</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/DoP3yEeX7us/</link>
		<comments>http://www.deploymentzone.com/2012/03/12/rake-task-to-convert-erb-to-haml/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 16:44:11 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=337</guid>
		<description><![CDATA[Rake task for converting all the ERb files to Haml files in a Rails project.]]></description>
			<content:encoded><![CDATA[<p>Pretty much need this with every new Rails project I create if only to convert the <tt>application.html.erb</tt> to Haml (for no other reason than to appease my sense of order).</p>
<p>After creating a new Rails project, in the Gemfile:</p>
<pre class="brush:ruby;">#./Gemfile
⋮
gem 'haml' # you probably have already done this
group :development do
  gem 'haml-rails' # you'll want this so all subsequent views are generated using Haml
  gem 'hpricot'
end
⋮
</pre>
<p>Then create a new <tt>lib/tasks/erb2haml.rake</tt> Rake task:</p>
<pre class="brush:ruby;">#./lib/tasks/erb2haml.rake
desc "Creates haml files for each of the erb files found under views (skips existing)"
task :erb2haml do
  from_path = File.join(File.dirname(__FILE__), '..', '..', 'app', 'views')
  Dir["#{from_path}/**/*.erb"].each do |file|
    puts file
    # for each .erb file in the path, convert it & output to a .haml file
    output_file = file.gsub(/\.erb$/, '.haml')
    `bundle exec html2haml -ex #{file} #{output_file}` unless File.exist?(output_file)
  end
end
</pre>
<p>Now don't forget that its <strong>not</strong> <tt>rake erb2html</tt>, its <tt>rake erb2haml</tt>!</p>
<p>Originally built this task for each project based on <a href="http://databasically.com/2010/09/19/converting-erb-to-haml-in-rails3/">this post</a>.</p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/DoP3yEeX7us" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/03/12/rake-task-to-convert-erb-to-haml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/03/12/rake-task-to-convert-erb-to-haml/</feedburner:origLink></item>
		<item>
		<title>Solarized, vim, 256 colors, Terminal.app, and OSX Lion</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/1bH6khYC6V0/</link>
		<comments>http://www.deploymentzone.com/2012/03/08/solarized-vim-256-colors-terminal-app-and-osx-lion/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 19:21:55 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[solarized]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=334</guid>
		<description><![CDATA[Solarized theme for vim on OS X Lion with Terminal.app.]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://ethanschoonover.com/solarized">Solarized</a> for all my editors but had the hardest time trying to figure out why vim in terminal mode had no syntax highlighting.</p>
<p>Fortunately the fix is incredibly easy [thanks to my co-worker] and probably well known to many OS X vim users relying on Terminal.app: In your Terminal preferences (⌘,) under Settings > Advanced tab set Declare terminal as: to "xterm-256color".  Restart your terminal sessions and 256 color themes will now work.</p>
<p>I figured out what the problem was from the excellent Xoria256 color theme which helpfully reports when your terminal is not running in 256 color mode with a message during vim startup...</p>
<pre class="brush:bash;">if &t_Co != 256 && ! has("gui_running")
  echomsg ""
  echomsg "err: please use GUI or a 256-color terminal (so that t_Co=256 could be set)"
  echomsg ""
  finish
endif</pre>
<p>As this is for OS X Lion's Terminal.app you won't need SIMBL or any other hacks to get this working.</p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/1bH6khYC6V0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/03/08/solarized-vim-256-colors-terminal-app-and-osx-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/03/08/solarized-vim-256-colors-terminal-app-and-osx-lion/</feedburner:origLink></item>
		<item>
		<title>Project level .pryrc</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/7Nq61p8xwhA/</link>
		<comments>http://www.deploymentzone.com/2012/01/22/project-level-pryrc/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 18:56:12 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[pry]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=327</guid>
		<description><![CDATA[Building off my previous ~/.pryrc I wanted to automatically load up my core project Ruby file, spec_helper.rb, and fire off some initialization routines whenever I start a new Pry session in my project's directory.
Because the contents of the local directory's .pryrc is evaluated before the :before_session hook from ~/.pryrc timing is a bit more delicate. [...]]]></description>
			<content:encoded><![CDATA[<p>Building off my previous <tt>~/.pryrc</tt> I wanted to automatically load up my core project Ruby file, <tt>spec_helper.rb</tt>, and fire off some initialization routines whenever I start a new Pry session in my project's directory.</p>
<p>Because the contents of the local directory's <tt>.pryrc</tt> is evaluated before the <tt>:before_session</tt> hook from <tt>~/.pryrc</tt> timing is a bit more delicate.  I get around this by creating a custom function named <tt>_pry_before_session</tt> (but you could name it anything you want really) and have the <tt>~/.pryrc</tt>'s <tt>before_session</tt> hook execute it if it exists.</p>
<p>So my project's <tt>.pryrc</tt>:</p>
<pre class="brush:ruby;">#~/Projects/ActiveAvro/.pryrc
def _pry_before_session
  require 'active_avro'
  require 'spec_helper'
  ActiveAvroHelper.initialize
end
</pre>
<p>And my updated <tt>~/.pryrc</tt> looks like this:</p>
<pre class="brush:ruby;">#~/.pryrc
require 'interactive_editor'

Pry.config.editor = "mate"
# add the current directories /lib and /spec directories to the path if they exist
before_session = Proc.new do |out, target, _pry_|
  dir = `pwd`.chomp
  %w(lib spec test).map{ |d| "#{dir}/#{d}" }.each { |p| $: << p unless !Dir.exists?(p) || $:.include?(p) }
  # if a local .pryrc defines a _pry_before_session function, execute it now
  send(:_pry_before_session) rescue nil
end
Pry.hooks[:before_session] = before_session
</pre>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/7Nq61p8xwhA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/01/22/project-level-pryrc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/01/22/project-level-pryrc/</feedburner:origLink></item>
		<item>
		<title>Pry and .pryrc – add ./lib and ./spec to $LOAD_PATH</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/-vbS1OTTUTI/</link>
		<comments>http://www.deploymentzone.com/2012/01/22/pry-and-pryrc-add-lib-and-spec-to-load_path/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 15:50:29 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[pry]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=324</guid>
		<description><![CDATA[Add the current directory's ./lib and ./spec paths to your $LOAD_PATH variable when you start up a new pry shell.]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://pry.github.com/">Pry</a> a lot.  If I had to develop without it I'd spend a hell of a lot more time not writing Ruby code.  Often I use Pry in a Rails project as part of <tt>rails console</tt> but I also use it with my non-Rails Ruby projects.  I wanted to get around having to append commonly used directories to the <tt>$LOAD_PATH</tt> each time I fire up a Pry session.</p>
<p>Ruby code you place in your <tt>~/.pryrc</tt> is executed when your Pry session begins.</p>
<p>Here's the relevant lines from my <tt>~/.pryrc</tt> that add the appropriate paths to <tt>$LOAD_PATH</tt> during start up.</p>
<pre class="brush:ruby;">#~/.pryrc
&#8942;
# add the current directories /lib and /spec directories to the path if they exist
before_session = Proc.new do |out, target, _pry_|
  dir = `pwd`.chomp
  %w(lib spec test).map{ |d| "#{dir}/#{d}" }.each { |p| $: << p unless !File.exist?(p) || $:.include?(p) }
end
Pry.hooks = { :before_session => before_session }
</pre>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/-vbS1OTTUTI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/01/22/pry-and-pryrc-add-lib-and-spec-to-load_path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/01/22/pry-and-pryrc-add-lib-and-spec-to-load_path/</feedburner:origLink></item>
		<item>
		<title>vim [TAB] function definition file not found (in zsh)</title>
		<link>http://feedproxy.google.com/~r/deploymentzone/~3/yXVtUiRWkuk/</link>
		<comments>http://www.deploymentzone.com/2012/01/20/vim-tab-function-definition-file-not-found-in-zsh/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 04:16:02 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[aggravations]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://www.deploymentzone.com/?p=321</guid>
		<description><![CDATA[Recently I ran into
_arguments:448: _vim_files: function definition file not found
when attempting to tab complete a file name while invoking vim.  Easy fix - at least for me: rm ~/.zcompdump.  Found the answer here.  How it got that way in the first place is another mystery. 
]]></description>
			<content:encoded><![CDATA[<p>Recently I ran into</p>
<pre>_arguments:448: _vim_files: function definition file not found</pre>
<p>when attempting to tab complete a file name while invoking vim.  Easy fix - at least for me: <tt>rm ~/.zcompdump</tt>.  Found the answer <a href="https://bbs.archlinux.org/viewtopic.php?id=37245">here</a>.  How it got that way in the first place is another mystery. </p>
<img src="http://feeds.feedburner.com/~r/deploymentzone/~4/yXVtUiRWkuk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deploymentzone.com/2012/01/20/vim-tab-function-definition-file-not-found-in-zsh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deploymentzone.com/2012/01/20/vim-tab-function-definition-file-not-found-in-zsh/</feedburner:origLink></item>
	</channel>
</rss>

