<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>ahabman</title>
	
	<link>http://www.ahabman.com/blog</link>
	<description />
	<pubDate>Mon, 29 Jun 2009 12:59:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>© </copyright>
		<managingEditor>andy@ahabman.com ()</managingEditor>
		<webMaster>andy@ahabman.com()</webMaster>
		<category>music</category>
		<ttl>1440</ttl>
		<itunes:keywords />
		<itunes:subtitle />
		<itunes:summary />
		<itunes:author />
		<itunes:category text="Society &amp; Culture" />
		<itunes:owner>
			<itunes:name />
			<itunes:email>andy@ahabman.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.ahabman.com/blog/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.ahabman.com/blog/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>ahabman</title>
			<link>http://www.ahabman.com/blog</link>
			<width>144</width>
			<height>144</height>
		</image>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Ahabman" type="application/rss+xml" /><item>
		<title>Splash</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/sLqrXUy7nD8/</link>
		<comments>http://www.ahabman.com/blog/2009/06/splash/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 12:59:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=53</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2009/06/splash/feed/</wfw:commentRss>
			
<itunes:duration>00:01:01</itunes:duration>
		<itunes:subtitle>Splash</itunes:subtitle>
		<itunes:summary />
		<itunes:keywords>music</itunes:keywords>
		<itunes:author>andy@ahabman.com</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	<feedburner:origLink>http://www.ahabman.com/blog/2009/06/splash/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/Ahabman/~5/oew0bOJB280/Splash.mp3" length="1" type="audio/mpeg" /><feedburner:origEnclosureLink>http://www.ahabman.com/blog/podpress_trac/feed/53/0/Splash.mp3</feedburner:origEnclosureLink></item>
		<item>
		<title>Ruby Duration</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/Y2abpJf833Q/</link>
		<comments>http://www.ahabman.com/blog/2009/06/ruby-duration/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:02:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=39</guid>
		<description><![CDATA[Duration.new recieves a string describing a duration of time, and converts it into:  seconds, and a standard readable format.
Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format.
Usage:
Passing a String

duration = Duration.new(&#34;2weeks 8 hr 30m&#34;)
duration.seconds  # =&#62; 1240200
duration.readable  # =&#62; &#34;2 weeks, 8 hours and 30 [...]]]></description>
			<content:encoded><![CDATA[<a href="http://www.ahabman.com/blog/wp-content/plugins/download-monitor/download.php?id=1">DOWNLOAD Duration</a> (44.42 KB zip with documentation) <br><br>
<p>Duration.new recieves a string describing a duration of time, and converts it into:  seconds, and a standard readable format.<br />
Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format.</p>
<p>Usage:</p>
<p>Passing a String</p>
<pre class="brush: ruby;">
duration = Duration.new(&quot;2weeks 8 hr 30m&quot;)
duration.seconds  # =&gt; 1240200
duration.readable  # =&gt; &quot;2 weeks, 8 hours and 30 mins&quot;
</pre>
<p>Passing an Fixnum (of seconds)</p>
<pre class="brush: ruby;">
duration = Duration.new(1240200)
duration.readable  # =&gt; &quot;2 weeks, 8 hours and 30 mins&quot;
</pre>
<p>Example valid input strings<br />
&#8220;2 weeks&#8221;, &#8220;2wks&#8221;, &#8220;2w&#8221;,<br />
&#8220;8h&#8221;, &#8220;8 hrs&#8221;,&#8221;8 hours&#8221;,<br />
&#8220;30m&#8221;, &#8220;0:30&#8243;, &#8220;30 minutes&#8221;, &#8220;30min&#8221;,<br />
&#8220;2 weeks, 8 hours and 30 minutes&#8221;, &#8220;2w 8h 30m&#8221;,  &#8220;2w 8:30&#8243;,<br />
&#8220;4 hours 30 minutes&#8221;, &#8220;4 hours and 30m&#8221;, &#8220;4h 30min&#8221;, &#8220;4:30&#8243;, &#8220;4.5&#8243;,  &#8220;4.50&#8243;, &#8220;4h, 30 min&#8221;, &#8220;4.5 hours&#8221;, &#8220;4.50h&#8221;</p>
<p>http://ahabman.com added functionallity, extended and mashed-up  http://stackoverflow.com/questions/657309/how-to-parse-days-hours-minutes-seconds-in-ruby  and  http://www.postal-code.com/binarycode/2007/04/04/english-friendly-timespan/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2009/06/ruby-duration/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2009/06/ruby-duration/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>rails template</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/w8gJv9COnHc/</link>
		<comments>http://www.ahabman.com/blog/2009/03/rails-template/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 04:14:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=37</guid>
		<description><![CDATA[Usage $ rails app_name -m ./ahabman_template.rb


run &#34;rm README&#34;
run &#34;rm public/index.html&#34;
run &#34;rm public/favicon.ico&#34;
run &#34;rm public/robots.txt&#34;
run &#34;rm -f public/javascripts/*&#34;

gem 'ruby-openid', :lib =&#62; 'openid'
rake(&#34;gems:install&#34;, :sudo =&#62; true)

plugin &#34;kamui_restful_authentication&#34;, :git =&#62; 'git://github.com/kamui/restful-authentication.git'
plugin 'exception_notifier', :git =&#62; 'git://github.com/rails/exception_notification.git'
plugin 'open_id_authentication', :git =&#62; 'git://github.com/rails/open_id_authentication.git'
#plugin 'asset_packager', :git =&#62; 'http://synthesis.sbecker.net/pages/asset_packager'
plugin 'role_requirement', :git =&#62; 'git://github.com/timcharper/role_requirement.git'
#plugin 'acts_as_taggable_redux', :git =&#62; 'http://github.com/geemus/acts_as_taggable_redux/tree/master'
#plugin 'restful-authentication', :git =&#62; 'git://github.com/technoweenie/restful-authentication.git'

generate(&#34;authenticated user sessions --include-activation [...]]]></description>
			<content:encoded><![CDATA[<p>Usage $ rails app_name -m ./ahabman_template.rb</p>
<pre class="brush: ruby;">

run &quot;rm README&quot;
run &quot;rm public/index.html&quot;
run &quot;rm public/favicon.ico&quot;
run &quot;rm public/robots.txt&quot;
run &quot;rm -f public/javascripts/*&quot;

gem 'ruby-openid', :lib =&gt; 'openid'
rake(&quot;gems:install&quot;, :sudo =&gt; true)

plugin &quot;kamui_restful_authentication&quot;, :git =&gt; 'git://github.com/kamui/restful-authentication.git'
plugin 'exception_notifier', :git =&gt; 'git://github.com/rails/exception_notification.git'
plugin 'open_id_authentication', :git =&gt; 'git://github.com/rails/open_id_authentication.git'
#plugin 'asset_packager', :git =&gt; 'http://synthesis.sbecker.net/pages/asset_packager'
plugin 'role_requirement', :git =&gt; 'git://github.com/timcharper/role_requirement.git'
#plugin 'acts_as_taggable_redux', :git =&gt; 'http://github.com/geemus/acts_as_taggable_redux/tree/master'
#plugin 'restful-authentication', :git =&gt; 'git://github.com/technoweenie/restful-authentication.git'

generate(&quot;authenticated user sessions --include-activation --include-forgot-password --email-as-login&quot;)
generate(&quot;roles&quot;, &quot;Role User&quot;)

#rake('acts_as_taggable:db:create')
rake(&quot;open_id_authentication:db:create&quot;)
rake('db:migrate')

route &quot;map.root :controller =&gt; 'sessions', :action =&gt; 'signup' &quot;

run &quot;echo generated from ahabman_template &gt; README&quot;
run &quot;cp config/database.yml config/example_database.yml&quot;

#if yes?(&quot;Do you want this thing?&quot;)
# ...
#end

#my_var = ask(&quot;was up&quot;)
#generate :something, my_var

puts &quot;SUCCESS!&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2009/03/rails-template/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2009/03/rails-template/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>ruby on rails - has and belongs to many view plugin</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/lDhdYxHiB20/</link>
		<comments>http://www.ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 12:59:27 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=35</guid>
		<description><![CDATA[So I&#8217;ll never have to write another has_and_belongs_to_many view again, here&#8217;s a plugin that dynamically makes 2 &#60;ul&#62; lists which you drag and drop both ways to manage the association.
http://svn.ahabman.com/public/many_to_many_view/
From the readme:
Assumming you have an @project var and you want to associate people with it.
&#60;div id="m2m_container"&#62;
&#60;%= render :partial =&#62; "shared/m2m", :locals =&#62; {
:thing =&#62; @project,
:association [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ll never have to write another has_and_belongs_to_many view again, here&#8217;s a plugin that dynamically makes 2 &lt;ul&gt; lists which you drag and drop both ways to manage the association.</p>
<p><a href="http://svn.ahabman.com/public/many_to_many_view/">http://svn.ahabman.com/public/many_to_many_view/</a></p>
<p>From the readme:</p>
<p>Assumming you have an @project var and you want to associate people with it.</p>
<pre>&lt;div id="m2m_container"&gt;</pre>
<pre>&lt;%= render :partial =&gt; "shared/m2m", :locals =&gt; {</pre>
<pre>:thing =&gt; @project,</pre>
<pre>:association =&gt; 'people',</pre>
<pre>:association_attr =&gt; 'first_name' }   %&gt;</pre>
<pre>&lt;/div&gt;</pre>
<p>:thing take the current object<br />
:association takes the pluralized association, a string.<br />
:association_attr takes the attribute of the associated object that will be displayed.</p>
<p><a href="http://www.ahabman.com/blog/wp-content/uploads/2008/10/many-to-many-view-plugin.png"><img class="alignnone size-medium wp-image-36" title="many-to-many-view-plugin" src="http://www.ahabman.com/blog/wp-content/uploads/2008/10/many-to-many-view-plugin.png" alt="" width="471" height="253" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/10/ruby-on-rails-has-and-belongs-to-many-view-plugin/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>You can’t use class variables in rails.</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/WNbFZ7bVmvE/</link>
		<comments>http://www.ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 12:51:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=34</guid>
		<description><![CDATA[You can&#8217;t use class variables in rails.  Unless you&#8217;d like to develop in production mode (specifically with config.cache_classes = true).  In development mode all classes are reloaded on each request, which clears all class variables.
I had the perfect place to use them - while running a mass synchronization, and needing to store the timestamp (I [...]]]></description>
			<content:encoded><![CDATA[<p>You can&#8217;t use class variables in rails.  Unless you&#8217;d like to develop in production mode (specifically with config.cache_classes = true).  In development mode all classes are reloaded on each request, which clears all class variables.</p>
<p>I had the perfect place to use them - while running a mass synchronization, and needing to store the timestamp (I couldn&#8217;t use the latest last_updated from each record).  It worked perfect in ./script/console but failed entirely through the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/10/you-cant-use-class-variables-in-rails/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>ruby csv to structured hash</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/v9OR-5kl7gs/</link>
		<comments>http://www.ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 20:29:02 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=31</guid>
		<description><![CDATA[I had a csv like this:



object
color
flavor
shape


apple
red
sweet
round


banana
yellow
sweet
long


lemon
yellow
sour
round



and I wanted a ruby hash structured like this:

{
'apple'=&#62; { 'color'=&#62;'red',  'flavor'=&#62;'sweet', 'shape'=&#62;'round'},
'banana'=&#62; {  'color'=&#62;'yellow',  'flavor'=&#62;'sweet', 'shape'=&#62;'long'},
'lemon'=&#62; {   'color'=&#62;'yellow',  'flavor'=&#62;'sour', 'shape'=&#62;'round'}
}

So I wrote this, which does the job:

require &#34;faster_csv&#34;

def csv_to_structured_hash
	arr_of_arrs = FasterCSV.read( 'your.csv' )
	stuff = {}
	header = arr_of_arrs.shift
		arr_of_arrs.each_with_index do &#124;row, i&#124;
		thing = { row[0] =&#62; {} }
			header.each_with_index do &#124;col, header_index&#124;
			thing[ [...]]]></description>
			<content:encoded><![CDATA[<p>I had a csv like this:</p>
<table style="height: 84px;" border="1" width="166">
<tbody>
<tr>
<th>object</th>
<th>color</th>
<th>flavor</th>
<th>shape</th>
</tr>
<tr>
<td>apple</td>
<td>red</td>
<td>sweet</td>
<td>round</td>
</tr>
<tr>
<td>banana</td>
<td>yellow</td>
<td>sweet</td>
<td>long</td>
</tr>
<tr>
<td>lemon</td>
<td>yellow</td>
<td>sour</td>
<td>round</td>
</tr>
</tbody>
</table>
<p>and I wanted a ruby hash structured like this:</p>
<pre class="brush: ruby;">
{
'apple'=&gt; { 'color'=&gt;'red',  'flavor'=&gt;'sweet', 'shape'=&gt;'round'},
'banana'=&gt; {  'color'=&gt;'yellow',  'flavor'=&gt;'sweet', 'shape'=&gt;'long'},
'lemon'=&gt; {   'color'=&gt;'yellow',  'flavor'=&gt;'sour', 'shape'=&gt;'round'}
}
</pre>
<p>So I wrote this, which does the job:</p>
<pre class="brush: ruby;">
require &quot;faster_csv&quot;

def csv_to_structured_hash
	arr_of_arrs = FasterCSV.read( 'your.csv' )
	stuff = {}
	header = arr_of_arrs.shift
		arr_of_arrs.each_with_index do |row, i|
		thing = { row[0] =&gt; {} }
			header.each_with_index do |col, header_index|
			thing[ row[0] ][ header[header_index] ] = row[ header_index]
			end
		stuff.update( thing )
		end
	return stuff
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/09/ruby-csv-to-structured-hash/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>Django Tango</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/tF55vouQ_HU/</link>
		<comments>http://www.ahabman.com/blog/2008/07/django-tango/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 17:21:05 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[music]]></category>

		<category><![CDATA[acoustic]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[grisman]]></category>

		<category><![CDATA[gypsy]]></category>

		<category><![CDATA[jazz]]></category>

		<category><![CDATA[mandolin]]></category>

		<category><![CDATA[tango]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=29</guid>
		<description><![CDATA[A Django Reinhardt and David Grisman fusion.
multitrack mandolins, nylon guitars,  and percusion.
]]></description>
			<content:encoded><![CDATA[<p>A Django Reinhardt and David Grisman fusion.</p>
<p>multitrack mandolins, nylon guitars,  and percusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/07/django-tango/feed/</wfw:commentRss>
			
<itunes:duration>00:01:01</itunes:duration>
		<itunes:subtitle>A Django Reinhardt and David Grisman fusion.

multitrack mandolins, nylon guitars,nbsp; and percusion. </itunes:subtitle>
		<itunes:summary>A Django Reinhardt and David Grisman fusion.

multitrack mandolins, nylon guitars,nbsp; and percusion.</itunes:summary>
		<itunes:keywords>music</itunes:keywords>
		<itunes:author>andy@ahabman.com</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	<feedburner:origLink>http://www.ahabman.com/blog/2008/07/django-tango/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/Ahabman/~5/IRaHRxGp7L4/Andy%20Weber%20-%20Django%20Tango.mp3" length="1" type="audio/mpeg" /><feedburner:origEnclosureLink>http://www.ahabman.com/blog/podpress_trac/feed/29/0/Andy%20Weber%20-%20Django%20Tango.mp3</feedburner:origEnclosureLink></item>
		<item>
		<title>Ruby conversion module</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/lLlyAR9tVeg/</link>
		<comments>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 12:52:11 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=26</guid>
		<description><![CDATA[This is a ruby module useful for conversions dealing with length, weight, torque.
module Convert

  def Convert.number_with_precision(number, precision=2)
    "%01.#{precision}f" % number
  rescue
    number
  end

  def Convert.mm_to_in(mm, precision=2)
    number_with_precision(mm * 0.03937, precision)
  end

  def Convert.in_to_mm(inches, precision=2)
    number_with_precision(inches / 0.03937 , precision)
  end


  def Convert.feet_to_meters(f, precision=2)
    number_with_precision( f * 0.3048, precision)
  end

  def Convert.meters_to_inches(m, precision=2)
    number_with_precision( m * [...]]]></description>
			<content:encoded><![CDATA[<p>This is a <a href="http://www.ahabman.com/blog/wp-content/uploads/2008/07/convert.rb">ruby module useful for conversions</a> dealing with length, weight, torque.</p>
<pre>module Convert</pre>
<pre></pre>
<pre>  def Convert.number_with_precision(number, precision=2)</pre>
<pre>    "%01.#{precision}f" % number</pre>
<pre>  rescue</pre>
<pre>    number</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.mm_to_in(mm, precision=2)</pre>
<pre>    number_with_precision(mm * 0.03937, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.in_to_mm(inches, precision=2)</pre>
<pre>    number_with_precision(inches / 0.03937 , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre></pre>
<pre>  def Convert.feet_to_meters(f, precision=2)</pre>
<pre>    number_with_precision( f * 0.3048, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.meters_to_inches(m, precision=2)</pre>
<pre>    number_with_precision( m * 39.37, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.meters_to_feet(m, precision=2)</pre>
<pre>    number_with_precision( m * 3.281, precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.kg_to_lbs(kg, precision=2)</pre>
<pre>    number_with_precision( kg * 2.2   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.lbs_to_kg(lbs, precision=2)</pre>
<pre>    number_with_precision( lbs / 2.2   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.nm_to_inch_pounds(nm, precision=1)</pre>
<pre>    number_with_precision( nm * 8.850   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>  def Convert.inch_pounds_to_nm(inlb, precision=1)</pre>
<pre>    number_with_precision( inlb / 8.850   , precision)</pre>
<pre>  end</pre>
<pre></pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/07/ruby-conversion-module/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>Rails redirect_to :back in Internet Explorer</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/0FBcPBb5gtk/</link>
		<comments>http://www.ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 21:03:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=25</guid>
		<description><![CDATA[Today I realized that the rails command   redirect_to :back  does not work in Internet Explorer because  redirect_to :back  depends on the HTTP_REFERER http header, which IE does not send.  I was capturing an onclick event with jQuery and was able to sending along the  current URL as a query string, which provided an easy [...]]]></description>
			<content:encoded><![CDATA[<p>Today I realized that the rails command   redirect_to :back  does not work in Internet Explorer because  redirect_to :back  depends on the HTTP_REFERER http header, which IE does not send.  I was capturing an onclick event with jQuery and was able to sending along the  current URL as a query string, which provided an easy way around this limitation.</p>
<p>In the view:</p>
<pre class="brush: javascript;">
&lt;script&gt;
    $jQuery('#myLink').click(function(){
        window.location.href = 'theDestinationPage/?current_url=' + document.location ;
    })
&lt;/script&gt;
</pre>
<p>In the controller:</p>
<pre class="brush: ruby;">
def myAction
    .....
    redirect_to params[:current_url]
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/06/rails-redirect_to-back-in-internet-explorer/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
		<item>
		<title>Rails background process - simple, fast, easy.</title>
		<link>http://feedproxy.google.com/~r/Ahabman/~3/qu3fjzuLo3M/</link>
		<comments>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/#comments</comments>
		<pubDate>Sat, 31 May 2008 22:46:12 +0000</pubDate>
		<dc:creator>andy</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.ahabman.com/blog/?p=24</guid>
		<description><![CDATA[My situation was this -

Rails 2.0 app running on slicehost (ubuntu 8.04) in passenger mod_rails
The goal was Dynamic PDF generation for a product catalog ( &#62; 100 pages)
This event had to be triggered from within the rails request / response cycle, but run outside of it
I needed the simplest, fastest, more reliable way for this [...]]]></description>
			<content:encoded><![CDATA[<p>My situation was this -</p>
<ul>
<li>Rails 2.0 app running on slicehost (ubuntu 8.04) in <a href="http://www.modrails.com/">passenger mod_rails</a></li>
<li>The goal was <a href="http://ruby-pdf.rubyforge.org/pdf-writer/">Dynamic PDF generation</a> for a product catalog ( &gt; 100 pages)</li>
<li>This event had to be triggered from within the rails request / response cycle, but run outside of it</li>
<li>I needed the simplest, fastest, more reliable way for this to happen</li>
</ul>
<p>I looked at <a href="http://backgroundrb.rubyforge.org/">BackgroundRB</a>, it is the most robust, well documented solution available.  But it was overkill since I didn&#8217;t need status feedback and my time was very limited (backgroundRB setup seems somewhat involved).  And, I wasn&#8217;t sure how it would interact with Passenger mod_rails - although <a href="http://github.com/FooBarWidget">FooBarWidget</a> mentioned on IRC that it should work as expected.</p>
<p>I looked at <a href="http://hearmesqueak.blogspot.com/2007/09/spawn-background-processing-in-rails.html">Spawn plugin</a> which supports threading and forking ruby processes.   No luck - setting it one way never ran inside mod_rails and setting it the other way tied up the request response cycle.</p>
<p>All the ruby code was in place, except for how to detach this process from the request/response cycle, when <a href="http://severnspoon.com/">severnspoon</a> provided this<br />
<strong>Simple, Easy, One-Line Solution:</strong></p>
<pre>My_Controller</pre>
<pre>  def generate_pdf_in_background
</pre>
<pre>    system " RAILS_ENV=#{RAILS_ENV}   ruby  #{RAILS_ROOT}/script/runner   'MyModel.create_pdf_in_background'  <a href="http://lynx.astro.ku.dk/comp-phys/tutorials/background.shtml">&amp;</a> "
</pre>
<pre>  end</pre>
<pre>end
</pre>
<p>That ampersand was all I needed.  It runs the command as a background process.  A new ruby process is kicked off, and the 10 minute task runs perfectly.  Something makes the browser hang and wait for a response, but we confirmed that other requests can happen along side this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ahabman.com/blog/2008/05/rails-background-process-simple-fast-easy/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</feedburner:origLink></item>
	</channel>
</rss>
