<?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>Joe Homs &#187; Ruby</title>
	<atom:link href="http://journal.bitshaker.com/articles/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://journal.bitshaker.com</link>
	<description>agent of change</description>
	<lastBuildDate>Thu, 24 Jun 2010 21:22:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>PSA: Don&#8217;t Generate Offensive Promo Codes</title>
		<link>http://journal.bitshaker.com/articles/2008/09/10/psa-dont-generate-offensive-promo-codes/</link>
		<comments>http://journal.bitshaker.com/articles/2008/09/10/psa-dont-generate-offensive-promo-codes/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 21:24:39 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://journal.bitshaker.com/?p=387</guid>
		<description><![CDATA[OK folks, I&#8217;m now on my 3rd client having problems with certain four letter words coming up in their automatically generated promo codes. It&#8217;s easy to get around this problem in a very simple way: Don&#8217;t use vowels in your promo codes if you&#8217;re using letters. No need for special filtering software or huge lists [...]]]></description>
			<content:encoded><![CDATA[<p>OK folks, I&#8217;m now on my 3rd client having problems with certain four letter words coming up in their automatically generated promo codes.  It&#8217;s easy to get around this problem in a very simple way: <strong>Don&#8217;t use vowels in your promo codes if you&#8217;re using letters</strong>.  No need for special filtering software or huge lists of banned words.  You can always add complexity later, but that simple rule will help you more than the rest.</p>
<p>If you want to get more careful, you could alternate letters and numbers, or use some other strategy.  To be kind to your users, be aware that some numbers and letters look the same to people and they will enter your codes wrong (or worse, enter in someone else&#8217;s code by mistake).</p>
<p>To help you, here&#8217;s a list of the numbers and letters I suggest people use because they won&#8217;t get them confused with each other and hopefully your system won&#8217;t create any bad words (if they do, let me know).  If you&#8217;re worried about the number of combinations you can make, just add more characters to the length of your code or allow yourself the option to generate your own special codes.</p>
<p>letters = ['B', 'C', 'D', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z']<br />
numbers = [2, 3, 4, 7, 9]</p>
<p>You could then take this and make a simple ruby method that does something like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">letters = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'B'</span>, <span style="color:#996600;">'C'</span>, <span style="color:#996600;">'D'</span>, <span style="color:#996600;">'F'</span>, <span style="color:#996600;">'H'</span>, <span style="color:#996600;">'J'</span>, <span style="color:#996600;">'K'</span>, <span style="color:#996600;">'L'</span>, <span style="color:#996600;">'M'</span>, <span style="color:#996600;">'N'</span>, <span style="color:#996600;">'P'</span>, <span style="color:#996600;">'Q'</span>, <span style="color:#996600;">'R'</span>, <span style="color:#996600;">'S'</span>, <span style="color:#996600;">'T'</span>, <span style="color:#996600;">'V'</span>, <span style="color:#996600;">'W'</span>, <span style="color:#996600;">'X'</span>, <span style="color:#996600;">'Y'</span>, <span style="color:#996600;">'Z'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
numbers = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">7</span>, <span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span>
promo_set = letters <span style="color:#006600; font-weight:bold;">|</span> numbers <span style="color:#008000; font-style:italic;"># combine arrays</span>
promo_code = promo_set.<span style="color:#9900CC;">sort_by</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#91;</span>0..14<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;"># randomize array and take the first 15 elements and make them a string</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;CS4FZLHVMPK3QJN&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://journal.bitshaker.com/articles/2008/09/10/psa-dont-generate-offensive-promo-codes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install Old Versions of Ports Using MacPorts</title>
		<link>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ports-using-macports/</link>
		<comments>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ports-using-macports/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 17:02:16 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[MacPorts is my preferred way of installing, managing, and upgrading much of the software I have on my Mac. I&#8217;m setting up a new work machine today and I need to install ruby 1.8.5 on my machine for Rails to be happy. Unfortunately, you can&#8217;t do something simple like specifying the version of the port [...]]]></description>
			<content:encoded><![CDATA[<p>MacPorts is my preferred way of installing, managing, and upgrading much of the software I have on my Mac.</p>
<p>I&#8217;m setting up a new work machine today and I need to install ruby 1.8.5 on my machine for Rails to be happy.</p>
<p>Unfortunately, you can&#8217;t do something simple like specifying the version of the port you want to install unless it&#8217;s in a local repository.</p>
<p>Fortunately, my friend Stephen Chu had this problem about a year ago and has <a href="http://www.stephenchu.com/2006/12/specifying-ruby-184-to-install-using.html">a nice procedure on how to do it</a>.  I&#8217;m going to update it for MacPorts and ruby 1.8.5 here.</p>
<p>1) Find out the svn revision number of the Portfile that has 1.8.5 by looking at:</p>
<p>http://trac.macosforge.org/projects/macports/log/trunk/dports/lang/ruby/Portfile</p>
<p>In my case it is 21127.</p>
<p>2) Set up a local port repository. In the file /opt/local/etc/macports/sources.conf, add this line before the rsync line:<br />
file:///Users/Shared/dports and create that directory.</p>
<p>3) Install the port into your local repository.</p>
<pre name="code">cd /Users/Shared/dports &#038;&#038; svn co --revision 21127 http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ lang/ruby/</pre>
<p>4) Run portindex so that ports now finds your new (old) version of ruby.</p>
<pre name="code">portindex /Users/Shared/dports</pre>
<p>5) Now you should be able to see ruby @1.8.5-p12 in addition to @1.8.6 by running:</p>
<pre name="code">port list</pre>
<p>6) Install Ruby</p>
<pre name="code">sudo port install ruby @1.8.5-p12</pre>
<p>You should be up and running now, so to check, run:</p>
<pre name="code">ruby -v</pre>
<p>You will see something like this:</p>
<pre name="code">ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.10.1]</pre>
<p>Now, if you want versions of ruby that MacPorts doesn&#8217;t have (later patchlevels for instance), you can modify the portfiles by hand, but I&#8217;ll leave that for another post.</p>
<p>Update: There is an &#8220;official&#8221; MacPorts HOWTO on installing older versions of ports here.  It may be updated in the future, so I&#8217;m linking to it here: <a href="http://trac.macports.org/wiki/howto/InstallingOlderPort">http://trac.macports.org/wiki/howto/InstallingOlderPort</a></p>
]]></content:encoded>
			<wfw:commentRss>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ports-using-macports/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Install Old Versions of Ruby Gems</title>
		<link>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ruby-gems/</link>
		<comments>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ruby-gems/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 16:37:03 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am setting up a new machine that has some old software requirements for my project this week. A quick tip if you need gems to be installed at an older version (if they are still available). Use the -v version flag to specify which version you want. sudo gem install capistrano -v 1.4.1 If [...]]]></description>
			<content:encoded><![CDATA[<p>I am setting up a new machine that has some old software requirements for my project this week.  A quick tip if you need gems to be installed at an older version (if they are still available).</p>
<p>Use the <code>-v</code> version flag to specify which version you want.</p>
<pre name="code">sudo gem install capistrano -v 1.4.1</pre>
<p>If you&#8217;ve got the newer versions of the capistrano gem, no need to fret.  You can specify the version you want to use on the command line like this:</p>
<pre name="code">cap  _1.4.1_  deploy</pre>
<p>You can alias that to something else in your bash profile by adding something like this:</p>
<pre name="code">alias cap1='cap  _1.4.1_'</pre>
]]></content:encoded>
			<wfw:commentRss>http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ruby-gems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RubyConf.new(2006)</title>
		<link>http://journal.bitshaker.com/articles/2006/10/22/rubyconf-new-2006/</link>
		<comments>http://journal.bitshaker.com/articles/2006/10/22/rubyconf-new-2006/#comments</comments>
		<pubDate>Sun, 22 Oct 2006 23:03:12 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rubyconf2006]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I attended the annual Ruby Conference this year in Denver, CO courtesy of ThoughtWorks. Lots of fun was had by all. I met up with a few people from caboose that I hadn&#8217;t seen since last year and had some friends like Evan Phoenix do some talks. The conference was a good chance to meet [...]]]></description>
			<content:encoded><![CDATA[<p>I attended the annual <a href="http://www.rubyconf.org/agenda.html">Ruby Conference</a> this year in Denver, CO courtesy of <a href="http://thoughtworks.com">ThoughtWorks</a>.  Lots of fun was had by all.  I met up with a few people from <a href="http://caboo.se">caboose</a> that I hadn&#8217;t seen since last year and had some friends like Evan Phoenix do some talks.</p>
<p>The conference was a good chance to meet up with some other ThoughtWorkers and have fun in a city I haven&#8217;t been to before.</p>
<p>I also snuck out at night to go to <a href="http://www.skyventurecolorado.com/">SkyVenture</a> and do a little indoor night-skydiving.  That was definitely an experience I&#8217;ll have to have again.</p>
<p>Until next year&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://journal.bitshaker.com/articles/2006/10/22/rubyconf-new-2006/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Weird Rails Errors?</title>
		<link>http://journal.bitshaker.com/articles/2006/04/25/getting-weird-rails-errors/</link>
		<comments>http://journal.bitshaker.com/articles/2006/04/25/getting-weird-rails-errors/#comments</comments>
		<pubDate>Tue, 25 Apr 2006 10:02:20 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Having trouble with rails on OS X? Are you getting something like this message? `require': No such file to load -- rubygems (LoadError) Then the ruby binary may have been replaced on your machine by Apple in an update recently. The fix is just to remove Apple&#8217;s version in /usr/bin or to change your bash [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble with rails on OS X?  Are you getting something like this message?</p>
<pre name="code">
`require': No such file to load -- rubygems (LoadError)
</pre>
<p>Then the ruby binary may have been replaced on your machine by Apple in an update recently.  The fix is just to remove Apple&#8217;s version in /usr/bin or to change your bash profile to load your version of ruby first.</p>
]]></content:encoded>
			<wfw:commentRss>http://journal.bitshaker.com/articles/2006/04/25/getting-weird-rails-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.324 seconds -->
