<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Ternimal::Blog - Home</title>
  <id>tag:ternimal.com,2007:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://ternimal.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://ternimal.com/" rel="alternate" type="text/html"/>
  <updated>2007-08-13T20:00:55Z</updated>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-08-13:29</id>
    <published>2007-08-13T18:29:00Z</published>
    <updated>2007-08-13T20:00:55Z</updated>
    <link href="http://ternimal.com/2007/8/13/accidental-resolution" rel="alternate" type="text/html"/>
    <title>Accidental Resolution</title>
<content type="html">
            &lt;p&gt;On any sizeable Rails app you are bound to define a method in a controller that you don&#8217;t intend on making routable and neglect to call hide_method or making. A really good sign that a method shouldn&#8217;t be routable is when the method has arity. I wrote this small script to find all of the action_methods that also accept arguments. Read on for the script.&lt;/p&gt;


	&lt;p&gt;Some day I will probably collect this and other code healthiness introspections into a rails plugin providing handy rake targets such as &#8220;rake show:actions_with_arity&#8221;. For now, load it with script/runner or inside of a script/console session.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    def get_all_controllers
      controllers=[];
      ObjectSpace.each_object do |obj|
        if (obj.is_a? Class)&#38;&#38;(obj.name=~/Controller$/)
          controllers &amp;lt;&amp;lt; obj
        end
      end
      controllers
    end

    def get_controllers_actions_methods
      controllers = get_all_controllers

      controllers_actions= controllers.inject([]){ |controllers_actions,controller|
        if controller.respond_to?(:action_methods)
          controller_actions_methods = controller.action_methods.to_a.map { |act|
            controllers_actions &amp;lt;&amp;lt; controller.new.method(act)
          }
        end
        controllers_actions
      }
      controllers_actions
    end

    def output_methods
      ms = get_controllers_actions_methods
      y (ms.reject{|x|x.arity==0}.map(&#38;:inspect).sort)
    end
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-06-01:28</id>
    <published>2007-06-01T14:22:00Z</published>
    <updated>2007-06-02T02:25:47Z</updated>
    <link href="http://ternimal.com/2007/6/1/another-scribble" rel="alternate" type="text/html"/>
    <title>Another scribble</title>
<content type="html">
            &lt;p&gt;With the addition of control-point-free curves my scribble code can be a lot more concise and rapid. Here is a little ditty that draws spirals with a degree of randomness
&lt;img src=&quot;http://ternimal.com/assets/2007/6/2/spiral.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-05-14:26</id>
    <published>2007-05-14T23:54:00Z</published>
    <updated>2007-05-14T23:55:25Z</updated>
    <link href="http://ternimal.com/2007/5/14/scribble" rel="alternate" type="text/html"/>
    <title>Scribble!</title>
<content type="html">
            &lt;p&gt;I have been playing a lot with a project that is intended to be a cross platform port of &lt;a href=&quot;http://nodebox.net/code/index.php/Home&quot;&gt;NodeBox&lt;/a&gt;. I even hope to contribute significantly to the project where I can. Other than that, I love graphics and programming so I am just going to play with it, report and fix bugs, and share my nifty hacks. I title this one: the curvy cubist&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://ternimal.com/assets/2007/5/14/the_curvy_cubist.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-05-10:24</id>
    <published>2007-05-10T22:33:00Z</published>
    <updated>2007-05-10T22:38:45Z</updated>
    <link href="http://ternimal.com/2007/5/10/gfdl-presentation-videos" rel="alternate" type="text/html"/>
    <title>GFDL Presentation Videos</title>
<content type="html">
            &lt;p&gt;There is a video of my May 5 presentation on Ruby on Rails at the Chiglug meeting.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.chicagolug.org/videos/&quot;&gt;&lt;img src=&quot;http://www.chicagolug.org/videos/chiglug070505_evan_lightning_on_rails.avi0000.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;There are a lot of other great presentations there, too!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-05-08:20</id>
    <published>2007-05-08T02:23:00Z</published>
    <updated>2007-05-08T02:26:53Z</updated>
    <link href="http://ternimal.com/2007/5/8/evolving-drawing-gone-underground" rel="alternate" type="text/html"/>
    <title>Evolving Drawing Gone Underground</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://evolvingdrawing.com&quot;&gt;Evolving Drawing&lt;/a&gt; is now by invitation only. You can still watch it evolve but now it is out of beta and into superproductionseriousnessenterprise mode. Watch your inbox!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-05-03:16</id>
    <published>2007-05-03T16:50:00Z</published>
    <updated>2007-05-03T16:53:41Z</updated>
    <link href="http://ternimal.com/2007/5/3/a-bit-sized-taste-of-my-rails-presentation" rel="alternate" type="text/html"/>
    <title>A tiny taste of my rails presentation</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://ternimal.com/assets/2007/5/3/mvcdiagram.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://ternimal.com/assets/2007/5/3/slide.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;I lovingly hand-wrote the slides in &lt;span class=&quot;caps&quot;&gt;SVG&lt;/span&gt; using present. I will be giving the talk at 3pm on the &lt;span class=&quot;caps&quot;&gt;IIT&lt;/span&gt; campus in the &lt;a href=&quot;http://www.cleversafe.com&quot;&gt;Cleversafe&lt;/a&gt; office for the &lt;a href=&quot;http://chiglug.org&quot;&gt;&lt;span class=&quot;caps&quot;&gt;CHIGLUG&lt;/span&gt;&lt;/a&gt; meeting&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-05-01:15</id>
    <published>2007-05-01T01:21:00Z</published>
    <updated>2007-05-01T01:21:11Z</updated>
    <link href="http://ternimal.com/2007/5/1/mindsplatter-a-camping-app" rel="alternate" type="text/html"/>
    <title>Mindsplatter: a camping app</title>
<content type="html">
            &lt;p&gt;This evening &lt;a href=&quot;http://mindsplatter.net/&quot;&gt;my first little camping app&lt;/a&gt;  was born. It was a hard 16hr labor full of FastCGI related complications. My dreamhost account is exhausted. He&#8217;s just a little guy with no database, so try not to slam him too hard with traffic. Little, yet he is &lt;a href=&quot;http://ternimal.com/svn/mindsplatter/mind_splatter.rb&quot;&gt;already big enough to wear the handmedown pantsuit&lt;/a&gt; of my old bloxsom weblahh I had so many years ago. In no time flat I will have stitched that pantsuit up with a few shiny sequins.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-04-16:13</id>
    <published>2007-04-16T06:02:00Z</published>
    <updated>2007-04-16T06:02:35Z</updated>
    <link href="http://ternimal.com/2007/4/16/present-an-svg-slideshow-script" rel="alternate" type="text/html"/>
    <title>Present: An SVG slideshow script</title>
<content type="html">
            &lt;p&gt;So in the process of writing a small presentation on Ruby on Rails for my &lt;a href=&quot;http://chiglug.org&quot;&gt;local &lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt;/Linux Group&lt;/a&gt; I wrote an &lt;span class=&quot;caps&quot;&gt;SVG&lt;/span&gt; slideshow program. OO Impress was just too frustrating with it&#8217;s utter lack of support for Fluxbox. The script is &lt;a href=&quot;http://ternimal.com/svn/present/trunk/present&quot;&gt;right here in my subversion repository&lt;/a&gt;. It is going to improve substantially as I use it to write a few more presentations I need to write for work. The sample slides.yml is a draft of the presentation I was actually working on.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-03-21:12</id>
    <published>2007-03-21T16:29:00Z</published>
    <updated>2007-03-21T16:56:43Z</updated>
    <link href="http://ternimal.com/2007/3/21/my-new-love-fields_for" rel="alternate" type="text/html"/>
    <title>My New Love: fields_for</title>
<content type="html">
            So I have always loved form_for, but it becomes tricky to use when your object is more complex than a simple flat object with attributes that can be set in the manner. But what if you are trying to save a model that has assoctiated models? Enter fields_for
&lt;pre&gt;&lt;code&gt;
class Package &amp;lt; ActiveRecord::Base
   has_one :address
end

class Address &amp;lt;ActiveRecord::Base
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;
&amp;lt;% form_for @package do |f| %&amp;gt;
  &amp;lt;%= f.text_field 'special_notes' %&amp;gt;
  &amp;lt;% f.fields_for @package.address do |a| %&amp;gt;
    &amp;lt;%= a.text_field 'first_line' %&amp;gt;
    &amp;lt;%= a.text_field 'second_line' %&amp;gt;
  &amp;lt;% end %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-03-19:11</id>
    <published>2007-03-19T16:49:00Z</published>
    <updated>2007-03-19T16:59:52Z</updated>
    <link href="http://ternimal.com/2007/3/19/this-title-intentionally-left-blank" rel="alternate" type="text/html"/>
    <title>This title intentionally left blank.</title>
<content type="html">
            &lt;pre&gt;&lt;code&gt;
&amp;gt;&amp;gt; def foo; puts &quot;bar&quot;; end
=&amp;gt; nil
&amp;gt;&amp;gt; p = :foo.to_proc
=&amp;gt; #&amp;lt;Proc:0xb7bbad20@/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/symbol.rb:10&amp;gt;
&amp;gt;&amp;gt; p = :foo.to_proc
=&amp;gt; #&amp;lt;Proc:0xb7bbad20@/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/symbol.rb:10&amp;gt;
&amp;gt;&amp;gt; eval(p.to_ruby).call
NameError: undefined local variable or method `obj' for #&amp;lt;Object:0xb7d359fc&amp;gt;
        from (eval):2
        from (irb):28:in `call'
        from (irb):28
        from :0
&amp;gt;&amp;gt; p.to_ruby
=&amp;gt; &quot;proc { |*args|\n  obj.send(self, *args)\n}&quot; 
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-02-23:10</id>
    <published>2007-02-23T02:31:00Z</published>
    <updated>2007-02-22T02:31:49Z</updated>
    <link href="http://ternimal.com/2007/2/23/javascript-it-just-sunk-in" rel="alternate" type="text/html"/>
    <title>Javascript: It Just Sunk In</title>
<content type="html">
            &lt;p&gt;So recently I just realized how it all works. Functions are first class data types in javascript and thus you can create &lt;span class=&quot;caps&quot;&gt;JSON&lt;/span&gt; hashes out of them which is what creates the CamelCaseObject.method() like syntax. That took a looong time to sink in.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-02-22:9</id>
    <published>2007-02-22T02:17:00Z</published>
    <updated>2007-02-22T02:32:23Z</updated>
    <category term="Projects"/>
    <link href="http://ternimal.com/2007/2/22/evolving-drawing" rel="alternate" type="text/html"/>
    <title>Evolving Drawing</title>
<content type="html">
            &lt;p&gt;So there is a little app I wrote recently: &lt;a href=&quot;http://evolvingdrawing.com&quot;&gt;evolving drawing&lt;/a&gt;. I can&#8217;t say too much about it without spoiling. Check it out, it is at a half baked state but I am still in talks with my &#8220;customer&#8221; to improve it. It runs using rails, a lot of XMLBuilder, cutting edge prototype and &lt;span class=&quot;caps&quot;&gt;SVG&lt;/span&gt;. It only works in firefox as far as I know. Feel free to see the source in my  &lt;a href=&quot;http://ternimal.com/svn/evolvingdrawing/trunk&quot;&gt;svn&lt;/a&gt;. The code is all mine but the idea is completely that of my friend Joe Philips.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-01-05:4</id>
    <published>2007-01-05T15:18:00Z</published>
    <updated>2007-01-05T15:30:09Z</updated>
    <link href="http://ternimal.com/2007/1/5/allison-mephisto-template" rel="alternate" type="text/html"/>
    <title>Allison Mephisto Template</title>
<content type="html">
            &lt;p&gt;This is the initial release of Allison Mephisto (v0.1). You can see it in action, um, right on this page here. It is a great way to theme your rdocs just like your project&#8217;s blog. In fact, if you customize allison&#8217;s styles to your project you can use the exact same css with my theme, with just a little bit of finagling for the rounded corners. To install it just run &lt;code&gt;svn co http://ternimal.com/svn/allison/trunk allison&lt;/code&gt; from the &lt;span class=&quot;caps&quot;&gt;RAILS&lt;/span&gt;_ROOT/themes/site-1 directory. If you have any problems just shoot me an email or leave a comment.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2007-01-04:2</id>
    <published>2007-01-04T19:37:00Z</published>
    <updated>2007-01-04T19:54:31Z</updated>
    <link href="http://ternimal.com/2007/1/4/cissaby-is-css-as-ruby" rel="alternate" type="text/html"/>
    <title>Cissaby is CSS as ruby</title>
<content type="html">
            &lt;p&gt;Check out my latest exploit, cissaby: a way to do &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; in ruby. Right now it isn&#8217;t quite finished, but I have figured out how I can make it work. So let&#8217;s say I have some &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; code like this:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
div.article{ font-color: red; }
#errors, #header{ padding: 0px; }
#errors{ display: none; }
#header h2{ font-size: 2em; }
&lt;/code&gt;&lt;/pre&gt;

In cissaby I would have done it like this:
&lt;pre&gt;&lt;code&gt;
Cissaby::Builder.new{
  div.article{ :&quot;font-color&quot; =&amp;gt; &quot;red&quot; }
  errors!/header!{ :padding =&amp;gt; &quot;0px&quot; }
  errors!{:display =&amp;gt; &quot;none&quot;}
  header!._.h2{ :&quot;font-size&quot; =&amp;gt; &quot;2em&quot;}
}
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Pretty uselessly awesome, huh? &lt;code&gt;svn co http://ternimal.com/svn/cissaby/trunk/&lt;/code&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://ternimal.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:ternimal.com,2006-12-31:1</id>
    <published>2006-12-31T04:21:00Z</published>
    <updated>2006-12-31T05:34:03Z</updated>
    <link href="http://ternimal.com/2006/12/31/using-script-runner" rel="alternate" type="text/html"/>
    <title>Using ./script/runner</title>
<content type="html">
            &lt;p&gt;&lt;strong&gt;Stop abusing the console!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Here is my confession: I&#8217;ve used the console in production mode to do some heavy lifting. I was shaking with nervousness though, because one weird typo or mixed up paste buffer could have meant disaster. &lt;em&gt;You don&#8217;t have to though:&lt;/em&gt; In rails there is a pretty amazing tool, runner, that I only recently discovered the usefulness of.&lt;/p&gt;


	&lt;p&gt;Generally, it is a tool that lets you execute code within your rails app&#8217;s environment. For me, specifically, it helps me avoid abusing the console. Which is a hard habit for &lt;span class=&quot;caps&quot;&gt;CLI&lt;/span&gt;-junkie like me to avoid. But I&#8217;m a programmer, damnit, I write programs. And I&#8217;m also not a &lt;span class=&quot;caps&quot;&gt;DBA&lt;/span&gt;, I don&#8217;t trust myself to shoot from the hip with &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt;. See, sometimes at work our beta-testing server&#8217;s database gets rebuilt. No biggie, but it is annoying because a few user settings that are in the database get lost. Until now I had been fixing this by tooling in the console. It is repepitive, it is tedious, and I typically forget how I have gone through the process by the time I finish it. Now I just write up my complex alterations in vim and run them with runner&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
  #!/usr/bin/env script/runner
  User.find_by_name($1).roles &amp;lt;&amp;lt; Role.find_by_name('Super User')
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;And here is a little tip that you will help you debug your scripts: wrap everything in a transaction, then throw a breakpoint at the end of the transation so you can find out if your code did what you intended it to. Or, here is an even better tip, use &lt;a href=&quot;http://www.rubyonrails.org/api/classes/Breakpoint.html#M000978&quot;&gt;breakpoint&#8217;s assert method&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
</feed>
