<?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/"
	>

<channel>
	<title>Paul Goscicki &#187; ruby</title>
	<atom:link href="http://paulgoscicki.com/categories/programming/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulgoscicki.com</link>
	<description>Random pieces of code, thoughts and movie reviews</description>
	<lastBuildDate>Wed, 09 May 2012 14:34:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Uninitialized constant Gem::Deprecate</title>
		<link>http://paulgoscicki.com/archives/2012/04/uninitialized-constant-gemdeprecate/</link>
		<comments>http://paulgoscicki.com/archives/2012/04/uninitialized-constant-gemdeprecate/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 16:17:12 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=405</guid>
		<description><![CDATA[If you run into this problem, which by the way usually happens after upgrading the rubygems package (in my case it was to version 1.8.21), your best bet is to upgrade the gem from the backtrace of this error. In my case it was the old passenger version 3.0.9, which was causing this problem. Upgrading [...]]]></description>
			<content:encoded><![CDATA[<p>If you run into this problem, which by the way usually happens after upgrading the rubygems package (in my case it was to version <code>1.8.21</code>), your best bet is to upgrade the gem from the backtrace of this error. In my case it was the old <a href="http://www.modrails.com/">passenger</a> version <code>3.0.9</code>, which was causing this problem. Upgrading to <code>3.0.11</code> solved it.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2012/04/uninitialized-constant-gemdeprecate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In Ruby &#8216;?&#8217; binds stronger than &#8216;or&#8217;</title>
		<link>http://paulgoscicki.com/archives/2011/10/in-ruby-binds-stronger-than-or/</link>
		<comments>http://paulgoscicki.com/archives/2011/10/in-ruby-binds-stronger-than-or/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 09:09:52 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=377</guid>
		<description><![CDATA[Found it the hard way. Improper/misleading: true or true ? "yes" : "no" => true the above is basically the same as this: true or (true ? "yes" : "no") => true The proper way: true &#124;&#124; true ? "yes" : "no" => "yes"]]></description>
			<content:encoded><![CDATA[<p>Found it the <strong>hard</strong> way.</p>
<p>Improper/misleading:</p>
<pre class="code">
true or true ? "yes" : "no"
=> true
</pre>
<p>the above is basically the same as this:</p>
<pre class="code">
true or (true ? "yes" : "no")
=> true
</pre>
<p>The <strong>proper</strong> way:</p>
<pre class="code">
true || true ? "yes" : "no"
=> "yes"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/10/in-ruby-binds-stronger-than-or/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tell bundler to install gems globally when using capistrano</title>
		<link>http://paulgoscicki.com/archives/2011/10/tell-bundler-to-install-gems-globally-when-using-capistrano/</link>
		<comments>http://paulgoscicki.com/archives/2011/10/tell-bundler-to-install-gems-globally-when-using-capistrano/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 18:00:51 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=372</guid>
		<description><![CDATA[Seems like it&#8217;s not so straightforward. Here&#8217;s the excerpt from my config/deploy.rb: require "bundler/capistrano" set :bundle_dir, "" # install into "system" gems set :bundle_flags, "--quiet" # no verbose output set :bundle_without, [] # bundle all gems (even dev &#038; test) Maybe someone finds it helpful.]]></description>
			<content:encoded><![CDATA[<p>Seems like it&#8217;s not so straightforward. Here&#8217;s the excerpt from my <code>config/deploy.rb</code>:</p>
<pre class="code">
require "bundler/capistrano"
set :bundle_dir,     ""         # install into "system" gems
set :bundle_flags,   "--quiet"  # no verbose output
set :bundle_without, []         # bundle all gems (even dev &#038; test)
</pre>
<p>Maybe someone finds it helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/10/tell-bundler-to-install-gems-globally-when-using-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painful ruby 1.9.2-p180 to 1.9.2-p290 upgrade</title>
		<link>http://paulgoscicki.com/archives/2011/10/painful-ruby-1-9-2-p180-to-1-9-2-p290-upgrade/</link>
		<comments>http://paulgoscicki.com/archives/2011/10/painful-ruby-1-9-2-p180-to-1-9-2-p290-upgrade/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 17:05:19 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=366</guid>
		<description><![CDATA[I did the recommended upgrade of my current p180 to the new p290 using rvm: $ rvm upgrade ruby-1.9.2-p180 ruby-1.9.2-p290 First annoyance &#8211; moving gems from one gemset to the new one took over 40 minutes. Have really no idea why. But after it was done, whenever I tried to run &#8216;gem&#8217; or &#8216;rake&#8217; or [...]]]></description>
			<content:encoded><![CDATA[<p>I did the recommended upgrade of my current p180 to the new p290 using rvm:</p>
<pre class="code">
$ rvm upgrade ruby-1.9.2-p180 ruby-1.9.2-p290
</pre>
<p>First annoyance &#8211; moving gems from one gemset to the new one took over 40 minutes. Have really no idea why.</p>
<p>But after it was done, whenever I tried to run &#8216;gem&#8217; or &#8216;rake&#8217; or &#8216;bundle&#8217; I got:</p>
<pre class="code">
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/guard-0.8.1.gemspec]: invalid date format in specification: "2011-09-29
00:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/json-1.6.1.gemspec]: invalid date format in specification: "2011-09-18 0
0:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/heroku-2.8.4.gemspec]: invalid date format in specification: "2011-09-23
 00:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/guard-0.8.4.gemspec]: invalid date format in specification: "2011-10-03
00:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/multi_xml-0.4.0.gemspec]: invalid date format in specification: "2011-09
-06 00:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/heroku-2.8.1.gemspec]: invalid date format in specification: "2011-09-21
 00:00:00.000000000Z"
Invalid gemspec in [/home/jkl/.rvm/gems/ruby-1.9.2-p290/specifications/metrical-0.0.7.gemspec]: invalid date format in specification: "2011-09-
11 00:00:00.000000000Z"
...
and so on...
</pre>
<p>The above is another manifestation of the YAML engine switch from Syck to Psych and all of the incompatibilities it has brought. The problem is that now you have to reinstall all of your gems, because all installed gems have wrong gemspec specification. D&#8217;oh.</p>
<p>I fixed it by running:</p>
<pre class="code">
$ rvm gemset empty
</pre>
<p>And then bundling in each project&#8230;</p>
<pre class="code">
$ bundle
</pre>
<p>Some <a href="https://github.com/rubygems/rubygems/pull/57">more</a> <a href="http://stackoverflow.com/questions/7379385/invalid-gemspec-in-and-illformed-requirement-whenever-i-create-a-new-project">reading</a> <a href="http://stackoverflow.com/questions/7379385/invalid-gemspec-in-and-illformed-requirement-whenever-i-create-a-new-project">material</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/10/painful-ruby-1-9-2-p180-to-1-9-2-p290-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug of the day</title>
		<link>http://paulgoscicki.com/archives/2011/09/bug-of-the-day/</link>
		<comments>http://paulgoscicki.com/archives/2011/09/bug-of-the-day/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 16:52:40 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=360</guid>
		<description><![CDATA[Completely bad code follows, beware. Silent error in Ruby 1.8.7: x = [:a, :b] => [:a, :b] x.slice!(:a) => nil x => [:a, :b] Explicit error (resulting in a failing test) in Ruby 1.9.2: x = [:a, :b] => [:a, :b] x.slice!(:a) TypeError: can't convert Symbol into Integer Just yet another incompatibility, but for the [...]]]></description>
			<content:encoded><![CDATA[<p>Completely <strong>bad code</strong> follows, beware.</p>
<p>Silent error in Ruby 1.8.7:</p>
<pre class="code">
x = [:a, :b]
=> [:a, :b]

x.slice!(:a)
=> nil

x
=> [:a, :b]
</pre>
<p>Explicit error (resulting in a failing test) in Ruby 1.9.2:</p>
<pre class="code">
x = [:a, :b]
=> [:a, :b]

x.slice!(:a)
TypeError: can't convert Symbol into Integer
</pre>
<p>Just yet another incompatibility, but for the better!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/09/bug-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run guard-jasmine-headless-webkit without X server</title>
		<link>http://paulgoscicki.com/archives/2011/09/run-guard-jasmine-headless-webkit-without-x-server/</link>
		<comments>http://paulgoscicki.com/archives/2011/09/run-guard-jasmine-headless-webkit-without-x-server/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 17:44:38 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=355</guid>
		<description><![CDATA[You write specs for your javascript, right? If not, you really should. jasmine-headless-webkit really helps with that. guard-jasmine-headless-webkit makes it all even more enjoyable, although there&#8217;s one caveat &#8211; it&#8217;s not so easy to set it all up. There is a great guide for that, but it lacks some important details on running guard-jasmine-headless-webkit without [...]]]></description>
			<content:encoded><![CDATA[<p>You write specs for your javascript, right? If not, you <a href="http://gilesbowkett.blogspot.com/2011/08/tdd-in-javascript-no-excuses.html">really</a> <a href="http://railscasts.com/episodes/261-testing-javascript-with-jasmine">should</a>.</p>
<p><a href="https://github.com/johnbintz/jasmine-headless-webkit">jasmine-headless-webkit</a> really helps with that. <a href="https://github.com/johnbintz/guard-jasmine-headless-webkit">guard-jasmine-headless-webkit</a> makes it all even more enjoyable, although there&#8217;s one caveat &#8211; it&#8217;s not so easy to set it all up.</p>
<p>There is a <a href="http://johnbintz.github.com/jasmine-headless-webkit/">great guide</a> for that, but it lacks some important details on running <code>guard-jasmine-headless-webkit</code> without graphical interface (X server).</p>
<p>Assuming you already have Xvfb installed, execute this command to run Xvfb in the background:</p>
<pre class="code">
Xvfb :0 -screen 0 1024x768x24 > /dev/null 2>&#038;1 &#038;
</pre>
<p>And then you need to setup the <code>DISPLAY</code> shell variable in order for <code>guard-jasmine-headless-webkit</code> to automatically connect to our virtual frame buffer. Here&#8217;s the excerpt from my <a href="https://github.com/pjg/dotfiles/blob/master/.bash_profile">.bash_profile</a> (it first checks if there is Xvfb running on display :0 and only then sets the DISPLAY variable):</p>
<pre class="code">
xdpyinfo -display :0 &#038;>/dev/null &#038;&#038; export DISPLAY=:0
</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/09/run-guard-jasmine-headless-webkit-without-x-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hash to HTML (hash2html) in Ruby</title>
		<link>http://paulgoscicki.com/archives/2011/09/hash_to_html-hash2html-in-ruby/</link>
		<comments>http://paulgoscicki.com/archives/2011/09/hash_to_html-hash2html-in-ruby/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 16:23:37 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=346</guid>
		<description><![CDATA[I needed to output a Hash as a nested HTML structure. Googling didn&#8217;t find any satisfactory results, so I decided to roll my own. UL/LI tags seemed like the best choice. It was a nice exercise in recursion. The result is a function, which outputs a nicely indented HTML. Note, however, that it&#8217;s a very [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to output a Hash as a nested HTML structure. Googling didn&#8217;t find any satisfactory results, so I decided to roll my own. UL/LI tags seemed like the best choice. It was a nice exercise in recursion.</p>
<p>The result is a function, which outputs a nicely indented HTML. Note, however, that it&#8217;s a very basic solution. It doesn&#8217;t cope well with anything other than Strings and Numbers (unless your objects support a nice <code>to_s</code> method).</p>
<pre class="code">
# Prints nested Hash as a nested &lt;ul&gt; and &lt;li&gt; tags
# - keys are wrapped in &lt;strong&gt; tags
# - values are wrapped in &lt;span&gt; tags
def HashToHTML(hash, opts = {})
  return if !hash.is_a?(Hash)

  indent_level = opts.fetch(:indent_level) { 0 }

  out = &quot; &quot; * indent_level + &quot;&lt;ul&gt;\n&quot;

  hash.each do |key, value|
    out += &quot; &quot; * (indent_level + 2) + &quot;&lt;li&gt;&lt;strong&gt;#{key}:&lt;/strong&gt;&quot;

    if value.is_a?(Hash)
      out += &quot;\n&quot; + HashToHTML(value, :indent_level =&gt; indent_level + 2) + &quot; &quot; * (indent_level + 2) + &quot;&lt;/li&gt;\n&quot;
    else
      out += &quot; &lt;span&gt;#{value}&lt;/span&gt;&lt;/li&gt;\n&quot;
    end
  end

  out += &quot; &quot; * indent_level + &quot;&lt;/ul&gt;\n&quot;
end
</pre>
<p>Who knows, maybe someone somewhere finds it useful.</p>
<p><strong>Update:</strong> much more <a href="https://gist.github.com/1196800">concise solution</a> by <a href="http://chastell.net/">Piotr Szotkowski</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/09/hash_to_html-hash2html-in-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My first pull request to a public project has been accepted</title>
		<link>http://paulgoscicki.com/archives/2011/08/my-first-pull-request-to-a-public-project-has-been-accepted/</link>
		<comments>http://paulgoscicki.com/archives/2011/08/my-first-pull-request-to-a-public-project-has-been-accepted/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 07:02:49 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=335</guid>
		<description><![CDATA[It was a small but important patch to the i18n gem&#8216;s pluralization rules for the Polish language. Really made my day. Thanks Krzysztof!]]></description>
			<content:encoded><![CDATA[<p>It was a <a href="https://github.com/svenfuchs/i18n/commit/4907d0cd866c23bd">small but important patch</a> to the <a href="https://github.com/svenfuchs/i18n">i18n gem</a>&#8216;s pluralization rules for the Polish language.</p>
<p>Really made my day. Thanks <a href="http://knapo.net">Krzysztof</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/08/my-first-pull-request-to-a-public-project-has-been-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hash#fetch</title>
		<link>http://paulgoscicki.com/archives/2011/08/hashfetch/</link>
		<comments>http://paulgoscicki.com/archives/2011/08/hashfetch/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 08:51:57 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=326</guid>
		<description><![CDATA[{}.fetch(:a) { 0 } => 0 I think it&#8217;s really beautiful. Oh, and it&#8217;s Ruby, btw. Update: this is even better: {}.fetch(:a) { {} } => {}]]></description>
			<content:encoded><![CDATA[<pre class="code">
{}.fetch(:a) { 0 }
=> 0
</pre>
<p>I think it&#8217;s really beautiful. Oh, and it&#8217;s <a href="http://www.ruby-doc.org/core/classes/Hash.html#M000728">Ruby</a>, btw.</p>
<p><strong>Update</strong>: this is even better:</p>
<pre class="code">
{}.fetch(:a) { {} }
=> {}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/08/hashfetch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>hookup is the shit!</title>
		<link>http://paulgoscicki.com/archives/2011/06/hookup-is-the-shit/</link>
		<comments>http://paulgoscicki.com/archives/2011/06/hookup-is-the-shit/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 19:41:14 +0000</pubDate>
		<dc:creator>Paul Goscicki</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://paulgoscicki.com/?p=319</guid>
		<description><![CDATA[This is simply amazing: $ g pull Already up-to-date. $ g co edge Switched to branch 'edge' == AddFileTypeToSong: migrating ============================================== -- add_column(:songs, :file_type, :string) -> 0.0048s == AddFileTypeToSong: migrated (0.1380s) ===================================== $ g rebase master Current branch edge is up to date. $ g co master Switched to branch 'master' == AddFileTypeToSong: reverting ============================================== [...]]]></description>
			<content:encoded><![CDATA[<p>This is simply amazing:</p>
<pre class="code">
$ g pull
Already up-to-date.

$ g co edge
Switched to branch 'edge'
==  AddFileTypeToSong: migrating ==============================================
-- add_column(:songs, :file_type, :string)
   -> 0.0048s
==  AddFileTypeToSong: migrated (0.1380s) =====================================

$ g rebase master
Current branch edge is up to date.

$ g co master
Switched to branch 'master'
==  AddFileTypeToSong: reverting ==============================================
-- remove_column(:songs, :file_type)
   -> 0.1674s
==  AddFileTypeToSong: reverted (0.1679s) =========================
</pre>
<p>Oh, and it will bundle automatically for you as well, so don&#8217;t hesitate and <a href="https://github.com/tpope/hookup">hookup your Rails project</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://paulgoscicki.com/archives/2011/06/hookup-is-the-shit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

