<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Semi-useless rhetoric</title>
	<atom:link href="http://hedonismbot.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hedonismbot.wordpress.com</link>
	<description>I apologize...for nothing!</description>
	<lastBuildDate>Wed, 28 Jan 2009 06:11:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hedonismbot.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Semi-useless rhetoric</title>
		<link>http://hedonismbot.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hedonismbot.wordpress.com/osd.xml" title="Semi-useless rhetoric" />
	<atom:link rel='hub' href='http://hedonismbot.wordpress.com/?pushpress=hub'/>
		<item>
		<title>I&#8217;ve moved!</title>
		<link>http://hedonismbot.wordpress.com/2009/01/27/ive-moved/</link>
		<comments>http://hedonismbot.wordpress.com/2009/01/27/ive-moved/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 06:10:27 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/2009/01/27/ive-moved/</guid>
		<description><![CDATA[This blog has moved to www.mrrubato.com.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=145&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This blog has moved to <a href="http://www.mrrubato.com" target="_self">www.mrrubato.com</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=145&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2009/01/27/ive-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Formatting source code in wordpress.com blogs</title>
		<link>http://hedonismbot.wordpress.com/2009/01/19/formatting-source-code-in-wordpresscom-blogs/</link>
		<comments>http://hedonismbot.wordpress.com/2009/01/19/formatting-source-code-in-wordpresscom-blogs/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 07:13:49 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=140</guid>
		<description><![CDATA[I just found out that there&#8217;s a way to format source code in wordpress.com blogs without having to mess around with the HTML yourself. You just need to surround your code with a tag. From http://support.wordpress.com/code/: Code in between the tags will automatically be encoded for display, you don’t need to worry about HTML entities [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=140&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I just found out that there&#8217;s a way to format source code in wordpress.com blogs without having to mess around with the HTML yourself.  You just need to surround your code with a  tag.</p>
<p>From <a href="http://support.wordpress.com/code/">http://support.wordpress.com/code/</a>:</p>
<blockquote><p>Code in between the  tags will automatically be encoded for display, you don’t need to worry about HTML entities or anything.</p></blockquote>
<p>When I get the chance, I&#8217;ll go through the old entries and modify them to make use of this feature.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/140/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=140&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2009/01/19/formatting-source-code-in-wordpresscom-blogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Overloading the ActiveRecord Setter</title>
		<link>http://hedonismbot.wordpress.com/2009/01/13/overloading-the-activerecord-setter/</link>
		<comments>http://hedonismbot.wordpress.com/2009/01/13/overloading-the-activerecord-setter/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 07:13:06 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=94</guid>
		<description><![CDATA[Sometimes, you want to do some extra work when you set an attribute on your ActiveRecord model instance. You can&#8217;t just do this, because you&#8217;ll just end up recursively calling the very setter that you&#8217;re defining: &#8230;and you can&#8217;t do this because you&#8217;ll end up modifying a copy of the attributes hash of the model [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=94&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Sometimes, you want to do some extra work when you set an attribute on your ActiveRecord model instance.</p>
<p>You can&#8217;t just do this, because you&#8217;ll just end up recursively calling the very setter that you&#8217;re defining:<br />
<pre class="brush: ruby;">
class Square &lt; ActiveRecord::Base
    def side=(value)
        self.area = value*value
        self.side = value
    end
end
</pre></p>
<div>&#8230;and you can&#8217;t do this because you&#8217;ll end up modifying a copy of the attributes hash of the model instance, which will not be written through to the database when the model instance is saved ( check out ActiveRecord::Base::attributes in active_record/base.rb):</div>
<p><pre class="brush: ruby;">
class Square &amp;gt; ActiveRecord::Base
    def side=(value)
        self.attributes['side'] = value
        self.area = value * value
    end 
end
</pre></p>
<div>After looking through the source for ActiveRecord::Base and some testing, I&#8217;ve found a method that&#8217;s worked for me and <em>appears</em> to be the preferred way of doing it:</div>
<p><pre class="brush: ruby;">
class Square &amp;gt; ActiveRecord::Base
    def side=(value)
        self.area = value * value # This would still work because we're calling the default setter for area
        write_attribute('side', value)
    end
end
</pre></p>
<div>Alternatively, you could do &#8220;self['side'] = value&#8221; instead of write_attribute.   The index assignment operatore actually does the same thing.</div>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=94&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2009/01/13/overloading-the-activerecord-setter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Monkey business and how to track monkey-patching of classes in Ruby</title>
		<link>http://hedonismbot.wordpress.com/2008/11/27/monkey-business-2/</link>
		<comments>http://hedonismbot.wordpress.com/2008/11/27/monkey-business-2/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:34:26 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/2008/12/02/monkey-business-2/</guid>
		<description><![CDATA[Playing with metaprogramming in Ruby and writing a simple example that overrides method_added to track monkey-patching of classes.  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=116&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To celebrate my 2 month anniversary with Ruby, I thought I&#8217;d play around a bit with its metaprogramming features. A quick intro: Ruby supports what some simian-primate aficionados would call <a title="Monkey patch - Wikipedia" href="http://en.wikipedia.org/wiki/Monkey_patch" target="_self">monkey-patching</a>.</p>
<blockquote><p>Monkey patching is a way to extend or modify the runtime code of dynamic languages (e.g. Smalltalk, Javascript, Objective-C, Ruby, Perl, Python, Groovy etc.) without altering the original source code.</p></blockquote>
<p>One way to do this in Ruby is by taking advantage of the fact that it supports &#8220;open classes.&#8221; That means that you can re-define parts of the class after it has already been defined. For example, you would be able to add a new to_s method to a class by doing the following:</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">AwesomeClass</span>
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">initialize</span>(value)
        <span style="color:#bb60d5;">@value</span> <span style="color:#666666;">=</span> value
    <span style="color:#007020;font-weight:bold;">end</span>
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">to_s</span>
        <span style="color:#bb60d5;">@value</span><span style="color:#666666;">.</span>to_s
    <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span>

ac <span style="color:#666666;">=</span> <span style="color:#60add5;">AwesomeClass</span><span style="color:#666666;">.</span>new(<span style="color:#4070a0;">"Soggy bacon"</span>)

<span style="color:#007020;">puts</span> ac <span style="font-style:italic;color:#60a0b0;"># prints "Soggy bacon" </span>

<span style="font-style:italic;color:#60a0b0;"># Change AwesomeClass's to_s implementation </span>
<span style="font-style:italic;color:#60a0b0;"># who likes soggy bacon?)</span>
<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">AwesomeClass</span>
    <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">to_s</span>
        <span style="color:#4070a0;">"Chunky bacon!"</span>
    <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span>

<span style="color:#007020;">puts</span> ac <span style="font-style:italic;color:#60a0b0;"># prints "Chunky bacon!"</span></pre>
</div>
</blockquote>
<p>In Ruby, all classes are simply instances of the <span style="font-family:'courier new';">Class</span> type.  Whenever you define a method on a class, the <span style="font-family:'courier new';">Class</span> instance&#8217;s <span style="font-family:'courier new';">method_added</span> method is called with the name of the method being defined.  For example, if we did the following, <span style="font-family:'courier new';">String.method_added()</span> would be called with &#8220;<span style="font-family:'courier new';">l33ticize</span>&#8221; as the argument:</p>
<blockquote>
<div class="highlight">
<pre><span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">String</span>
   <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">l33ticize</span>
       <span style="font-style:italic;color:#60a0b0;"># l33ticize the string - left as        </span>
       <span style="font-style:italic;color:#60a0b0;"># exercise for the reader...that's        </span>
       <span style="font-style:italic;color:#60a0b0;"># you! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span>
   <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span></pre>
</div>
</blockquote>
<h3>Monkeys Watching Monkeys</h3>
<p>By using open classes, we can re-define <span style="font-family:'courier new';">method_added</span> for instances of Class and do some custom stuff every time a method is defined for any class.  In this example, we&#8217;re re-defining method_added so that it tracks where the method was last defined.</p>
<blockquote>
<div class="highlight">
<pre><span style="font-style:italic;color:#60a0b0;">#!/usr/bin/env ruby                                                                                                                                                           </span>

<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">Class</span>
  <span style="color:#bb60d5;">@@method_history</span> <span style="color:#666666;">=</span> {}

  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#0e84b5;font-weight:bold;">self</span><span style="color:#666666;">.</span><span style="color:#06287e;">method_history</span>
    <span style="color:#007020;font-weight:bold;">return</span> <span style="color:#bb60d5;">@@method_history</span>
  <span style="color:#007020;font-weight:bold;">end</span>

  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">method_added</span>(method_name)
    <span style="color:#007020;">puts</span> <span style="color:#4070a0;">"</span><span style="font-style:italic;color:#70a0d0;">#{</span>method_name<span style="font-style:italic;color:#70a0d0;">}</span><span style="color:#4070a0;"> added to </span><span style="font-style:italic;color:#70a0d0;">#{</span><span style="color:#007020;">self</span><span style="font-style:italic;color:#70a0d0;">}</span><span style="color:#4070a0;">"</span>
    <span style="color:#bb60d5;">@@method_history</span><span style="color:#666666;">[</span><span style="color:#007020;">self</span><span style="color:#666666;">]</span> <span style="color:#666666;">||=</span> {}
    <span style="color:#bb60d5;">@@method_history</span><span style="color:#666666;">[</span><span style="color:#007020;">self</span><span style="color:#666666;">][</span>method_name<span style="color:#666666;">]</span> <span style="color:#666666;">=</span> <span style="color:#007020;">caller</span>
  <span style="color:#007020;font-weight:bold;">end</span>

  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">method_defined_in</span>(method_name)
    <span style="color:#007020;font-weight:bold;">return</span> <span style="color:#bb60d5;">@@method_history</span><span style="color:#666666;">[</span><span style="color:#007020;">self</span><span style="color:#666666;">][</span>method_name<span style="color:#666666;">]</span>
  <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span>

<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">SomeClass</span>
  <span style="color:#007020;">attr_accessor</span>  <span style="color:#517918;">:value</span>
  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">initialize</span>(value)
    <span style="color:#bb60d5;">@value</span> <span style="color:#666666;">=</span> value
  <span style="color:#007020;font-weight:bold;">end</span>

  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">compute</span>
    <span style="color:#007020;font-weight:bold;">return</span> <span style="color:#bb60d5;">@value</span> <span style="color:#666666;">*</span> <span style="color:#40a070;">2</span>
  <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span>

s <span style="color:#666666;">=</span> <span style="color:#60add5;">SomeClass</span><span style="color:#666666;">.</span>new(<span style="color:#40a070;">10</span>)

<span style="color:#007020;">puts</span> s<span style="color:#666666;">.</span>compute <span style="font-style:italic;color:#60a0b0;"># Prints "20"</span>

<span style="font-style:italic;color:#60a0b0;"># Prints this file + line number from </span>
<span style="font-style:italic;color:#60a0b0;"># the @value * 2 definition</span>
<span style="color:#007020;">p</span> <span style="color:#60add5;">SomeClass</span><span style="color:#666666;">.</span>method_defined_in(<span style="color:#517918;">:compute</span>)
<span style="color:#007020;font-weight:bold;">class</span> <span style="color:#0e84b5;font-weight:bold;">SomeClass</span>
  <span style="color:#007020;font-weight:bold;">def</span> <span style="color:#06287e;">compute</span>
    <span style="color:#007020;font-weight:bold;">return</span> <span style="color:#bb60d5;">@value</span> <span style="color:#666666;">*</span> <span style="color:#40a070;">3</span>
  <span style="color:#007020;font-weight:bold;">end</span>
<span style="color:#007020;font-weight:bold;">end</span>

<span style="color:#007020;">puts</span> s<span style="color:#666666;">.</span>compute <span style="font-style:italic;color:#60a0b0;"># Prints "30"</span>

<span style="font-style:italic;color:#60a0b0;"># Prints this file + line number from</span>
<span style="font-style:italic;color:#60a0b0;"># the @value * 3 definition</span>
<span style="color:#007020;">p</span> <span style="color:#60add5;">SomeClass</span><span style="color:#666666;">.</span>method_defined_in(<span style="color:#517918;">:compute</span>)</pre>
</div>
</blockquote>
<h3>For more fun&#8230;</h3>
<p>Comments are welcome.  There are definitely cleaner ways to implement the above.  For example, instead of storing an @@method_history variable on Class, you could store it for each Class instance (e.g. SomeClass.method_history).</p>
<p>What kinds of style guidelines should one follow when doing these kinds of things?  Was it a good choice to use open classes instead of using <a href="http://www.ruby-doc.org/core-1.9/classes/Module.html#M001262">class_eval</a>, <a href="http://www.rubycentral.com/book/ref_c_object.html#Object.send">send</a>, or even <a href="http://www.ruby-doc.org/core-1.9/classes/Module.html#M001262">instance_eval</a>?  I don&#8217;t really have the answer right now, but it&#8217;s definitely on my list of things to think about while I brush my teeth in the mornings.</p>
<p>If anyone&#8217;s out there, I invite you to do any of the following:</p>
<ul>
<li>Implement the l33ticize method</li>
<li>Improve on the method_defined_in implementation</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=116&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/11/27/monkey-business-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby load path</title>
		<link>http://hedonismbot.wordpress.com/2008/11/20/ruby-load-path/</link>
		<comments>http://hedonismbot.wordpress.com/2008/11/20/ruby-load-path/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 20:02:17 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=108</guid>
		<description><![CDATA[There are three ways to refer to the variable that stores the load paths that Ruby checks for libraries when you use &#8216;require&#8217; or &#8216;load.&#8217; $:, $-I, $LOAD_PATH<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=108&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There are three ways to refer to the variable that stores the load paths that Ruby checks for libraries when you use &#8216;require&#8217; or &#8216;load.&#8217;</p>
<blockquote>
<pre>$:, $-I, $LOAD_PATH</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=108&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/11/20/ruby-load-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>19 Rails Tricks</title>
		<link>http://hedonismbot.wordpress.com/2008/11/18/19-rails-tricks/</link>
		<comments>http://hedonismbot.wordpress.com/2008/11/18/19-rails-tricks/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 02:56:28 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=106</guid>
		<description><![CDATA[I came across this article on Ruby Inside. It contains a nice quick list of things that you might not have known that you can do in Rails.  I find the Rails Engines to be particularly interesting. http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html Benchmark logic in your controller actions acts_as_nested_set Easier collections with to_proc Convert arrays to sentences in views [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=106&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I came across this article on Ruby Inside.  It contains a nice quick list of things that you might not have known that you can do in Rails.  I find the Rails Engines to be particularly interesting.</p>
<p><a href="http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html" rel="nofollow">http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html</a></p>
<ol>
<li>Benchmark logic in your controller actions</li>
<li><strong><span style="font-weight:normal;">acts_as_nested_set</span></strong></li>
<li>Easier collections with to_proc</li>
<li>Convert arrays to sentences in views</li>
<li>Send files back to the user</li>
<li>Iterating through page elements with RJS</li>
<li>Check for existence</li>
<li>Number helpers for common number tasks</li>
<li>Testing different route configurations easily</li>
<li>Get lots of info about requests</li>
<li><strong><span style="font-weight:normal;">Improving session performance even more than with ActiveRecord</span></strong></li>
<li>Caching unchanging data at application startup</li>
<li>Check your views are rendering valid HTML / XHTML</li>
<li><strong><span style="font-weight:normal;">Cleaner HTML output testing</span></strong> </li>
<li>Run long-running tasks separately in the background</li>
<li>Make ids in URLs more user friendly</li>
<li>Separate out slices of functionality into Engines</li>
<li>Calculations</li>
<li><strong><span style="font-weight:normal;">XML or YAML output of your data</span></strong> </li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=106&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/11/18/19-rails-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Advanced Python</title>
		<link>http://hedonismbot.wordpress.com/2008/11/09/advanced-python/</link>
		<comments>http://hedonismbot.wordpress.com/2008/11/09/advanced-python/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 20:48:06 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=96</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=96&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<span style='text-align:center;display:block;'><object width='400' height='330' type='application/x-shockwave-flash' data='http://video.google.com/googleplayer.swf?docId=7760178035196894549'><param name='allowScriptAccess' value='never' /><param name='movie' value='http://video.google.com/googleplayer.swf?docId=7760178035196894549'/><param name='quality' value='best'/><param name='bgcolor' value='#ffffff' /><param name='scale' value='noScale' /><param name='wmode' value='opaque' /></object></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=96&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/11/09/advanced-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Which process is using that port?</title>
		<link>http://hedonismbot.wordpress.com/2008/10/27/which-process-is-using-that-port/</link>
		<comments>http://hedonismbot.wordpress.com/2008/10/27/which-process-is-using-that-port/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 23:39:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fuser]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=91</guid>
		<description><![CDATA[A simple example: to find out which process is using TCP port 8080 $ fuser -n tcp 8080<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=91&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A simple example: to find out which process is using TCP port 8080</p>
<blockquote>
<pre>$ fuser -n tcp 8080</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=91&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/10/27/which-process-is-using-that-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>Passing environment variables to sudo</title>
		<link>http://hedonismbot.wordpress.com/2008/10/27/passing-environment-variables-to-sudo/</link>
		<comments>http://hedonismbot.wordpress.com/2008/10/27/passing-environment-variables-to-sudo/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 22:06:36 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=87</guid>
		<description><![CDATA[You can pass environment variables such as $PYTHONPATH to sudo like this: sudo env PYTHONPATH=$PYTHONPATH /some/python/script<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=87&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>You can pass environment variables such as $PYTHONPATH to sudo like this:</p>
<blockquote>
<pre>sudo env PYTHONPATH=$PYTHONPATH /some/python/script</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=87&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/10/27/passing-environment-variables-to-sudo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
		<item>
		<title>How to delete a remote branch from a git repository</title>
		<link>http://hedonismbot.wordpress.com/2008/10/24/how-to-delete-a-remote-branch-from-a-git-repository/</link>
		<comments>http://hedonismbot.wordpress.com/2008/10/24/how-to-delete-a-remote-branch-from-a-git-repository/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 03:40:07 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://hedonismbot.wordpress.com/?p=81</guid>
		<description><![CDATA[This isn&#8217;t obvious, so I thought I&#8217;d post an example for deleting a remote branch. Let&#8217;s say you want to delete origin/some_branch from origin $ git branch -a * master origin/master origin/some_branch To remove the branch, just do this: $ git push origin :some_branch Now, it&#8217;s gone! $ git branch -a * master origin/master From [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=81&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This isn&#8217;t obvious, so I thought I&#8217;d post an example for deleting a remote branch.</p>
<p>Let&#8217;s say you want to delete origin/some_branch from origin</p>
<blockquote>
<pre>$ git branch -a
* master
origin/master
origin/some_branch</pre>
</blockquote>
<p>To remove the branch, just do this:</p>
<blockquote>
<pre>$ git push origin :some_branch</pre>
</blockquote>
<p>Now, it&#8217;s gone!</p>
<blockquote>
<pre>$ git branch -a
* master
origin/master</pre>
</blockquote>
<p>From the git push <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">manual page</a>:</p>
<blockquote><p>The canonical format of a &lt;refspec&gt; parameter is +?&lt;src&gt;:&lt;dst&gt;; that is, an optional plus +, followed by the source ref, followed by a colon :, followed by the destination ref.<br />
&#8230;</p>
<p>Pushing an empty &lt;src&gt; allows you to delete the &lt;dst&gt; ref from the remote repository.</p></blockquote>
<p>So, when you do &#8220;git push repo src:dest&#8221;, that translates to &#8220;git push &lt;repository&gt; &lt;refspec&gt;&#8221;.  In the example above, &lt;repository&gt; was &#8220;origin&#8221; and &lt;refspec&gt; was &#8220;:some_branch&#8221;.  Since there was no &lt;src&gt; part of the refspec, the &lt;dst&gt; ref was deleted from the remote repository.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hedonismbot.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hedonismbot.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hedonismbot.wordpress.com&#038;blog=4880439&#038;post=81&#038;subd=hedonismbot&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hedonismbot.wordpress.com/2008/10/24/how-to-delete-a-remote-branch-from-a-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0e841e76da197a6660150a79877f7d8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tim</media:title>
		</media:content>
	</item>
	</channel>
</rss>
