<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>benburkert.com - blog</title>
  <id>tag:benburkert.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://benburkert.com/" rel="alternate" type="text/html" />
  <updated>2008-02-08T17:32:05Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/benburkert" type="application/atom+xml" /><entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2008-02-08:15</id>
    <published>2008-02-08T17:24:00Z</published>
    <updated>2008-02-08T17:32:05Z</updated>
    <category term="barcamptx" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/Wwtoh6KRFSQ/testing-talk" rel="alternate" type="text/html" />
    <title>Testing Talk</title>
<content type="html">
            &lt;p&gt;I recently gave a talk on software testing at &lt;a href="http://barcamptexas.com"&gt;BarCampTX&lt;/a&gt;, the slides are available at &lt;a href="http://www.slideshare.net/superphly/software-testing-246433"&gt;slideshare&lt;/a&gt;.  The talk covered TDD, BDD, rspec, autotest, autometric, and story testing.  I going to write more about using story testing to test your views, and where webrat comes in, but in the meantime you can checkout the &lt;a href="http://github.com/hornbeck/blerb-core/"&gt;blerb project&lt;/a&gt; to see story testing in action.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2008/2/8/testing-talk</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-11-09:13</id>
    <published>2007-11-09T02:44:00Z</published>
    <updated>2007-11-09T02:54:06Z</updated>
    <category term="autometric" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/5rlDaR2dTyE/introducing-autometric" rel="alternate" type="text/html" />
    <title>Introducing Autometric</title>
<content type="html">
            &lt;p&gt;Autometric is a tool thats automates the task of running metrics on your ruby code.  It’s modeled after autotest, so it behaves the same way.  Don’t waist any more time running rcov from the command line or rake task.  Here’s a demo:&lt;/p&gt;

&lt;p&gt;&amp;lt;center&gt;                                                            &lt;div&gt;&lt;a href="http://blip.tv/file/get/Benburkert-AutometricDemo567.mov"&gt;&lt;img title="Click To Play" src="http://blip.tv/file/get/Benburkert-AutometricDemo567.mov.jpg" alt="Video thumbnail. Click to play" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://blip.tv/file/get/Benburkert-AutometricDemo567.mov"&gt;Click To Play&lt;/a&gt;&lt;/div&gt;                                     &amp;lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Or the full screen, if you prefer:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://benburkert.com/assets/2007/11/9/autometric.mov"&gt;Autometric Demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here’s how to install it with images and all:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;sudo gem install autometric
mkdir ~/.autometric_images
cd ~/.autometric_images
wget http://upload.wikimedia.org/wikipedia/commons/2/2e/Crystal_Clear_action_button_cancel.png -O coverage_failed.png
wget http://upload.wikimedia.org/wikipedia/commons/d/d6/Crystal_Clear_action_apply.png -O coverage_passed.png
wget http://upload.wikimedia.org/wikipedia/commons/2/2c/Crystal_Clear_action_stop.png -O cyclo_error.png
wget http://upload.wikimedia.org/wikipedia/commons/5/53/Crystal_Clear_app_error.png -O cyclo_warn.png
wget http://upload.wikimedia.org/wikipedia/commons/b/b9/Crystal_Clear_action_edit_remove.png -O decrease.png
wget http://upload.wikimedia.org/wikipedia/commons/e/e2/Crystal_Clear_action_edit_add.png -O increase.png
wget http://upload.wikimedia.org/wikipedia/commons/0/0a/Crystal_Clear_action_1downarrow.png -O flog_decrease.png
wget http://upload.wikimedia.org/wikipedia/commons/2/2c/Crystal_Clear_action_1uparrow.png -O flog_increase.png
wget http://upload.wikimedia.org/wikipedia/commons/0/03/Crystal_Clear_action_bookmark.png -O flog.png&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And save the following as “.autometric” in your home directory:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def growl(title, msg, pri=0, stick=&amp;quot;&amp;quot;, image=&amp;quot;&amp;quot;)
  image_arg = (!image.empty?) ? &amp;quot;--image #{image}&amp;quot; : &amp;quot;&amp;quot;
  system &amp;quot;growlnotify -n autometric #{image_arg} -p #{pri} -m \&amp;quot;#{msg}\&amp;quot; #{title} #{stick}&amp;quot; 
