<?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>Something Unimportant &#187; Code</title>
	<atom:link href="http://www.somethingunimportant.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.somethingunimportant.com</link>
	<description>Rambling one post at a time</description>
	<lastBuildDate>Tue, 04 Jan 2011 19:43:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ejabberd and External Authentication in Ruby</title>
		<link>http://www.somethingunimportant.com/2010/12/30/ejabberd-and-external-authentication-in-ruby/</link>
		<comments>http://www.somethingunimportant.com/2010/12/30/ejabberd-and-external-authentication-in-ruby/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 17:58:56 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=236</guid>
		<description><![CDATA[I just spent far far to long trying to get an ejabberd service to authenticate with an external Ruby script. In the hopes of saving someone else the trouble I&#8217;ve thrown together this gist.]]></description>
			<content:encoded><![CDATA[<p>I just spent far far to long trying to get an ejabberd service to authenticate with an external Ruby script. In the hopes of saving someone else the trouble I&#8217;ve thrown together this gist.</p>
<p><script src="https://gist.github.com/760052.js?file=gistfile1.txt"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2010/12/30/ejabberd-and-external-authentication-in-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fun with TI&#8217;s LaunchPad starter kit</title>
		<link>http://www.somethingunimportant.com/2010/11/16/fun-with-tis-launchpad-starter-kit/</link>
		<comments>http://www.somethingunimportant.com/2010/11/16/fun-with-tis-launchpad-starter-kit/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 17:24:06 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[c/c++]]></category>
		<category><![CDATA[launchpad]]></category>
		<category><![CDATA[msp430]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=188</guid>
		<description><![CDATA[I know, it&#8217;s been a really long time since I&#8217;ve actually written anything on this blog. About a year ago I left Leapfrog Online and moved to Centro. I&#8217;m still doing similar stuff, mostly Ruby and a lot of Javascript, but recently I&#8217;ve found myself helping out with some recruiting efforts. This Friday, November 19th, [...]]]></description>
			<content:encoded><![CDATA[<p><em>I know, it&#8217;s been a really long time since I&#8217;ve actually written anything on this blog. About a year ago I left <a href="http://leapfrogonline.com" onclick="pageTracker._trackPageview('/outgoing/leapfrogonline.com?referer=');">Leapfrog Online</a> and moved to <a href="http://centro.net" onclick="pageTracker._trackPageview('/outgoing/centro.net?referer=');">Centro</a>. I&#8217;m still doing similar stuff, mostly Ruby and a lot of Javascript, but recently I&#8217;ve found myself helping out with some recruiting efforts.</em></p>
<p>This Friday, November 19th, Centro is sponsoring the <a href="http://www.illinoistech.org/page.aspx/Fall_Challenge" onclick="pageTracker._trackPageview('/outgoing/www.illinoistech.org/page.aspx/Fall_Challenge?referer=');">ITA Fall 2010 Challenge</a>. This is the first year the Illinois Technology Association is putting on the contest and I think it&#8217;s a great idea. The <a href="http://www.flyovergeeks.com/2010/10/ita-fall-challenge-keeping-top-talent-in-our-state/" onclick="pageTracker._trackPageview('/outgoing/www.flyovergeeks.com/2010/10/ita-fall-challenge-keeping-top-talent-in-our-state/?referer=');">ITA&#8217;s goal</a> is to show local college students that there are plenty of tech jobs in the area, they don&#8217;t have to move to the coasts just to nerd it up professionally. Centro is a key sponsor, and as always, we&#8217;re looking to make a splash. We&#8217;ve decided to pass out some slightly unusual conference swag.</p>
<p><a rel="attachment wp-att-220" href="http://www.somethingunimportant.com/2010/11/16/fun-with-tis-launchpad-starter-kit/box/"><img class="aligncenter size-medium wp-image-220" title="box" src="http://www.somethingunimportant.com/wp-content/uploads/2010/11/box-480x269.jpg" alt="" width="480" height="269" /></a></p>
<p>The <a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)?DCMP=launchpad&amp;HQS=Other+OT+launchpadwiki" onclick="pageTracker._trackPageview('/outgoing/processors.wiki.ti.com/index.php/MSP430_LaunchPad_MSP-EXP430G2_?DCMP=launchpad_amp_HQS=Other+OT+launchpadwiki&amp;referer=');">TI LaunchPad</a> is an extremely affordable entry into hardware development at only $4.30 a piece. The LaunchPad is very similar to the <a href="http://arduino.cc/" onclick="pageTracker._trackPageview('/outgoing/arduino.cc/?referer=');">Arduino</a> I&#8217;ve <a href="http://www.somethingunimportant.com/2009/05/04/arduino-nixie-tube-bar-graph-control-with-tlc5628cn/">blogged</a> <a href="http://www.somethingunimportant.com/2009/04/24/some-arduino-photos-and-a-better-film/">about</a> <a href="http://www.somethingunimportant.com/2009/04/23/playing-with-the-arduino/">before</a>. Unlike most Arduinos the MSP430 dev board doesn&#8217;t come completely assembled leaving the customer to solder on the pin headers. It&#8217;s a great way to save cost and make the units more customizable, but it&#8217;s definitely a barrier to entry for those new to hardware. Since we don&#8217;t know the students are that are getting these boards we decided we needed to do some assembly and, because electronics bought in bulk are so cheap we threw in some LEDs, resistors, wires and a breadboard.</p>
<p><a rel="attachment wp-att-222" href="http://www.somethingunimportant.com/2010/11/16/fun-with-tis-launchpad-starter-kit/kit/"><img class="aligncenter size-medium wp-image-222" title="kit" src="http://www.somethingunimportant.com/wp-content/uploads/2010/11/kit-480x360.jpg" alt="" width="480" height="360" /></a></p>
<p>What kind of fun would it be to just hand these students a box of parts and a random microcontroller development board? Sure they could find a <a href="http://static.sparkfun.com/images/products/Insert_Back.jpg" onclick="pageTracker._trackPageview('/outgoing/static.sparkfun.com/images/products/Insert_Back.jpg?referer=');">diagram</a> explaining how to wire up an LED with a <a href="http://www.somethingunimportant.com/?attachment_id=221">breadboard</a>, but then what? They could jump into some of the cool projects people have been sharing like this <a href="http://www.43oh.com/2010/09/launchpad-pov-air-your-message/" onclick="pageTracker._trackPageview('/outgoing/www.43oh.com/2010/09/launchpad-pov-air-your-message/?referer=');">LED POV message writer</a>, but in the spirit of the ITA Fall Challenge we wanted to give these kids both a starting point and a bit of an incentive. We&#8217;ve preprogrammed every board with our own little contest and have great prizes for the winners.</p>
<p>I can&#8217;t divulge much about our contest yet, we haven&#8217;t even passed out the boards. But as the contest progresses expect updates here, and eventually I&#8217;ll release all the code after the prizes are awarded. This is all for fun, and will hopefully be a nice, simple hardware introduction for people who might not have had the opportunity.</p>
<p>Seeing as this all came about in an effort to help us recruit more developers it would be foolish of me to not include a link to the <a href="http://centro.net/careers/were-hiring" onclick="pageTracker._trackPageview('/outgoing/centro.net/careers/were-hiring?referer=');">Centro Job Board</a>. If you have any questions or find yourself interested in one of the positions listed please email me: andrew [dot] bloom [at] centro [dot] net. I also owe a huge thank you to my teammates who helped me solder and pack all 100 of these boxes, especially Amy for picking up the beer!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2010/11/16/fun-with-tis-launchpad-starter-kit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Nixie Tube Bar Graph Control With TLC5628CN</title>
		<link>http://www.somethingunimportant.com/2009/05/04/arduino-nixie-tube-bar-graph-control-with-tlc5628cn/</link>
		<comments>http://www.somethingunimportant.com/2009/05/04/arduino-nixie-tube-bar-graph-control-with-tlc5628cn/#comments</comments>
		<pubDate>Mon, 04 May 2009 05:20:52 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[nixie tubes]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=171</guid>
		<description><![CDATA[Check out these tubes, pretty bad ass, don&#8217;t you think? With the help of Daniel Naito&#8217;s amazing project and the TI TLC5628CN 8-bit serial DAC I&#8217;ve managed to get my Arduino controlling an IN-13 tube. I&#8217;ve got simple 3 wire serial communication working with the TLC5628 (thanks Ogi Lumen), and but I&#8217;m only utilizing one [...]]]></description>
			<content:encoded><![CDATA[<p>Check out <a href="http://www.ogilumen.com/neon-graph-in13-p-99.html" onclick="pageTracker._trackPageview('/outgoing/www.ogilumen.com/neon-graph-in13-p-99.html?referer=');">these  tubes</a>, pretty bad ass, don&#8217;t you think? With the help of <a href="http://tchips.com/home/content/view/35/1/" onclick="pageTracker._trackPageview('/outgoing/tchips.com/home/content/view/35/1/?referer=');">Daniel Naito&#8217;s amazing project</a> and the TI <a href="http://parts.digikey.com/1/parts/477688-ic-oct-8-bit-d-a-conv-16-dip-tlc5628cn.html" onclick="pageTracker._trackPageview('/outgoing/parts.digikey.com/1/parts/477688-ic-oct-8-bit-d-a-conv-16-dip-tlc5628cn.html?referer=');">TLC5628CN</a> 8-bit serial DAC I&#8217;ve managed to get my Arduino controlling an IN-13 tube. I&#8217;ve got simple 3 wire serial communication working with the TLC5628 (thanks <a href="http://www.ogilumen.com/pub/fileroom/001/drivermux.zip" onclick="pageTracker._trackPageview('/outgoing/www.ogilumen.com/pub/fileroom/001/drivermux.zip?referer=');">Ogi Lumen</a>), and but I&#8217;m only utilizing one DAC right now. The nixie tubes on the left are facing up and therefore are hard to see, but they are cycling 0-9-0.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/7qRwhqH3iuw&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7qRwhqH3iuw&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2009/05/04/arduino-nixie-tube-bar-graph-control-with-tlc5628cn/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Playing with the Arduino</title>
		<link>http://www.somethingunimportant.com/2009/04/23/playing-with-the-arduino/</link>
		<comments>http://www.somethingunimportant.com/2009/04/23/playing-with-the-arduino/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 04:11:40 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[c/c++]]></category>
		<category><![CDATA[nixie tubes]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=135</guid>
		<description><![CDATA[I might have mentioned previously that I recently bought an Arduino Duemilanove. It&#8217;s pretty damn cool and I&#8217;m amazed at the amount of power you can get for such small price (and form factor). My first month or so was spent hooking it up to LED&#8217;s and the Ethernet Shield. I wasted a bunch of [...]]]></description>
			<content:encoded><![CDATA[<p>I might have mentioned previously that I recently bought an <a href="http://arduino.cc/en/Main/ArduinoBoardDuemilanove" onclick="pageTracker._trackPageview('/outgoing/arduino.cc/en/Main/ArduinoBoardDuemilanove?referer=');">Arduino Duemilanove</a>. It&#8217;s pretty damn cool and I&#8217;m amazed at the amount of power you can get for such small price (and form factor).</p>
<p>My first month or so was spent hooking it up to LED&#8217;s and the <a href="http://arduino.cc/en/Main/ArduinoEthernetShield" onclick="pageTracker._trackPageview('/outgoing/arduino.cc/en/Main/ArduinoEthernetShield?referer=');">Ethernet Shield</a>. I wasted a bunch of time on a poorly thought out messaging system. I had LED&#8217;s hooked up to PWM outputs and was controlling their brightness independently from my computer. It was a great learning experience and the perfect way to remind me how to write C. Luckily for us all, that code has been scrapped (it can probably be found at the first revision on <a href="http://github.com/abloom/arduino_messaging/commit/c2b8aca3566e36bf9062037c1800c75b3d6c5195" onclick="pageTracker._trackPageview('/outgoing/github.com/abloom/arduino_messaging/commit/c2b8aca3566e36bf9062037c1800c75b3d6c5195?referer=');">Github</a>).</p>
<p>This week I got a package from Canada. &#8220;What comes from Canada?&#8221; you might ask. Not much, but there is a place that loves to ship NOS Russian Nixie tubes. <a href="http://www.ogilumen.com" onclick="pageTracker._trackPageview('/outgoing/www.ogilumen.com?referer=');">Ogi Lumen</a> has been a pleasure to deal with, and provides a top quality <a href="http://www.ogilumen.com/nixie-nixie-driver-kits-p-92.html" onclick="pageTracker._trackPageview('/outgoing/www.ogilumen.com/nixie-nixie-driver-kits-p-92.html?referer=');">kit</a>. Assembling the Nixie Driver kit took about an hour, and getting it <a href="http://www.youtube.com/watch?v=uH0alwtht0A" onclick="pageTracker._trackPageview('/outgoing/www.youtube.com/watch?v=uH0alwtht0A&amp;referer=');">up and running</a> was smooth as can be. Ogi Lumen provides a concise and well written library with only a handful of functions for the developer to learn. </p>
<p>Tomorrow I&#8217;m giving a lightning talk at work about all this. I&#8217;ve spent the better part of the evening putting together <a href="http://github.com/abloom/arduino_messaging/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/abloom/arduino_messaging/tree/master?referer=');">some code</a> to help with a demo. I&#8217;ve cleaned up the messaging protocol a bit (it still needs major refactoring, but I&#8217;ve opted to keep it simple). Now I have a few different kinds of messages, as well as minor error handling. I&#8217;ve set up a simple way to clear the Nixie tubes, a command to left justify some digits (and continuously shift them to the right) as well as right justify the display (with no shifting). But my ace in the hole is a demo command I&#8217;ve put together that will do some cool cycling of content across the tubes.</p>
<p>Ok, so it&#8217;s still not all that exciting, eventually I&#8217;ll buy more than two tubes. First though, I have plans to conquer this beast: <a href="http://www.ogilumen.com/neon-graph-in13-p-99.html" onclick="pageTracker._trackPageview('/outgoing/www.ogilumen.com/neon-graph-in13-p-99.html?referer=');">Neon Bar Graph</a>. I&#8217;ve placed an order from <a href="http://www.digikey.com/" onclick="pageTracker._trackPageview('/outgoing/www.digikey.com/?referer=');">Digi-Key</a> for a few discrete components to get myself started, eventually building a shift register/DAC driver similar to the Ogi Lumen Nixie Tube Driver kits (probably without the cool boards though).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2009/04/23/playing-with-the-arduino/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get My Patch Added to Core</title>
		<link>http://www.somethingunimportant.com/2009/03/04/get-my-patch-added-to-core/</link>
		<comments>http://www.somethingunimportant.com/2009/03/04/get-my-patch-added-to-core/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 16:25:45 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=76</guid>
		<description><![CDATA[Help me out here. I came across what I think is a bug in Rails core. It&#8217;s a really small issue, and an even smaller patch. Seriously, it&#8217;s only two lines of code, and three new tests &#8212; as you can see in the Lighthouse Ticket. Oh, you want a description? The description I wrote [...]]]></description>
			<content:encoded><![CDATA[<p>Help me out here. I came across what I think is a bug in Rails core. It&#8217;s a really small issue, and an even smaller patch. Seriously, it&#8217;s only two lines of code, and three new tests &#8212; as you can see in the <a href="http://rails.lighthouseapp.com/projects/8994/tickets/2122-routing-with-a-blank-path_prefix-causes-a-bad-url-to-generate" onclick="pageTracker._trackPageview('/outgoing/rails.lighthouseapp.com/projects/8994/tickets/2122-routing-with-a-blank-path_prefix-causes-a-bad-url-to-generate?referer=');">Lighthouse Ticket</a>.</p>
<p>Oh, you want a description? The description I wrote in the ticket wasn&#8217;t enough? Fine, I&#8217;ll expand a bit here. First, let me state that this issue was only uncovered due to our semi-unorthodox deployment strategy. I say semi-unorthodox because I&#8217;ve never read of anyone else using a similar style, but I don&#8217;t see an alternative.</p>
<p>Here at work we build apps for two sets of users: the public and our business team. These sets of users see totally different applications; in fact, they aren&#8217;t even running on the same boxes. Think of our internal tool as a CMS and Customer Service tool. Instead of writing two applications and making them share models, we have one larger application but can control how it reacts by changing the <em>RAILS_ENV</em>. Our basic configuration contains three environments: <em>development</em>, <em>production</em> and <em>admin</em> (this is a simplification: we also have multiple test environments, but they are unimportant for the sake of this discussion).</p>
<p>To limit what can take place on each environment we have segregated our <em>routes.rb</em> like you see below.</p>
<pre class="rails" name="code">
# back end services
if %w(admin development test).include?(RAILS_ENV)
    path_prefix = (RAILS_ENV == "development") ? "admin" : "")
    map.namespace(:admin, :path_prefix => path_prefix) do |admin|
      admin.connect "/applicants/:id", :controller => "applicants", :action => "show"
    end
end

# front end site
if %w(production development test).include?(RAILS_ENV)
    map.root :controller => "applicants", :action => "new"
end
</pre>
<p>Let&#8217;s go over this routing real quick. You&#8217;ll immediately notice two blocks, the first being for &#8220;back end services&#8221; (i.e.: internal business users), and the second for the &#8220;front end site&#8221; (i.e.: the public). If you look closely you&#8217;ll see the only difference between the conditionals for each block is that the first includes the &#8220;admin&#8221; environment while the second uses the &#8220;production&#8221; environment.</p>
<p>The issue I ran into stems from line #3. When <em>path_prefix</em> is blank, RouteBuilder generates improper URLs, therefore affecting everything inside the admin namespace. </p>
<ul>
<li>When <em>path_prefix</em> is set, the admin URLs look like: <strong>/admin/applicants/1</strong></li>
<li>When <em>path_prefix</em> is blank they look like: <strong>//applicants/1</strong></li>
</ul>
<p>That extra slash is a bit of a problem with the way we deploy our &#8220;admin&#8221; environment. We use some Apache fu to map <strong>http://admin/project</strong> to the root of the application, meaning our internal users need to go to <strong>http://admin/project//applicants/1</strong>. This URL is clearly incorrect and should never be generated.</p>
<p>Without the <em>path_prefix</em> we are severely limited in our ability to run the full project in development mode. With the <em>path_prefix</em> set in &#8220;development&#8221; mode we can view the public portion of the site at <strong>http://localhost:3000/applicants/1</strong> and the private part at <strong>http://localhost:3000/admin/applicants/1</strong>. It should be noted that these two routes go to two completely different controllers, one being in the global namespace, and the other existing inside an <em>Admin</em> module.</p>
<p>Now I know if you payed attention you&#8217;re probably thinking: &#8220;Andrew, you can get around this with a simple refactor, maybe try this&#8230;&#8221;</p>
<pre class="rails" name="code">
path_prefix = (RAILS_ENV == "development") ? "admin" : nil)
</pre>
<p>Yes, you&#8217;re right, that would work: having the <em>path_prefix</em> set to <em>nil</em> is a simple solution. But, a bug is a bug, and adding an extra slash to a URL isn&#8217;t an appropriate thing to do. So please, if you made it this far and you don&#8217;t think I&#8217;m a raving loon then +1 my <a href="http://rails.lighthouseapp.com/projects/8994/tickets/2122-routing-with-a-blank-path_prefix-causes-a-bad-url-to-generate" onclick="pageTracker._trackPageview('/outgoing/rails.lighthouseapp.com/projects/8994/tickets/2122-routing-with-a-blank-path_prefix-causes-a-bad-url-to-generate?referer=');">patch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2009/03/04/get-my-patch-added-to-core/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Defaults I Like to Change</title>
		<link>http://www.somethingunimportant.com/2008/11/10/rails-defaults-i-like-to-change/</link>
		<comments>http://www.somethingunimportant.com/2008/11/10/rails-defaults-i-like-to-change/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 20:54:16 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=58</guid>
		<description><![CDATA[When working on larger projects the RAILS_ROOT/app folder structure can be a little restrictive. Lately I&#8217;ve taken to adding more sub-directories into RAILS_ROOT/app like, observers, mailers and presenters (check out ActivePresenter and Presenter Pattern if you&#8217;ve never heard of it). It&#8217;s a simple trivial addition to the folder structure that allows me to keep my [...]]]></description>
			<content:encoded><![CDATA[<p>When working on larger projects the <em>RAILS_ROOT/app</em> folder structure can be a little restrictive. Lately I&#8217;ve taken to adding more sub-directories into <em>RAILS_ROOT/app</em> like, <em>observers, mailers </em>and <em>presenters </em>(check out <a href="http://github.com/giraffesoft/active_presenter/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/giraffesoft/active_presenter/tree/master?referer=');">ActivePresenter</a> and <a href="http://blog.jayfields.com/2007/03/rails-presenter-pattern.html" onclick="pageTracker._trackPageview('/outgoing/blog.jayfields.com/2007/03/rails-presenter-pattern.html?referer=');">Presenter Pattern</a> if you&#8217;ve never heard of it). It&#8217;s a simple trivial addition to the folder structure that allows me to keep my sanity. Instead of sifting through 40+ files in the <em>models</em> folder I can quickly drill down to what I&#8217;m looking for.</p>
<p>Luckily, Rails is nice enough to have a simple mechanism to do this. Open your environment.rb file and look for the lines that read:</p>
<pre class="rails" name="code">  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )</pre>
<p>Simply un-comment the second line and replace it with something like this:</p>
<pre class="rails" name="code">  # Add additional load paths for your own custom dirs
  config.load_paths += %W( #{RAILS_ROOT}/app/clients #{RAILS_ROOT}/app/observers #{RAILS_ROOT}/app/presenters #{RAILS_ROOT}/app/mailers )</pre>
<p>Very similar to moving the Ruby files around, I have also taken to moving some of the views around, specifically, mailer views. I like to keep them near the mailer model, and not in the <em>RAILS_ROOT/app/views</em> path.</p>
<p>This change is also quite easy thanks to the extensibility of the Rails framework. Near the end of your environment.rb file add the following line:</p>
<pre class="rails" name="code">  config.action_mailer.template_root = "#{RAILS_ROOT}/app/mailers"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2008/11/10/rails-defaults-i-like-to-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tall Mocha, no toppings please</title>
		<link>http://www.somethingunimportant.com/2008/10/27/tall-mocha-no-toppings-please/</link>
		<comments>http://www.somethingunimportant.com/2008/10/27/tall-mocha-no-toppings-please/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 19:18:29 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mocha]]></category>
		<category><![CDATA[mocks]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=50</guid>
		<description><![CDATA[I finally got around to using a mocking library today at work. I chose Mocha to start, no real reason, just the first name to pop into my head. After about 15 minutes (10 reading docs, and 5 coding) I am in love. Seriously, testing has never been this easy. What would have taken me [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got around to using a mocking library today at work. I chose <a href="http://mocha.rubyforge.org/" onclick="pageTracker._trackPageview('/outgoing/mocha.rubyforge.org/?referer=');">Mocha</a> to start, no real reason, just the first name to pop into my head. After about 15 minutes (10 reading docs, and 5 coding) I am in love. Seriously, testing has never been this easy. What would have taken me at least 30 minutes to add new fixtures wihtout breaking old tests or screwing anything else up was easily solved in one to 2 lines per test case.</p>
<pre class="rails" name="code">class SupportControllerTest &lt; ActionController::TestCase
  def test_applicant_activated_view
      Applicant.any_instance.expects(:activated?).returns(:true)

      post :create, :applicant =&gt; {:last_name =&gt; "Leapfrog", :email =&gt; "sos_platform@leapfrogqa.com"}
      assert_select "ul.activated"
  end
end</pre>
<p>The first line in the above method mocks out the <em>activated?</em> method on any instance of the Applicant class. Isn&#8217;t that simple and clean? Without seeing the rest of the business logic I know it might be hard to accept why I need an entire library to help me with this simple boolean method, but trust me, <em>activated?</em> method is actually delegated to another model which is using an <em>ActiveResource</em> object to truly determine the result.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2008/10/27/tall-mocha-no-toppings-please/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prototype Scroller Object</title>
		<link>http://www.somethingunimportant.com/2008/10/03/prototype-scroller-object/</link>
		<comments>http://www.somethingunimportant.com/2008/10/03/prototype-scroller-object/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 00:20:16 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=39</guid>
		<description><![CDATA[Recently an old friend, David Moffitt, asked me to tweak some Javascript I wrote for him and his company GTTS over a year ago. Looking at it again after such a long time was scary. The code was terrible. All functions, no classes, just a mess. I rewrote it for them as a Prototype based [...]]]></description>
			<content:encoded><![CDATA[<p>Recently an old friend, David Moffitt, asked me to tweak some Javascript I wrote for him and his company <a href="http://gttsmarketing.com" onclick="pageTracker._trackPageview('/outgoing/gttsmarketing.com?referer=');">GTTS</a> over a year ago. Looking at it again after such a long time was scary. The code was terrible. All functions, no classes, just a mess. I rewrote it for them as a <a href="http://prototypejs.org/" onclick="pageTracker._trackPageview('/outgoing/prototypejs.org/?referer=');">Prototype</a> based <a href="http://prototypejs.org/api/class" onclick="pageTracker._trackPageview('/outgoing/prototypejs.org/api/class?referer=');">Class</a>. Very clean and easy. </p>
<p>The Scroller object creates a simple news ticker that nicely rotates messages, stops when you mouse over, and continues when you mouse out. Yep, thats it. Check out my <a href="http://github.com/abloom/prototype-objects/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/abloom/prototype-objects/tree/master?referer=');">github project</a>. View the comments in <a href="http://github.com/abloom/prototype-objects/tree/master/scroller.js" onclick="pageTracker._trackPageview('/outgoing/github.com/abloom/prototype-objects/tree/master/scroller.js?referer=');">scroller.js</a> for directions on how to use it. </p>
<p>Why the almost empty <a href="http://github.com" onclick="pageTracker._trackPageview('/outgoing/github.com?referer=');">github</a> project? The theory is I might one day write more Javascript and need a place to put it. So for now, only one file in that &#8220;project&#8221; but just you wait.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2008/10/03/prototype-scroller-object/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ERB templates of ERB templates</title>
		<link>http://www.somethingunimportant.com/2008/08/05/erb-templates-of-erb-templates/</link>
		<comments>http://www.somethingunimportant.com/2008/08/05/erb-templates-of-erb-templates/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 21:03:58 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=24</guid>
		<description><![CDATA[Recursion, every programmers favorite topic. Luckily that&#8217;s not what this is about, really. Today at work I was writing a Rails Generator that needed to created &#60;a href=&#8221;http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/&#8221;&#62;ERB&#60;/a&#62; templates for views. It sounded pretty simple, but I hit one stumbling point. How do I make my template an ERB template that generates an ERB template [...]]]></description>
			<content:encoded><![CDATA[<p>Recursion, every programmers favorite topic. Luckily that&#8217;s not what this is about, really. Today at work I was writing a Rails Generator that needed to created &lt;a href=&#8221;http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/&#8221;&gt;ERB&lt;/a&gt; templates for views. It sounded pretty simple, but I hit one stumbling point. How do I make my template an ERB template that generates an ERB template of its own without interpreting all of the tags? After a bit of Googling I started to get discouraged. Then I remembered Rails already does some of this in places like the scaffold generator. I opened up the source and the templates and found an ERB tag I had never seen before &lt;code&gt;&lt;%%= do_something %&gt;&lt;/code&gt;. There it was, the &#8216;%%&#8217; will tell ERB to treat this as a tag for a future run. It will remove the second % and leave you with the output you expect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2008/08/05/erb-templates-of-erb-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing Plugistrano v0.0.1</title>
		<link>http://www.somethingunimportant.com/2008/06/01/announcing-plugistrano-v001/</link>
		<comments>http://www.somethingunimportant.com/2008/06/01/announcing-plugistrano-v001/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 05:07:52 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[plugistrano]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.somethingunimportant.com/?p=17</guid>
		<description><![CDATA[Plugistrano is a little project I&#8217;ve been pondering for a while. My boss Jeff Cohen came up with the idea a few weeks ago. While in Portland at RailsConf 2008 I made some progress with it, thanks to the help of my coworker Mike. Check out the github repo. Let me know what you think, [...]]]></description>
			<content:encoded><![CDATA[<p>Plugistrano is a little project I&#8217;ve been pondering for a while. My boss <a href="http://www.softiesonrails.com/" onclick="pageTracker._trackPageview('/outgoing/www.softiesonrails.com/?referer=');pageTracker._trackPageview('/outgoing/www.softiesonrails.com/?referer=http://somethingunimportant.com.s11946.gridserver.com/wp-admin/export.php');">Jeff Cohen</a> came up with the idea a few weeks ago. While in Portland at <a href="http://railsconf.com/" onclick="pageTracker._trackPageview('/outgoing/railsconf.com/?referer=');pageTracker._trackPageview('/outgoing/railsconf.com/?referer=http://somethingunimportant.com.s11946.gridserver.com/wp-admin/export.php');">RailsConf 2008</a> I made some progress with it, thanks to the help of my coworker <a href="http://www.sepcot.com" onclick="pageTracker._trackPageview('/outgoing/www.sepcot.com?referer=');pageTracker._trackPageview('/outgoing/www.sepcot.com?referer=http://somethingunimportant.com.s11946.gridserver.com/wp-admin/export.php');">Mike</a>.</p>
<p>Check out the <a href="http://github.com/abloom/plugistrano/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/abloom/plugistrano/tree/master?referer=');pageTracker._trackPageview('/outgoing/github.com/abloom/plugistrano/tree/master?referer=http://somethingunimportant.com.s11946.gridserver.com/wp-admin/export.php');">github repo</a>. Let me know what you think, fork it, fix it and make it better.</p>
<p><em>note: I have only tested this (very briefly) with Capistrano 1.4.1. It might not work with 2.0. I will try to test it with 2.0 later</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.somethingunimportant.com/2008/06/01/announcing-plugistrano-v001/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

