<?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>Millarian &#187; Programming</title>
	<atom:link href="http://millarian.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://millarian.com</link>
	<description>Musings of a startup junkie and Ruby on Rails nerd.</description>
	<lastBuildDate>Sun, 22 Jan 2012 19:39: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>Jekyll Presentation at Ruby AZ</title>
		<link>http://millarian.com/programming/jekyll-presentation-at-ruby-az/</link>
		<comments>http://millarian.com/programming/jekyll-presentation-at-ruby-az/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 23:44:10 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2659</guid>
		<description><![CDATA[After switching from Wordpress to the Jekyll static site generator, I put together a short presentation on Jekyll to share with the Phoenix Ruby community. The slides cover some of the basics of what Jekyll is, the features it provides and a few gotchas we found along the way.]]></description>
			<content:encoded><![CDATA[<p>We recently switched from WordPress to the Jekyll static site generator at my <a href="http://flatterline.com/">Ruby development company</a>, Flatterline. So, I put together a Jekyll presentation based on that experience. Here are the slides, as presented at the <a href="http://rubyaz.org/">Phoenix Ruby meetup</a>.</p>
<div style="width:510px" id="__ss_10653919">
  <strong style="display:block;margin:12px 0 4px"><br />
    <a href="http://www.slideshare.net/Flatterline/jekyll-presentation-slides" title="Jekyll Presentation Slides" target="_blank">Jekyll Presentation Slides</a><br />
  </strong></p>
<p>  <iframe src="http://www.slideshare.net/slideshow/embed_code/10653919?rel=0" width="510" height="426" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/Flatterline" target="_blank">presentations</a> from <a href="http://flatterline.com/team/curtis-miller" target="_blank">Curtis Miller</a>
  </div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/jekyll-presentation-at-ruby-az/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arizona&#8217;s First Ruby Conference &#8211; SunnyConf 2010</title>
		<link>http://millarian.com/programming/ruby-on-rails/arizonas-first-ruby-conference-sunnyconf-2010/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/arizonas-first-ruby-conference-sunnyconf-2010/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 23:45:13 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2597</guid>
		<description><![CDATA[Arizona's first Ruby conference is happening soon. There's a great group of speakers as well as lightning talks and hacking. If you're interested in Ruby, this is a conference you won't want to miss!]]></description>
			<content:encoded><![CDATA[<p>It started as an impromptu chat about getting more Ruby sessions into events like Desert Code Camp. A small group of rubyists met in the courtyard of DeVry University after the lunch break and kicked around some ideas. It seems like only yesterday that the group, which represented about 5 Phoenix companies, was asked &#8220;<strong>Wait&#8230; what about having a Ruby conference in AZ?</strong>&#8221; Now, that idea has blossomed into a full-fledged <a rel="external" href="http://sunnyconf.com">regional Ruby conference, SunnyConf 2010</a>.</p>
<div style="float:right;">
  <iframe  src="http://www.eventbrite.com/countdown-widget?eid=769378231" frameborder="0" height="376" width="220" marginheight="0" marginwidth="0" scrolling="no" ></iframe>
</div>
<p>SunnyConf is a single-track, one day conference taking place Sept. 25th in Phoenix. There will be 8 speakers and a keynote, as well as lightning talks. There will also be time after the conference set aside for hacking. We&#8217;ve managed to pull together a great group of rubyists to share their knowledge. The speakers include:</p>
<ul>
<li><a href="http://ashkenas.com">Jeremy Ashkenas</a> (Keynote)</li>
<li><a href="http://hashrocket.com/people/view/les-hill/">Les Hill</a> &amp; <a href="http://hashrocket.com/people/view/jim-remsik/">Jim Remsik</a> of <a href="http://hashrocket.com">HashRocket</a></li>
<li><a href="http://blog.headius.com/">Charles Nutter</a></li>
<li><a href="http://github.com/bmizerany">Blake Mizerany</a></li>
<li>and <a rel="external" href="http://sunnyconf.com/#speakers">more</a>!</li>
</ul>
<p>You can find all of the date, time and location information in the widget to the right. You can also visit the <a rel="external" href="http://sunnyconf.com">official SunnyConf website</a> or just jump straight over to Eventbrite to <a rel="external" href="http://sunnyconf.eventbrite.com">register for SunnyConf</a>.</p>
<p>Late September is a great time to visit Phoenix! If you live nearby (e.g., Southern California, Nevada, Utah, Colorado, New Mexico, etc.) then we&#8217;re only a short drive, and an even shorter flight, away. If you&#8217;re outside of that area, we have a major international airport, and plane tickets should be pretty cheap <img src='http://millarian.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I encourage you to come out to Arizona in September to learn, hack and meet other rubyists. <strong>I hope to see you at the conference!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/arizonas-first-ruby-conference-sunnyconf-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE tries to be helpful when using JavaScript to set the href attribute</title>
		<link>http://millarian.com/programming/ie-tries-to-be-helpful-when-using-javascript-to-set-the-href-attribute/</link>
		<comments>http://millarian.com/programming/ie-tries-to-be-helpful-when-using-javascript-to-set-the-href-attribute/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 17:30:42 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2587</guid>
		<description><![CDATA[I have to believe that the developers behind Internet Explorer have good intentions. It might ruin my world view and trust in people if that turned out to not be the case. However, there are instances where they go too far.

In this case, Internet Explorer tries to be "helpful" by automatically setting the link text when you set the href attribute of an anchor tag. I present the details of when this will happen and how you can get around it.]]></description>
			<content:encoded><![CDATA[<p>Have you ever tried to set an anchor tag&#8217;s <code>href</code> attribute using JavaScript? It&#8217;s pretty easy, even without a JavaScript library (jQuery, Prototype, etc.). All you need to do is find (or create) the element and then set the href attribute to the desired text.</p>
<p><script src="http://gist.github.com/436998.js"></script></p>
<p>Now, try executing the following in IE:</p>
<p><script src="http://gist.github.com/437011.js"></script></p>
<p>What would you expect to be the value of <code>link.innerHTML</code>? Turns out that it is the same as the href value, &#8216;http://flatterline.com&#8217;. It seems that, on IE only, if the inner HTML of an anchor tag looks like a URL, then upon replacing the href, it will also replace the inner HTML. Try the same experiment, but with link text that does not look like a URL:</p>
<p><script src="http://gist.github.com/437016.js"></script></p>
<p>Inspecting the innerHTML value will show that it was not replaced.</p>
<p>This is a browser level quirk, so using a JavaScript library won&#8217;t save from this unless your library has specifically made a special case for this. I originally saw this when using jQuery and thought it might be a problem with the jQuery framework.</p>
<p>I think the best workaround here is that when modifying an anchor tag with JavaScript, set attributes first, then set the link text.</p>
<p><strong>What do you think? Have a different workaround or solution?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ie-tries-to-be-helpful-when-using-javascript-to-set-the-href-attribute/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE7 resize window problem</title>
		<link>http://millarian.com/programming/ie7-resize-window-problem/</link>
		<comments>http://millarian.com/programming/ie7-resize-window-problem/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 16:30:39 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2582</guid>
		<description><![CDATA[When developing for the web, if there is one browser that will not look correct, it is almost guaranteed to be a version of IE.

This was the case when I recently encountered elements that appeared to have a fixed position when they were not styled in that way. The problem was only visible on IE7 and, as I discovered, was a known bug in IE since version 6.

This article describes two different solutions to this problem.]]></description>
			<content:encoded><![CDATA[<p>While developing an embeddable JavaScript widget, I ran across a problem in IE7 recently that was pretty strange. Some of the elements on the page appeared to be fixed (i.e., <code>position: fixed</code>) when really they were not.</p>
<p>I was able to track it down to the use of <code>position: relative</code> on these particular elements. If I added <code>position: relative</code> to other elements, they would also appear to be fixed. I proceed to try relative positioning on surrounding elements, but it was only at the body level that all elements behaved as they should.</p>
<p>Armed with these clues, I was able to find a post by <a rel="external" href="http://friendlybit.com/css/ie6-resize-bug/">Emil Stenström</a> that documented the existence of this bug in IE6 and IE7 beta 2. He has a great explanation about how to recreate it. His suggestion was to add relative positioning to the body tag, but the real problem, as he explained, was the use of auto margin to center the body element.</p>
<p>Seeing as how this was an embeddable widget, I didn&#8217;t really want to have the widget affect any elements outside of itself. So I opted to advise the embedding page to add a centered div around their content and remove the centering on the body tag. This corrected the problem and, once again, all was right in the world.</p>
<p><strong>Or was it?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ie7-resize-window-problem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Honeypot Captchas for Rails</title>
		<link>http://millarian.com/programming/ruby-on-rails/honeypot-captchas-for-rails/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/honeypot-captchas-for-rails/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 23:10:03 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2571</guid>
		<description><![CDATA[Honeypot captchas are a simple, unobtrusive way to try to combat automated form spam. I packaged some work I did a few years ago using this technique in Ruby on Rails forms and created a gem.]]></description>
			<content:encoded><![CDATA[<p>A while ago, I read a few articles on the technique of honeypot captchas and thought it was a pretty simple, but interesting, technique.</p>
<p>Essentially, with honeypot captchas you add fields into public facing forms that you expect to <strong>not</strong> be filled in, then you hide them through CSS (or other means). Since spam bots don&#8217;t usually apply CSS styles, the fields are visible to them, yet styled away for normal users. And we all know how spam bots love to fill in whatever fields they find&#8230; When the form is submitted, you simply check for these honeypot captcha fields to have values. If they do, then you stop processing the request and return as if everything completed a-okay.</p>
<p>I used this technique on a site several years ago and meant to package it into a gem. This weekend, I finally checked that off my todo list! Now, I&#8217;d like your feedback on whether this is useful and what I can do to make it better. Feel free to fork the repository and mess with the code. If you add a feature, please send me a pull request. Thanks!</p>
<p>You can find the repository here: <a rel="external" href="http://github.com/curtis/honeypot-captcha">Honeypot Captcha on Github</a>.</p>
<h3>References</h3>
<ul>
<li><a rel="external" href="http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx">Honeypot Captcha by Phil Haack</a></li>
<li><a rel="external" href="http://nedbatchelder.com/text/stopbots.html">Stopping spambots with hashes and honeypots</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/honeypot-captchas-for-rails/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Rails Named Bind Variables</title>
		<link>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-named-bind-variables/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-named-bind-variables/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 16:30:28 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2549</guid>
		<description><![CDATA[Sometimes, Rails queries can get long and complicated. Using named bind variables is an easy way to give some context to the query and, when you need to supply the same value to multiple query conditions, can shorten the query parameters.]]></description>
			<content:encoded><![CDATA[<p>Have you ever come across a Ruby on Rails query that has so many conditions that it&#8217;s hard to figure out what is being replaced where? While this can be somewhat mitigated by using <a href="http://millarian.com/programming/ruby-on-rails/quick-tip-named_scope/">Rails named scopes</a>, you can also use named bind variables to make it easier to read. Named bind variables replace the question marks with symbols and you supply a hash with values for the matching symbol keys:</p>
<pre>Company.find(:first, :conditions => [
  "state = :state AND name = :name AND division = :division AND created_at > :some_date",
  { :state => :approved, :name => 'Flatterline', :division => 'First', :some_date => '2009-02-27' }
])</pre>
<p>This is also very handy when you have the same value for multiple parameters, since it will replace all matching bind variables with the value (e.g., the current time).</p>
<pre>Event.find(:first, :conditions => [
  "state = :state AND starts_at <= :now AND ends_at >= :now",
  { :state => :active, :now => Time.zone.now }
])</pre>
<h3>References</h3>
<ul>
<li><a rel="external" href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html">ActiveRecord::Base API documentation</a>
  </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-named-bind-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Cucumber Works-in-Progress</title>
		<link>http://millarian.com/programming/ruby-on-rails/quick-tip-cucumber-works-in-progress/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/quick-tip-cucumber-works-in-progress/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:30:30 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2527</guid>
		<description><![CDATA[Cucumber has a relatively new feature that allows you to tag individual scenarios as "should pass" versus "work-in-progress". Rake tasks are provided that run the two groups of tagged scenarios separately.]]></description>
			<content:encoded><![CDATA[<p>After upgrading to the latest gems, including cucumber and webrat, I noticed a deprecation message when trying to run <strong>rake features</strong>. There are new rake tasks now for running cucumber features:</p>
<p><script src="http://gist.github.com/194601.js"></script></p>
<p>So now, you can indicate which scenarios should pass and which are still be worked on, then run them separately if you like. Simply add some meta-data to your scenarios like this:</p>
<p><script src="http://gist.github.com/194602.js"></script></p>
<p>This will tag the scenario as a test that should work. If you have a work-in-progress, simply tag with <strong>@wip</strong>.</p>
<p>Read about some other <a rel="external" href="http://robots.thoughtbot.com/post/189412598/five-ridiculously-awesome-cucumber-and-webrat">ridiculously awesome cucumber and webrat features</a> on the thoughtbot blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/quick-tip-cucumber-works-in-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Rails Singularization of -ess</title>
		<link>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-singularization-of-ess/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-singularization-of-ess/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 16:30:05 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2515</guid>
		<description><![CDATA[The Ruby on Rails built-in inflections don't handle singularizing words like "business" or "address" correctly. Here's a quick way to make sure it's handled in your Rails project.]]></description>
			<content:encoded><![CDATA[<p>Have you ever created a Ruby on Rails application dealing with businesses or addresses? I&#8217;d be hard pressed to find someone who hasn&#8217;t.</p>
<p>Strangely, though, Rails does not have an inflection that deals with the singularization of these words correctly. From the command line, try singularizing the word &#8220;business&#8221;:</p>
<p><script src="http://gist.github.com/194495.js"></script></p>
<p>While this seems like a contrived situation, it&#8217;s actually not as hard to hit as you&#8217;d think (e.g., common code that needs to singularize the incoming argument). I saw this while using Acl9, a <a rel="external" href="http://github.com/be9/acl9">role-based authorization system for Rails</a>&#8230;</p>
<p><strong>Here&#8217;s a quick fix that you can add to your config/initializers/inflections.rb:</strong></p>
<p><script src="http://gist.github.com/194493.js"></script></p>
<p>You can read more about how this won&#8217;t be fixed in this <a rel="external" href="https://rails.lighthouseapp.com/projects/8994/tickets/2399-incorrect-inflectors-for-business-or-ness">ticket</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/quick-tip-rails-singularization-of-ess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Multipart Uploads in Rack for Ruby 1.9</title>
		<link>http://millarian.com/programming/ruby-on-rails/fixing-multipart-uploads-in-rack-for-ruby-1-9/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/fixing-multipart-uploads-in-rack-for-ruby-1-9/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 04:05:13 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2536</guid>
		<description><![CDATA[Describes a fatal error in Rack v1.0.0 that may need to be patched until a new version is released. If you're seeing a "invalid byte sequence in US-ASCII" error, then read on!]]></description>
			<content:encoded><![CDATA[<p>There is a slight problem in Rack 1.0.0 that causes a fatal error to be produced when uploading files <= 110K in size. You may need to patch Rack if you see the following error when uploading a file (I saw it with Paperclip):</p>
<p><script src="http://gist.github.com/197155.js"></script></p>
<p><strong>Here's what you do to patch Rack:</strong></p>
<p><script src="http://gist.github.com/197215.js"></script></p>
<p>You should now be back in business. Hopefully it won't be too long before an update is released for Rack that includes the patch.</p>
<p>Happy uploading!</p>
<h3>References</h3>
<ul>
<li><a rel="external" href="https://rails.lighthouseapp.com/projects/8994/tickets/2497-rack-in-rails-232-throws-fatal-error-with-small-uploads">Rails Ticket #2497: Rack in Rails 2.3.2 throws fatal error with small uploads</a></li>
<li><a rel="external" href="http://github.com/rack/rack/commit/44ed4640f077504a49b7f1cabf8d6ad7a13f6441">Rack commit log: Fix multipart uploads on 1.9</a></li>
<li><a rel="external" href="http://rubynyc.wordpress.com/ruby-1-9-1/paperclip-triggering-a-invalid-byte-sequence-in-us-ascii/">Ruby NYC: paperclip triggering a “invalid byte sequence in US-ASCII” ruby 1.9 rails 2.3</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/fixing-multipart-uploads-in-rack-for-ruby-1-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Named Scopes in a Rails Plugin</title>
		<link>http://millarian.com/programming/ruby-on-rails/using-named-scopes-in-a-rails-plugin/</link>
		<comments>http://millarian.com/programming/ruby-on-rails/using-named-scopes-in-a-rails-plugin/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 17:00:23 +0000</pubDate>
		<dc:creator>Curtis Miller</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://millarian.com/?p=2388</guid>
		<description><![CDATA[I encountered a problem after extracting some common functionality into a Rails plugin that contained two named scopes. It was not returning the correct results and it took me a while to figure it out. With the help of Chris Chandler we determined the cause and a solution so that the named scopes work correctly from within a Rails plugin.]]></description>
			<content:encoded><![CDATA[<p>After extracting some common functionality into a Rails plugin, I was quite pleased with the result. The code was now contained and could be used within a model with a single line. Awesome! Except, a problem cropped up that was quite strange. In production mode, we noticed that after modifying some objects to not be visible, they still appeared in the interface as visible objects. Turns out there was an insidious defect in the plugin code I extracted.</p>
<p>The plugin code in question had two named scopes: one for the visible objects and one for the non-visible. The system uses a timestamp to determine if an object is visible or not, so part of the conditions of these named scopes was to check if the object had been marked as not visible earlier than the current time.</p>
<p><script src="http://gist.github.com/151450.js"></script></p>
<p><strong>So, you see the problem, right?</strong></p>
<p>Since this code is contained within the plugin, it will be evaluated once in production mode, meaning that the time will remain whatever it was when the plugin was loaded. This will cause the strange behavior that we saw. By using a lambda, we can ensure that the code is evaluated every time it is run and not just once.</p>
<p><script src="http://gist.github.com/151452.js"></script></p>
<p>Note the use of double curly braces. The outer is for the lambda and the inner if for the hash. This is necessary for this code to work correctly.</p>
<p>Thanks to <a rel="external" href="http://chrischandler.name">Chris Chandler</a> for helping me to figure this out.</p>
<p><strong>Have you seen similar strange behavior in your Rails plugins?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://millarian.com/programming/ruby-on-rails/using-named-scopes-in-a-rails-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