end

Autocoverage.add_hook :initialize do |at|
  at.threshold = 90.0
end

Autocoverage.add_hook :failed do |at|
  growl(&amp;quot;Code Coverage Failed&amp;quot;,&amp;quot;#{at.coverage}% code coverage&amp;quot;, 2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/coverage_failed.png&amp;quot;)
end

Autocoverage.add_hook :passed do |at|
  growl(&amp;quot;Code Coverage Passed&amp;quot;, &amp;quot;#{at.coverage}% code coverage&amp;quot;, -2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/coverage_passed.png&amp;quot;) #if at.tainted
end

Autocoverage.add_hook :increased do |at|
  growl(&amp;quot;Code Coverage Increased&amp;quot;,&amp;quot;#{&amp;quot;%.3f&amp;quot; % (at.coverage - at.previous_coverage)}% code coverage increase&amp;quot;, 2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/increase.png&amp;quot;)
end

Autocoverage.add_hook :decreased do |at|
  growl(&amp;quot;Code Coverage Decreased&amp;quot;, &amp;quot;#{&amp;quot;%.3f&amp;quot; % (at.previous_coverage - at.coverage)}% code coverage decrease&amp;quot;, -2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/decrease.png&amp;quot;) #if at.tainted
end

Autocyclo.add_hook :erred do |at|
  lines = at.errors.collect {|e| &amp;quot;#{e[:rating]} #{e[:id]}&amp;quot; }
  message = lines.length &amp;gt; 5 ? lines[0...5].join(&amp;quot;\n&amp;quot;) + &amp;quot;\n...&amp;quot; : lines.join(&amp;quot;\n&amp;quot;)
  growl(&amp;quot;Cyclomatic Complexity Errors&amp;quot;, message, 1, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/cyclo_error.png&amp;quot;)
end

Autocyclo.add_hook :warned do |at|
  lines = at.warnings.collect {|w| &amp;quot;#{w[:rating]} #{w[:id]}&amp;quot; }
  message = lines.length &amp;gt; 5 ? lines[0...5].join(&amp;quot;\n&amp;quot;) + &amp;quot;\n...&amp;quot; : lines.join(&amp;quot;\n&amp;quot;)
  growl(&amp;quot;Cyclomatic Complexity Warnings&amp;quot;, &amp;quot;#{message}&amp;quot;, 2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/cyclo_warn.png&amp;quot;)
end

Autotoken.add_hook :erred do |at|
  lines = at.errors.collect {|e| &amp;quot;#{e[:rating]} #{e[:id]}&amp;quot; }
  message = lines.length &amp;gt; 5 ? lines[0...5].join(&amp;quot;\n&amp;quot;) + &amp;quot;\n...&amp;quot; : lines.join(&amp;quot;\n&amp;quot;)
  growl(&amp;quot;Token Complexity Errors&amp;quot;, message, 1, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/cyclo_error.png&amp;quot;)
end

Autotoken.add_hook :warned do |at|
  lines = at.warnings.collect {|w| &amp;quot;#{w[:rating]} #{w[:id]}&amp;quot; }
  message = lines.length &amp;gt; 5 ? lines[0...5].join(&amp;quot;\n&amp;quot;) + &amp;quot;\n...&amp;quot; : lines.join(&amp;quot;\n&amp;quot;)
  growl(&amp;quot;Token Complexity Warnings&amp;quot;, &amp;quot;#{message}&amp;quot;, 2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/cyclo_warn.png&amp;quot;)
end

Autoflog.add_hook :flogged do |at|
  growl(&amp;quot;Flog Score&amp;quot;, &amp;quot;#{&amp;quot;%.3f&amp;quot; % at.score}&amp;quot;, 2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/flog.png&amp;quot;)
end

Autoflog.add_hook :increased do |at|
  growl(&amp;quot;Flog Score Increased&amp;quot;, &amp;quot;#{&amp;quot;%.3f&amp;quot; % (at.score - at.previous_score)}&amp;quot;, -2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/flog_increase.png&amp;quot;)
end

Autoflog.add_hook :decreased do |at|
  growl(&amp;quot;Flog Score Decreased&amp;quot;, &amp;quot;#{&amp;quot;%.3f&amp;quot; % (at.previous_score - at.score)}&amp;quot;, -2, &amp;quot;&amp;quot;, &amp;quot;~/.autometric_images/flog_decrease.png&amp;quot;)
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/11/9/introducing-autometric</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-10-25:12</id>
    <published>2007-10-25T16:43:00Z</published>
    <updated>2007-11-09T02:47:44Z</updated>
    <category term="autometric" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/9A-1pITD5r0/fun-with-superators" rel="alternate" type="text/html" />
    <title>Fun with Superators</title>
<content type="html">
            &lt;p&gt;&lt;a href="http://jicksta.com/"&gt;Jay Phillips&lt;/a&gt; wrote a wicked little gem called &lt;a href="http://jicksta.com/articles/2007/08/29/superators-add-new-operators-to-ruby"&gt;Superators&lt;/a&gt; this summer, and I’ve been looking for an excuse to use it.  Here’s a superator to change the protection of a method:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;require 'rubygems'
require 'superators'

class Class
  superator &amp;quot;&amp;lt;-&amp;quot; do |method_id|
    private method_id
  end

  superator &amp;quot;&amp;lt;+&amp;quot; do |method_id|
    public method_id
  end

  superator &amp;quot;&amp;lt;~&amp;quot; do |method_id|
    protected method_id
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This allows you to quickly access private methods:&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;puts [].rand rescue &amp;quot;rand is private!&amp;quot;
Array &amp;lt;+ &amp;quot;rand&amp;quot;
puts [].rand&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Dangerous, but useful if you need to keep a method private but you want to test it as if it was public (think: testing your rails models).&lt;/p&gt;


&lt;pre&gt;&lt;code class="ruby"&gt;describe Foo, &amp;quot;#bar&amp;quot; do

  before(:each) do
    # Foo#bar is private
    Foo &amp;lt;+ &amp;quot;bar&amp;quot;
  end

  after(:each) do
    Foo &amp;lt;- &amp;quot;bar&amp;quot;
  end

  it &amp;quot;should do something amazing!&amp;quot; do
    bar.should be_amazing
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Enjoy.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/10/25/fun-with-superators</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-09-21:9</id>
    <published>2007-09-21T17:46:00Z</published>
    <updated>2007-10-22T01:28:02Z</updated>
    <link href="http://feedproxy.google.com/~r/benburkert/~3/bHqKDjMT_s0/trim-your-if-trees" rel="alternate" type="text/html" />
    <title>Trim Your 'if' Trees</title>
<content type="html">
            &lt;p&gt;Here’s a helpful little hack for keeping those if trees under control.  Ever written code like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def parse_line
  if line_is_parsable? 
    if line_is_nested? 
      if line_is_attribute?
        parse_attribute
      else
        # do parsing
      end
    else
      @line_stack.pop
      return
    end
  else
    skip_line
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What started out as a single if statement has grown into an unmaintainable mess of &lt;em&gt;if*’s *elsif&lt;/em&gt;’s, and &lt;em&gt;unless&lt;/em&gt;’.  Well, thats fine and all, until you have to make changes.  What if you need to check for attributes before nested?  Or insert a condition check between parsable and nested?  Every change requires stepping through the code to figure out whats going on. It’s a drain on productivity, but there is a cure.  &lt;/p&gt;

&lt;p&gt;First, add the following snippet to your project.  (I like to put it in a file called ‘util.rb’ that gets loaded first.)&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;# Stolen without regard from http://svn.rubyonrails.org/rails/trunk/activesupport/lib/active_support/core_ext/module/aliasing.rb
# Inspired by http://errtheblog.com/post/1109
class Module

  def alias_method_chain(target, feature)
    # Strip out punctuation on predicates or bang methods since
    # e.g. target?_without_feature is not a valid method name.
    aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
    yield(aliased_target, punctuation) if block_given?

    with_method, without_method = &amp;quot;#{aliased_target}_with_#{feature}#{punctuation}&amp;quot;, &amp;quot;#{aliased_target}_without_#{feature}#{punctuation}&amp;quot;

    alias_method without_method, target
    alias_method target, with_method

    case
      when public_method_defined?(without_method)
        public target
      when protected_method_defined?(without_method)
        protected target
      when private_method_defined?(without_method)
        private target
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That little bit of magic allows you to break up your if statements into multiple methods.  Not so special by itself, until you start chaining the methods:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def parse_line
  #do parsing
end

def parse_line_with_attribute_check
  if line_is_attribute?
    parse_attribute
  else
    parse_line_without_attribute_check
  end
end

alias_method_chain :parse_line, :attribute_check

def parse_line_with_nested_check
  if line_is_nested?
    parse_line_without_nested_check
  else
    @line_stack.pop
  end
end

alias_method_chain :parse_line, :nested_check

def parse_line_with_parsable_check
  if line_is_parsable?
    parse_line_without_parsable_check
  else
    skip_line
  end
end

alias_method_chain :parse_line, :parsable_check&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So now the behavior is determined by the code in the methods &lt;strong&gt;and&lt;/strong&gt; the order of methods.  This makes changes to the condition checks as easy as inserting, deleting, or reordering your methods.  So if I wanted to check attributes before nested, I simply move the attributes check after the nested check:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def parse_line
  #do parsing
end

def parse_line_with_nested_check
  if line_is_nested?
    parse_line_without_nested_check
  else
    @line_stack.pop
  end
end

alias_method_chain :parse_line, :nested_check

def parse_line_with_attribute_check
  if line_is_attribute?
    parse_attribute
  else
    parse_line_without_attribute_check
  end
end

alias_method_chain :parse_line, :attribute_check

def parse_line_with_parsable_check
  if line_is_parsable?
    parse_line_without_parsable_check
  else
    skip_line
  end
end

alias_method_chain :parse_line, :parsable_check&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This leaves your code damp, but much easier to extend and maintain.  It works great when &lt;strong&gt;BDD&lt;/strong&gt;‘ing.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/9/21/trim-your-if-trees</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-09-13:7</id>
    <published>2007-09-13T03:58:00Z</published>
    <updated>2007-10-22T01:14:59Z</updated>
    <category term="tamu" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/-RieIxT52HM/ruby-rails-on-sy-cs-tamu-edu" rel="alternate" type="text/html" />
    <title>Ruby/Rails on sy*.cs.tamu.edu</title>
<content type="html">
            &lt;p&gt;I was asked to install Ruby on Rails on a windows server, to be used for class projects.  I went  with the mongrel via apache approach.  I was originally going to install it on IIS runing under FastCGI, but decided against it for a few reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FastCGI is really only appropriate for a production environment.  It’s hard to debug, and this machine is probably going to be used for development, testing, and production.&lt;/li&gt;
&lt;li&gt;Its relatively unstable.  FastCGI on IIS is still an awkward combination, and was bound to cause headaches.&lt;/li&gt;
&lt;li&gt;The apache/mongrel approach keeps the two very separate, so it’s easier to find problems.&lt;/li&gt;
&lt;li&gt;To use IIS with Mongrel, you need ISAPI_rewrite, which costs money.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I used &lt;a href="http://www.napcsweb.com/howto/rails/deployment/RailsWithApacheAndMongrel.pdf" title="Rails with Apache and Mongrel"&gt;this guide&lt;/a&gt;, so be sure to look it over if you have any problems.&lt;/p&gt;

&lt;h2&gt;Step 0: Downloads&lt;/h2&gt;

&lt;p&gt;Remote desktop into the install machine, and download the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.devlib.org/apache/httpd/binaries/win32/apache_2.0.59-win32-x86-no_ssl.msi"&gt;Apache server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://rubyforge.org/frs/download.php/18566/ruby186-25.exe"&gt;Ruby One-Click Installer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Step 1: Install Apache &amp;amp; Ruby&lt;/h2&gt;

&lt;p&gt;Run the apache installer.  Use ”sy&amp;lt;your&gt;.cs.tamu.edu” as the network domain and server name.  Put whatever you want for the administrators email.&lt;/p&gt;

&lt;p&gt;On the next page, click “Custom Install”, and change the installation to “c:\apache”, then choose next and let the installer finish.&lt;/p&gt;

&lt;p&gt;Now open the Ruby installer.  The default install should be fine.&lt;/p&gt;

&lt;h2&gt;Step 2: Start the Apache Daemon&lt;/h2&gt;

&lt;p&gt;Enter the following into a command shell:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd \
cd apache\apache2\bin
apache –k install&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The apache service icon should appear in the task bar.&lt;/p&gt;

&lt;h2&gt;Step 3: Install Rails &amp;amp; Mongrel&lt;/h2&gt;

&lt;p&gt;Install the rails, redcloth, and mongrel gems:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;gem install rails mongrel mongrel_service redcloth -y&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make sure to choose the win32 option every time it asks.&lt;/p&gt;

&lt;h2&gt;Step 4: Configure Apache&lt;/h2&gt;

&lt;p&gt;From the start menu, navigate to “All Programs”-&gt;”Apache HTTP Server X”-&gt;”Configure Apache Server”-&gt;”Edit The Apache http.conf Configuration file”.&lt;/p&gt;

&lt;p&gt;Change the line with:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;Listen 8080&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;Listen 80&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note: Binding to port 80 will only work if you don’t have another webserver running on the machine.  If you think you might have IIS or something else running on port 80, run:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;netstat -a&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you see something like the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;TCP    sy02:http              sy02.cs.tamu.edu:0     LISTENING&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You may need to change to an open port number.  I suggest 81.&lt;/p&gt;

&lt;p&gt;Save the file, then start apache using the icon on the bottom right.  Enter the following command(change ‘http’ to your port number):&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;netstat -a | find &amp;quot;http&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It should print out something like:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;TCP    sy02:http              sy02.cs.tamu.edu:0     LISTENING&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you don’t see anything, you have a problem somewhere.&lt;/p&gt;

&lt;h2&gt;Step 5: Create the Rails App Folder&lt;/h2&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd \
mkdir rails_apps
cd rails_apps
rails test_site
cd test_site
ruby script/server –e production&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Point your browser to “http://localhost:3000/” ( replace 3000 with whatever port mongrel is running on.), if every thing’s working you should be at the default rails page.&lt;/p&gt;

&lt;h2&gt;Step 6: Configure Apache to Proxy to Mongrel&lt;/h2&gt;

&lt;p&gt;Run the following from the command shell:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd \
cd apache\apache2\conf
(
echo LoadModule proxy_module
modules/mod_proxy.so
echo LoadModule proxy_http_module
modules/mod_proxy_http.so
echo ProxyRequests Off
echo ^&amp;lt;Proxy *^&amp;gt;
echo   Order deny,allow
echo   Allow from all
echo ^&amp;lt;/Proxy^&amp;gt;
) &amp;gt;&amp;gt; http-proxy.conf
(
echo .
echo Include conf/http-proxy.conf
) &amp;gt;&amp;gt; httpd.conf&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this should create a http-proxy.conf file in apache’s conf directory.  Next run:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;set APP_NAME=test_site
set PORT=3000
(
echo .
echo Alias /%APP_NAME% &amp;quot;c:/rails_apps/%APP_NAME%/public&amp;quot;
echo ^&amp;lt;Directory &amp;quot;c:/rails_apps/%APP_NAME%/public&amp;quot;^&amp;gt;
echo   Options Indexes FollowSymLinks
echo   AllowOverride none
echo   Order allow,deny
echo   Allow from all
echo ^&amp;lt;/Directory^&amp;gt;
echo .
echo ProxyPass /%APP_NAME%/images !
echo ProxyPass /%APP_NAME%/stylesheets !
echo ProxyPass /%APP_NAME%/javascripts !
echo ProxyPass /%APP_NAME%/ http://127.0.0.1:%PORT%/
echo ProxyPass /%APP_NAME% http://127.0.0.1:%PORT%/
echo ProxyPassReverse /%APP_NAME%/ http://127.0.0.1:%PORT%/
) &amp;gt;&amp;gt; http-proxy.conf&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Restart apache, browse to “http://localhost/test_site/”, and you should be at your default page.&lt;/p&gt;

&lt;h2&gt;Step 7: Install Proxy Plugin&lt;/h2&gt;

&lt;p&gt;Apparently rails needs some help rewriting URL’s to work with the proxy server, so you need to install a rails plugin:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd \
cd rails_apps\test_site
ruby script/plugin install http://svn.napcsweb.com/public/plugins/reverse_proxy_fix/branches/rails123
http://localhost/test_site
cd vendor\plugins\rails123\lib
echo BASE_URL=&amp;quot;http://localhost/test_site&amp;quot; &amp;gt;&amp;gt; config.rb&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 8: Start mongrel as a service&lt;/h2&gt;

&lt;p&gt;This will start a mongrel server as a windows service:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;mongrel_rails service::install -N test_site
net start test_site&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that should do it.  If everything went right, you should get the default rails page again.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/9/13/ruby-rails-on-sy-cs-tamu-edu</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-09-11:5</id>
    <published>2007-09-11T23:23:00Z</published>
    <updated>2007-09-11T23:44:06Z</updated>
    <category term="LSRC" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/-wVUYpI2VKg/lone-star-ruby-conf" rel="alternate" type="text/html" />
    <title>Lone Star Ruby Conf</title>
<content type="html">
            &lt;p&gt;Wow.  &lt;a href="http://www.lonestarrubyconf.com/" title="LSRC2007"&gt;Lone Star Ruby Conference&lt;/a&gt;.  Through an unexpected series of events, I ended up volunteering this weekend and had a great time.  It was great to see the ruby community in action.&lt;/p&gt;

&lt;p&gt;There were some fantastic presentations.  H D Moor’s presentation about security exploits, an area I could care less about, was an entertaining story about using ruby to create &lt;a href="http://www.metasploit.com/"&gt;Metasploit 3&lt;/a&gt;.  Evan Short’s DSL presentation opened my eye’s to a lot of stuff I was missing about DSL’s.  Zed’s (anti) &lt;a href="http://wiki.lonestarrubyconf.com/Zed's-Keynote"&gt;keynote&lt;/a&gt; was better than expected.  So was Jay Phillips talk on &lt;a href="http://adhearsion.com/"&gt;Adhearsion&lt;/a&gt;.  And the &lt;a href="http://www.railsenvy.com/"&gt;Rails Envy&lt;/a&gt; guys gave us a sneak peak at their latest Rails video.&lt;/p&gt;

&lt;p&gt;It still amazes me how many movers and shakers in the ruby community call Texas their home.  Without them, LSRC wouldn’t have been the huge success that it was.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/9/11/lone-star-ruby-conf</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-09-01:4</id>
    <published>2007-09-01T18:42:00Z</published>
    <updated>2007-10-22T00:54:05Z</updated>
    <category term="tamu" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/sREJleUO_do/ruby-rails-on-unix-cs-tamu-edu" rel="alternate" type="text/html" />
    <title>Ruby/Rails on unix.cs.tamu.edu</title>
<content type="html">
            &lt;p&gt;I wanted to host a ruby on rails website on my csnet account, but there were some problems.  The server is running an older version of ruby without gems installed.  Also, it looks like apache is not compiled with fastcgi.  To get around this, I had to install ruby and gems locally, and proxy the requests to a mongrel server.  There are a bunch of how-to’s on installing ruby/rails, but I ran into a few hiccups due csnet’s configuration.  This guide is mostly gathered from &lt;a href="http://wiki.dreamhost.com/Main_Page" title="dreamhost wiki"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Step 0: Environment Setup&lt;/h2&gt;

&lt;p&gt;First off, ssh into your unix account.  There’s information on how to do this over at &lt;a href="http://helpdesk.cs.tamu.edu/"&gt;cs helpdesk&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m used to the bash shell, but the default is tcsh.  If you have no idea what difference is, I recommend switching to bash:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;echo &amp;quot;exec bash --login&amp;quot; &amp;gt;&amp;gt; ~/.login&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Log out and log back in; the prompt should have changed to something like bash-3.00.  I recommend changing the prompt to something more usefull:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;echo &amp;quot;PS1=\&amp;quot;\[\033[0;31m\][\u@\h \W]#\[\033[0m\] \&amp;quot;&amp;quot; &amp;gt;&amp;gt; ~/.bash_profile&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Log in/out or source the .bash_profile file and the prompt should be updated.&lt;/p&gt;

&lt;p&gt;Because we are building and executing everything locally, we need to add a few folders:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ~/
mkdir -pv soft run www log
cd ~/run
mkdir -pv bin etc include lib man share&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next, we need to set the RUN variable and update PATH:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cat &amp;gt;&amp;gt;${HOME}/.bashrc &amp;lt;&amp;lt;eof
export RUN=&amp;quot;\${HOME}/run&amp;quot;

export PATH=&amp;quot;\${RUN}/bin:\${PATH}&amp;quot;

export LD_LIBRARY_PATH=\${RUN}/lib:\${LD_LIBRARY_PATH}
export LD_RUN_PATH=\${RUN}/lib:\${LD_RUN_PATH}
eof

echo &amp;quot;source ~/.bashrc&amp;quot; &amp;gt;&amp;gt; ${HOME}/.bash_profile&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 1: Install Readline&lt;/h2&gt;

&lt;p&gt;Ruby requires Readline, so we need to install it locally before compiling ruby:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ${HOME}/soft
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar xvzf readline-5.2.tar.gz
cd readline-5.2

./configure --prefix=${RUN}
make &amp;amp;&amp;amp; make install&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 2: Install Ruby&lt;/h2&gt;

&lt;p&gt;Download, compile, and install ruby locally:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ${HOME}/soft
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar xvzf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure --prefix=${RUN} --with-readline-dir=${RUN}
make &amp;amp;&amp;amp; make install&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will tell ruby to use use the local libs folders:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cat &amp;gt;&amp;gt; ${HOME}/.bashrc &amp;lt;&amp;lt;eof
# ruby library search path
export RUBYLIB=\${RUN}/lib/ruby:\${RUN}/lib/rubyext
eof&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Logout/in then make sure ruby is pointing to ~/run/bin/ruby and is the version you installed (1.8.6):&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;which ruby &amp;amp;&amp;amp; ruby -v&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It should print something like:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;/user/brb1763/run/bin/ruby
ruby 1.8.6 (2007-03-13 patchlevel 0) [sparc-solaris2.8]&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 3: Install RubyGems&lt;/h2&gt;

&lt;p&gt;Download and install rubygems:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ${HOME}/soft
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar xzvf rubygems-0.9.4.tgz
cd rubygems-0.9.4
ruby setup.rb config --prefix=$RUN
ruby setup.rb setup
ruby setup.rb install&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Verify rubygems is installed:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;which gem &amp;amp;&amp;amp; gem -v&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should see:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;/user/brb1763/run/bin/gem
0.9.4&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 4: Install Rails&lt;/h2&gt;

&lt;p&gt;Install rails and mongrel:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;gem install rails mongrel --no-rdoc --no-ri -y
If you are prompted to choose a gem, select the ones that end with (ruby).&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Verify rails is installed:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;which rails &amp;amp;&amp;amp; rails -v&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That should print:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;/user/brb1763/run/bin/rails
Rails 1.2.3&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 5: Create a Test Site&lt;/h2&gt;

&lt;p&gt;Create a test rails site in your www dir:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ~/www
rails test_site&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Start a mongrel server to server your site:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;cd ~/www/test_site
mongrel_rails start -d -p 3042 -l ~/log/mongrel.log&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The port number (3042 in this case) should be a random but unique port number.  If you are local or have a vpn connection, browse to http://unix.cs.tamu.edu:&amp;lt;your port number&amp;gt;/, it should serve the ruby on rails placeholder page.&lt;/p&gt;

&lt;h2&gt;Step 6: Proxy Requests to Your Mongrel Server&lt;/h2&gt;

&lt;p&gt;Set the mod_proxy stuff in your .htaccess file:&lt;/p&gt;

&lt;pre&gt;&lt;code class="sh"&gt;mkdir -pv ${HOME}/web_home/test_site
cd ${HOME}/web_home/test_site
cat &amp;gt;&amp;gt; .htaccess &amp;lt;&amp;lt;eof
RewriteEngine   on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://unix.cs.tamu.edu:&amp;lt;your port number&amp;gt;/$1 [P]
eof
chmod 644 .htaccess&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Don’t forget to set the port number.  Browse to http://students.cs.tamu.edu/&amp;lt;your username&amp;gt;/test_site/, if you see the placeholder page, you’re good to go.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/9/1/ruby-rails-on-unix-cs-tamu-edu</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-08-31:3</id>
    <published>2007-08-31T18:38:00Z</published>
    <updated>2007-10-22T05:24:42Z</updated>
    <category term="haml" />
    <link href="http://feedproxy.google.com/~r/benburkert/~3/Y9iaFH3r7dA/skittlish-haml" rel="alternate" type="text/html" />
    <title>skittlish (Haml)</title>
<content type="html">
            &lt;p&gt;I’m using the &lt;a href="http://evil.che.lu/projects/skittlish" title="skittlish"&gt;skittlish&lt;/a&gt; theme by Cristi Balan.  I use it for my &lt;a href="http://blog.dnite.org/2007/3/10/new-trac-theme"&gt;trac theme&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;The theme uses liquid, but I’m a big fan of &lt;a href="http://haml.hamptoncatlin.com/" title="haml"&gt;Haml&lt;/a&gt;, so I converted it( sorry, no &lt;a href="http://haml.hamptoncatlin.com/docs/rdoc" title="Sass"&gt;Sass&lt;/a&gt;).  Warning: I personalized for my site, so it not an exact copy of the liquid theme.  You can find it &lt;a href="/assets/2007/10/22/skittlish-0.4-haml.zip" title="skittlish-haml"&gt;here&lt;/a&gt;.&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/8/31/skittlish-haml</feedburner:origLink></entry>
  <entry xml:base="http://benburkert.com/">
    <author>
      <name>ben</name>
    </author>
    <id>tag:benburkert.com,2007-08-30:1</id>
    <published>2007-08-30T23:39:00Z</published>
    <updated>2007-10-22T00:30:15Z</updated>
    <link href="http://feedproxy.google.com/~r/benburkert/~3/hVW32QwwL3E/mic-check" rel="alternate" type="text/html" />
    <title>mic check</title>
<content type="html">
            &lt;p&gt;check. check 1 – 2. check.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;italicize check&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;bold check&lt;/strong&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;#ruby mic-check
3.times do |count|
  puts &amp;quot;check #{count}&amp;quot;
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;…&lt;/p&gt;

&lt;p&gt;rock &amp;amp; roll&lt;/p&gt;
          </content>  <feedburner:origLink>http://benburkert.com/2007/8/30/mic-check</feedburner:origLink></entry>
</feed>
