<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Making The Leap - Home</title>
  <id>tag:blog.mcmoyer.com,2010:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://blog.mcmoyer.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.mcmoyer.com/" rel="alternate" type="text/html"/>
  <updated>2010-02-02T18:57:36Z</updated>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2010-02-02:172</id>
    <published>2010-02-02T18:46:00Z</published>
    <updated>2010-02-02T18:57:36Z</updated>
    <category term="ColdFusion"/>
    <category term="ColdFusion"/>
    <category term="coldfusion"/>
    <category term="nginx"/>
    <link href="http://blog.mcmoyer.com/2010/2/2/nginx-and-railo" rel="alternate" type="text/html"/>
    <title>Nginx and Railo</title>
<content type="html">
            &lt;p&gt;I still have to do maintenance on my older CF sites.  Luckily, I found the excellent Railo CF Server.  I&#8217;ve also transitioned to using Nginx as my development and production web server&#8230;..mainly because of the ease of configuration&#8230;well, that and the speed and the reduced memory footprint compared to Apache.&lt;/p&gt;


	&lt;p&gt;In my development environment, I&#8217;ve symlinked the cfm source directory in the /railo-install-dir/webapps/ROOT path so I have something similar to this:&lt;/p&gt;


&lt;pre&gt;
/railo-install-dir/webapps/ROOT/website-1/
/railo-install-dir/webapps/ROOT/website-2/
&lt;/pre&gt;

	&lt;p&gt;Then, in my nginx.conf file, I have an entry like this:&lt;/p&gt;


&lt;pre&gt;
    server {
      listen      80;
      server_name website-1.local;
      index             index.cfm index.html index.html;

      location ~ \.cfm$ {
        #proxy_pass can't have a uri so we use rewrite to change the uri to pass to Railo
        rewrite ^(.*)$ /website-1/$1;
        proxy_pass       http://127.0.0.1:8600;
        proxy_redirect   off;
        proxy_set_header Host                          $host;
        proxy_set_header X-Real-IP                     $remote_addr;
        proxy_set_header X-Forwarded_For               $proxy_add_x_forwarded_for;
        break;
      }
      location ~ / {      
        root             /home/myuser/cf_sites/public;
      }

    }
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-11-16:171</id>
    <published>2009-11-16T17:45:00Z</published>
    <updated>2009-11-16T17:54:29Z</updated>
    <category term="ColdFusion"/>
    <category term="coldfusion"/>
    <category term="ror"/>
    <link href="http://blog.mcmoyer.com/2009/11/16/couldn-t-have-said-it-better-myself" rel="alternate" type="text/html"/>
    <title>Couldn't have said it better myself</title>
<content type="html">
            &lt;p&gt;Hal Helms was one of the original creators of the Fusebox framework for ColdFusion.  I started using that framework at version 2 for all of my ColdFusion development.  Back in 2006-ish, I discovered Ruby and Ruby On Rails.  I was hooked and even though I had around 8 years of CF experience at the time, I went whole hog on RoR.&lt;/p&gt;


	&lt;p&gt;I&#8217;ve been watching members of the CF community slowly switch over to RoR.  I&#8217;d always thought the CF programmers were a pragmatic bunch.  Afterall, CF was the best tool for the job back in the dark ages of web development.  It only made sense to me that they&#8217;d figure out that Ruby was an even better tool.&lt;/p&gt;


	&lt;p&gt;Today Hal Helms posted his farewell to CF blog post.  It&#8217;s affirming to me to see something like this and I gladly welcome him to the community.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.halhelms.com/blog/index.cfm/2009/11/16/Why-Im-Moving-to-Ruby-On-Rails&quot;&gt;Hals Blog Entry&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-07-28:135</id>
    <published>2009-07-28T02:10:00Z</published>
    <updated>2009-07-28T02:16:38Z</updated>
    <category term="Rails"/>
    <category term="factory_girl"/>
    <link href="http://blog.mcmoyer.com/2009/7/28/factory-girl-and-a-has-many-relationship" rel="alternate" type="text/html"/>
    <title>Factory girl and a has many relationship</title>
<content type="html">
            &lt;p&gt;Recently I had to use a Factory Girl object that had many children.  I had seen blog postings about keeping the object as an array, but none about assigning multiple objects to the association.&lt;/p&gt;


So, here&#8217;s what I came up with
&lt;pre&gt;
Factory.define :myobject do |f|
  f.children {|c| ary=[];4.times {|cld| ary &amp;lt;&amp;lt; c.association(:child)};ary}
end
&lt;/pre&gt;

	&lt;p&gt;In essence, you initialize an array, create x number of objects and append them to the array and lastly return the array from the block&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-04-30:113</id>
    <published>2009-04-30T15:33:00Z</published>
    <updated>2009-04-30T16:40:14Z</updated>
    <link href="http://blog.mcmoyer.com/2009/4/30/wso2-wsf-ruby-installation-on-ubuntu-9-04" rel="alternate" type="text/html"/>
    <title>WSO2 WSF/Ruby  installation on Ubuntu 9.04</title>
<content type="html">
            &lt;p&gt;Recently I upgraded my system from Ubuntu 8.04 to 9.04.  My typical upgrade just retains the home partition and reloads the rest from scratch.  When it came time to install &lt;span class=&quot;caps&quot;&gt;WSO2 WSF&lt;/span&gt;/C and &lt;span class=&quot;caps&quot;&gt;WSF&lt;/span&gt;/Ruby, I hit some snags.&lt;/p&gt;


	&lt;p&gt;It seems that 9.04 may not install some of the required libraries by default as I don&#8217;t remember having any issue installing it on 8.04.  This was installed on fresh Jaunty install with on Ruby Enterprise Edition installed.  libmysqlclient15-dev and libsqlite3-dev were installed as part of the &lt;span class=&quot;caps&quot;&gt;REE&lt;/span&gt; install.  &lt;span class=&quot;caps&quot;&gt;WSO2 WSF&lt;/span&gt;/C was installed by trial and error.  I&#8217;d run the install script and find the missing library, install it and try again until it compiled without any error.  You may not need all the libraries below, but they worked for me.&lt;/p&gt;


	&lt;p&gt;Anyway, in case you&#8217;re getting errors, try these aggregated tips:&lt;/p&gt;


	&lt;p&gt;First off, you probably already have it but you&#8217;ll need to install build-essential&lt;/p&gt;


&lt;pre&gt;sudo apt-get install build-essential&lt;/pre&gt;

	&lt;p&gt;I also needed this since the libtoolize command was failing.&lt;/p&gt;


&lt;pre&gt;sudo apt-get install libtool&lt;/pre&gt;

	&lt;p&gt;Next, these were the libraries that I needed to get everything installed.&lt;/p&gt;


&lt;pre&gt;
sudo apt-get install libxml 
sudo apt-get install libiconv-dev 
sudo apt-get install libxml2-dev 
sudo apt-get install openssl 
sudo apt-get install libsqlite 
sudo apt-get install libssl-dev 
sudo apt-get install libaxis2c-dev 
sudo apt-get install libxslt-dev 
sudo apt-get install librampart-dev
&lt;/pre&gt;

	&lt;p&gt;Now, follow the install instructions packaged with the &lt;span class=&quot;caps&quot;&gt;WSF&lt;/span&gt;/C and &lt;span class=&quot;caps&quot;&gt;WSF&lt;/span&gt;/Ruby tarballs and everything should go smoothly.&lt;/p&gt;


	&lt;p&gt;if you&#8217;re getting ax_util errors when compiling &lt;span class=&quot;caps&quot;&gt;WSF&lt;/span&gt;/C, try this:&lt;/p&gt;


&lt;pre&gt;export CFLAGS=&quot;-D_GNU_SOURCE&quot; &lt;/pre&gt;

	&lt;p&gt;at this point it is working for me and will hopefully be working for you.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-04-24:112</id>
    <published>2009-04-24T12:49:00Z</published>
    <updated>2009-04-24T13:36:43Z</updated>
    <link href="http://blog.mcmoyer.com/2009/4/24/my-upgrade-to-ubuntu-9-04" rel="alternate" type="text/html"/>
    <title>My upgrade to Ubuntu 9.04</title>
<content type="html">
            &lt;p&gt;I&#8217;ve been using Ubuntu 8.10 for about 3 months now.  This has been my first foray into using linux full time since I gave up on it becoming a desktop contender back in 2002 (Boy was I wrong!).  After a few attempts at using the upgrade button and having it time out, I downloaded the &#8216;alternate&#8217; cd and was successful in running the upgrade.&lt;/p&gt;


	&lt;p&gt;Everything was going along swimmingly until I rebooted.  Once the splash screen went away, I was presented with a black screen with a no longer moving wheel cursor.  The keyboard was unresponsive, but I could move the static cursor.  It was then I remembered that this was the same behavior I had seen when I installed 8.10.&lt;/p&gt;


	&lt;p&gt;After searching for fixes, this is was did it for me:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Boot into recover mode and drop into a root shell&lt;/li&gt;
		&lt;li&gt;dpkg-reconfigure xserver-xorg&lt;/li&gt;
		&lt;li&gt;edit /etc/X11/xorg.conf and add a line to the devices section: Driver      &#8220;vesa&#8221; &lt;/li&gt;
		&lt;li&gt;reboot and you should be presented with the login screen&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;At this point, I tried to use the hardware manager to use the NVidia drivers but it didn&#8217;t seem to work.  I ended up downloading the v180 driver from NVidia&#8217;s site and using their installer.&lt;/p&gt;


	&lt;p&gt;So far, everything else is going great.&lt;/p&gt;


	&lt;p&gt;For reference, my system specs are as follows:
. Dell Precision &lt;span class=&quot;caps&quot;&gt;T3400&lt;/span&gt;
. 8 Gig of ram
. Quad Core 
. NVidia &lt;span class=&quot;caps&quot;&gt;NVS 290&lt;/span&gt;
. Dual 250Gb sata drives&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-03-17:111</id>
    <published>2009-03-17T22:52:00Z</published>
    <updated>2009-03-17T23:09:46Z</updated>
    <category term="Rails"/>
    <category term="polymorphic resources"/>
    <category term="restful routes"/>
    <link href="http://blog.mcmoyer.com/2009/3/17/another-one-of-those-wow-that-worked-moments" rel="alternate" type="text/html"/>
    <title>Another one of those "Wow! that worked" moments.</title>
<content type="html">
            &lt;p&gt;Rails, and therefore ruby, are always amazing me.  Just today, I was working on a site that had a job object.  The job belonged to both a company and a project.  Now, normally, given restful routing, you have something like this as your url&lt;/p&gt;


&lt;pre&gt;
http://www.mycoolsite.com/projects/1/jobs/4/edit
&lt;/pre&gt;

	&lt;p&gt;or&lt;/p&gt;


&lt;pre&gt;
http://www.mycoolsite.com/companies/2/jobs/4/edit
&lt;/pre&gt;

	&lt;p&gt;and this will load up the form for a job object.  In my jobs controller, I have a method as such:&lt;/p&gt;


&lt;pre&gt;
class JobsController &amp;lt; ApplicationController
  before_filter :get_dependencies

  def get_dependencies
    #requests will come in from either projects or companies
    @project = Project.find(params[:project_id]) unless params[:project_id].nil?
    @company = Company.find(params[:company_id]) unless params[:company_id].nil?
    @parent = @project || @company
  end
end
&lt;/pre&gt;

	&lt;p&gt;and depending on whether the request came in from a context of a company or a project, the @parent object will contain that object.  The form can also determine if the the parent object is a company or a project and pre-fill that blank with the correct information.  All of this is pretty standard.  The part that I was stuck on was linking to these forms. Given these urls:&lt;/p&gt;


&lt;pre&gt;
http://www.mycoolsite.com/companies/2/jobs
&lt;/pre&gt;
or
&lt;pre&gt;
http://www.mycoolsite.com/projects/1/jobs
&lt;/pre&gt;

	&lt;p&gt;How can I link to the add or edit actions without having to do something un-dry like this:&lt;/p&gt;


&lt;pre&gt;
- if @parent.is_a? Project
  =link_to 'Edit', edit_project_job_path(@parent, job)
- else
  =link_to 'Edit', edit_company_job_path(@parent, job)
&lt;/pre&gt;

	&lt;p&gt;Well, the solution is simple, clear &#38; concise&#8212;Would you expect anything less from RoR? :)&lt;/p&gt;


&lt;pre&gt;
link_to 'Edit', edit_polymorphic_path([@parent,job])
&lt;/pre&gt;

	&lt;p&gt;This will automatically determine the parent object and it&#8217;s associated restful path along with the current jobs restful path.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-02-21:110</id>
    <published>2009-02-21T00:03:00Z</published>
    <updated>2009-02-21T00:42:06Z</updated>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="tutorials"/>
    <link href="http://blog.mcmoyer.com/2009/2/21/getting-freetds-to-work-on-centos-5-2" rel="alternate" type="text/html"/>
    <title>Getting FreeTDS to work on CentOS 5.2</title>
<content type="html">
            &lt;p&gt;Recently I had to finally bite the bullet and get my Linux VM&#8217;s talking with MS SqlServer.  After much trial and error and umpteen tutorial sites, I have finally figured out how to do this&#8230;..and the amazing thing is that is dead simple.&lt;/p&gt;


	&lt;p&gt;First off, all of this was executed as root:&lt;/p&gt;


&lt;pre&gt;yum install freetds-devel unixODBC-devel&lt;/pre&gt;
This will install not only these packages, but the freetds and unixODBC ones as well
and install the libraries &#8216;libtdsS.so&#8217; and &#8216;libtdsodbc.so&#8217; in the /usr/lib folder
&lt;pre&gt;vim /etc/freetds.conf&lt;/pre&gt;
- in the global section change &#8220;tds version&#8221; to 8.0
&lt;pre&gt;
vim /etc/odbcinst.ini&lt;/pre&gt;
 &#8212;add an entry for FreeTDS
&lt;pre&gt;
[FreeTDS]
Description     = ODBC for SqlServer
Driver          = /usr/lib/libtdsodbc.so
Setup           = /usr/lib/libtdsS.so
FileUsage       = 1
&lt;/pre&gt;
once this has been done, you should be able to connection up to your SqlServer machine
&lt;pre&gt;
tsql -S &amp;lt;server-ip&amp;gt; -U &amp;lt;username&amp;gt; -P &amp;lt;password&amp;gt;
&lt;/pre&gt;
you will now be in a shell and can test is by doing this
&lt;pre&gt;
use &amp;lt;actual database name&amp;gt;
go
select * from &amp;lt;actual table name&amp;gt;
go
&lt;/pre&gt;
Normally, at this point, I install Ruby Enterprise Edition.  I use this as my only ruby installation on the machine.  I won&#8217;t go into how to install it because http://www.rubyenterpriseedition.com/ has great documentation already.

	&lt;p&gt;Next, download ruby-odbc from http://www.ch-werner.de/rubyodbc/&lt;/p&gt;


Once downloaded, do the following
&lt;pre&gt;
tar zxvf ruby-odbc-0.xxxx #replace the xxxx with the current version
cd ruby-odbc-0.xxxx 
ruby extconf.rb
make
make install
&lt;/pre&gt;

Next, grab the gems you&#8217;ll need
&lt;pre&gt;
gem install dbi
gem install dbd-odbc
gem install rails-sqlserver-2000-2005-adapter -s http://gems.github.com
&lt;/pre&gt;

That&#8217;s it!  At this point you can make a new rails app and modify the database.yml file to look similar to this:
&lt;pre&gt;
development:
  adapter: sqlserver
  mode: odbc
  dsn: Driver=FreeTDS;Server=10.x.x.x;Database=dbBoring;Uid=sa;Pwd=password1
&lt;/pre&gt;

	&lt;p&gt;There is an option to edit the file /etc/odbc.ini and define your dsn&#8217;s there, but that didn&#8217;t feel too dry to me so I define them only in the database.yml file.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-01-07:95</id>
    <published>2009-01-07T10:26:00Z</published>
    <updated>2009-01-07T17:37:00Z</updated>
    <category term="Flex Builder"/>
    <link href="http://blog.mcmoyer.com/2009/1/7/flex-builder-3-on-the-osx" rel="alternate" type="text/html"/>
    <title>Flex Builder 3 on the OSX</title>
<content type="html">
            &lt;p&gt;After days of watching Flex Builder 3 crash as soon as I opened it, I figured out how to fix it.  It seems that Flex Builder doesn&#8217;t like the 64 bit version of Java 1.6 that &lt;span class=&quot;caps&quot;&gt;OSX&lt;/span&gt; now uses.  I had thought this might be an issue so I used the Java Prefences pane to move Java 1.5 up as my default.  It didn&#8217;t change a thing.  I downloaded eclipse to see if it was a Flex Builder issue or an Eclipse issue.   Turns out it&#8217;s and Eclipse issue.&lt;/p&gt;


	&lt;p&gt;The solution:  You need to specify the exact &lt;span class=&quot;caps&quot;&gt;JVM&lt;/span&gt; in the Info.plist file.  You can find this file Flex Builder.app -&amp;gt; Contents -&amp;gt; Info.plist&lt;/p&gt;


	&lt;p&gt;Open that up in your favorite text editor and add a line like so:&lt;/p&gt;


&lt;pre&gt;
 &amp;lt;key&amp;gt;Eclipse&amp;lt;/key&amp;gt;
  &amp;lt;array&amp;gt;
      &amp;lt;string&amp;gt;-startup&amp;lt;/string&amp;gt;
       &amp;lt;string&amp;gt;../../../startup.jar&amp;lt;/string&amp;gt;
      &amp;lt;string&amp;gt;-vm&amp;lt;/string&amp;gt;&amp;lt;string&amp;gt;/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java&amp;lt;/string&amp;gt;

&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2009-01-02:89</id>
    <published>2009-01-02T08:37:00Z</published>
    <updated>2009-01-02T14:44:36Z</updated>
    <category term="resolutions"/>
    <link href="http://blog.mcmoyer.com/2009/1/2/it-s-2009" rel="alternate" type="text/html"/>
    <title>It's 2009</title>
<content type="html">
            &lt;p&gt;It&#8217;s 2009 and it&#8217;s time for those pesky resolutions.&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Start blogging more.  The Rails community has helped me out immensely and it&#8217;s time to start giving back.&lt;/li&gt;
		&lt;li&gt;Port over all those legacy apps at work that need updating but don&#8217;t get them because it&#8217;s too painful to refactor the old code.&lt;/li&gt;
		&lt;li&gt;Learn &lt;span class=&quot;caps&quot;&gt;VIM&lt;/span&gt;&#8230;.no &lt;span class=&quot;caps&quot;&gt;REALLY&lt;/span&gt; learn &lt;span class=&quot;caps&quot;&gt;VIM&lt;/span&gt;.  I think my productivity would increase two-fold once I got good at it.&lt;/li&gt;
		&lt;li&gt;This one&#8217;s no surprise &#8211; Lose weight.  I&#8217;ve been carrying around an extra 30 lbs that needs to go away.&lt;/li&gt;
		&lt;li&gt;Write my own blog software.&lt;/li&gt;
	&lt;/ol&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2008-09-22:60</id>
    <published>2008-09-22T12:12:00Z</published>
    <updated>2008-09-22T17:15:07Z</updated>
    <link href="http://blog.mcmoyer.com/2008/9/22/meme-me" rel="alternate" type="text/html"/>
    <title>Meme(me)</title>
<content type="html">
            &lt;p&gt;From &lt;a href=&quot;http://www.reybango.com/index.cfm/2008/9/22/Mememe&quot;&gt;Rey Bango&#8217;s Blog&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;1. Take a picture of yourself right now.
2. Don't change your clothes, don't fix your hair... just take a picture.
3. Post that picture with NO editing.
4. Post these instructions with your picture.&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2008-09-19:59</id>
    <published>2008-09-19T15:23:00Z</published>
    <updated>2008-09-19T20:45:25Z</updated>
    <category term="ruby rails"/>
    <link href="http://blog.mcmoyer.com/2008/9/19/stuck-on-windows-but-develop-in-rails" rel="alternate" type="text/html"/>
    <title>Stuck on Windows but develop in Rails</title>
<content type="html">
            &lt;p&gt;I&#8217;&#8216;ve got a problem.  I work in an all windows shop, but I develop in rails.  Normally, that&#8217;s not such a big deal, but every once in a while, you find a plugin or gem that only works in linux.  Usually, I&#8217;d through together a virtual machine loaded with linux and develop that way.  It&#8217;s kinda a pain though, having to set up samba shares and editing your code &#8220;remotely&#8221;.&lt;/p&gt;


	&lt;p&gt;Recently, I found a project called andLinux (andLinux.org).  This is a modified linux kernel that runs inside of Windows.  It ships with a basic set of tools, Konquerer, Kate, Konsole, .etc&#8230;.oh, I did I mention it&#8217;s &lt;span class=&quot;caps&quot;&gt;KDE&lt;/span&gt; based :)  All of these programs can interact directly with the windows desktop.  As a matter of fact, now I have a right-click option to edit xml files in Kate.&lt;/p&gt;


	&lt;p&gt;The really cool part though is how I can develop rails apps.  After I installed andLinux, I compiled ruby.  I installed Apache2, Mysql, Passenger Phusion (mod_rails) and Rails and a host of other gems.  The andLinux distro is able to see your windows hard drives by default, so in my Apache config, I pointed directly to the mounted windows directory where my source files exist.  In the linux terminal I can script/server and go back to Netbeans on windows and edit to my hearts content.&lt;/p&gt;


	&lt;p&gt;I used these two links to configure the server.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://blog.fiveruns.com/2008/3/3/compiling-ruby-rubygems-and-rails-on-ubuntu&quot;&gt;Compiling Ruby, Rubygems and Rails on Ubuntu&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://sysadminschronicles.com/2008/05/06/ubuntu-8-04-rails-server-using-passenger&quot;&gt;Setting up Ubuntu and Passenger&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2008-08-26:49</id>
    <published>2008-08-26T02:11:00Z</published>
    <updated>2008-08-27T02:30:44Z</updated>
    <category term="Prius"/>
    <link href="http://blog.mcmoyer.com/2008/8/26/audio-sanity-restored" rel="alternate" type="text/html"/>
    <title>Audio Sanity Restored</title>
<content type="html">
            &lt;p&gt;I own a 2008 Toyota Prius.  It&#8217;s got a handy aux-in jack in the console.  The first day I had it, I had my iPod plugged into through a Belkin power/aux out adapter.  It was great.  The iPod stayed charged and my music sounded great.  Things were good.&lt;/p&gt;


	&lt;p&gt;Fast forward to August when I got my iPhone 3G (yay!).  This was the answer to a lot of my problems.  I&#8217;ve missed countless calls because my iPod has been turned up louder than my phone can ring.  The iPhone would solve that by performing both functions.  So, imagine my disappointment when I plugged in my iPod to my Belkin cord and I get a message stating that &#8220;Charging is not supported with the accessory&#8221;.....oh well, I&#8217;ll just listen to the music until it dies.  Que &#8216;Der Kommisar&#8217;:&lt;/p&gt;


	&lt;p&gt;bumda bum bum bum bum&#8230;bumda bwah bwah bwah..eeeeeeeee&#8230;....bumda bum bum bum&#8230;bumda bwah bwah bwah bwah eeeeeeeee&#8230;..&lt;/p&gt;


	&lt;p&gt;What in the hell is that whining sound!?  Come to find out, the iPhone 3g suffers from a ground loop isolation problem whereas the iPod didn&#8217;t.  My next step was to buy a new adapter for the iPhone&#8230;.Yikes!  $49.99 for the Griffin Auto Pilot Aux&#8230;.&lt;/p&gt;


	&lt;p&gt;I went straight to the car, plugged in the adapter popped the iPhone on it and was greeted by that annoying &#8216;weeeeeeeeeeeeeeeeeeeeeeeee!&#8217;&lt;/p&gt;


	&lt;p&gt;More research&#8230;..&lt;/p&gt;


	&lt;p&gt;I found this device: &lt;a href=&quot;http://www.sonicelectronix.com/item_8987_PAC+SNI-1-3.5.html&quot;&gt;&lt;span class=&quot;caps&quot;&gt;PAC SNI&lt;/span&gt;-1/3.5&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;It only took a couple of days to get here, but since I drive 100 mile round trip to work each day&#8230;it seemed like an excruciatingly long time.  Interestingly, radio is still more irritating than listening to the incessant &#8216;weeeeeeeeeeeeeeeeeeeee&#8217;.  Anyway, plugged it in tonight.  Plugged the ipod into it and viola!, instant silence.  As far as I can tell, the signal isn&#8217;t noticeably degraded.  The highs still sound sharp and the bass isn&#8217;t muffled (any more than the stock Toyota speakers make it)&lt;/p&gt;


	&lt;p&gt;So, do your ears a favor and get this thing&#8230;.it&#8217;s the best $14 I&#8217;ve spent in a long time.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2008-04-14:31</id>
    <published>2008-04-14T12:56:00Z</published>
    <updated>2008-04-14T19:03:48Z</updated>
    <category term="Rails"/>
    <link href="http://blog.mcmoyer.com/2008/4/14/it-s-been-awhile" rel="alternate" type="text/html"/>
    <title>It's been awhile</title>
<content type="html">
            &lt;p&gt;It&#8217;s been awhile since I&#8217;ve written anything.  I&#8217;ve been deep into sites using Ruby/Rails, but now I&#8217;ve started playing around with JRuby/Rails.  As such, I want to write down the steps to connect to a sqlserver database from JRuby.&lt;/p&gt;


	&lt;p&gt;First, download the sqlserver.jar file from Microsoft.  Place it in the lib directory of your JRuby installation.&lt;/p&gt;


	&lt;p&gt;Second, configure your database.yml file to read like so:&lt;/p&gt;


&lt;pre&gt;
ActiveRecord::Base.establish_connection(
    :adapter=&amp;gt; 'jdbc',
    :url=&amp;gt; 'jdbc:sqlserver://MyDatabaseServer;databaseName=MyDataBaseName',
    :driver =&amp;gt; 'com.microsoft.jdbc.sqlserver.SQLServerDriver',
    :username=&amp;gt;'xxxxxxxx',
    :password=&amp;gt;'xxxxxxxx'
    )
&lt;/pre&gt;

	&lt;p&gt;Thirdly&#8230;..there is not step three!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2007-10-05:30</id>
    <published>2007-10-05T16:27:00Z</published>
    <updated>2007-10-05T16:30:56Z</updated>
    <category term="Rails"/>
    <category term="ColdFusion"/>
    <link href="http://blog.mcmoyer.com/2007/10/5/another-reason-i-ve-come-to-love-ruby" rel="alternate" type="text/html"/>
    <title>Another reason I've come to love ruby</title>
<content type="html">
            &lt;p&gt;I still haven&#8217;t given up my subscriptions to my ColdFusion based mailing lists.  Heck I&#8217;ve belonged to them sing 2000.  It&#8217;s almost like leaving family.  Alas I digress, a question came up asking how you would solve this problem in CF.&lt;/p&gt;


&lt;blockquote&gt;
Say that I have a list of allowed nmbers:
32,48,64,72,144,160,200,288,320,400,512,576,640,720,800

	&lt;p&gt;If I give the user the option of selecting a number, and it happens to not be in this list, how might I go about automagically selecting the next lowest number? One exception being if the user selects a number lower than 32, in which case the code should return 32.&lt;/p&gt;


	&lt;p&gt;Examples:
User selects 100, the code would return 72.&lt;/p&gt;


	&lt;p&gt;User selects 480, the code would return 400.&lt;/p&gt;


User selects 25, the code would return 32.
&lt;/blockquote&gt;

	&lt;p&gt;One of the simplest solutions presented was this:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;cfset input = 100 /&amp;gt;
&amp;lt;cfset last = listFirst(numbers) /&amp;gt;

&amp;lt;cfloop list=&quot;#numbers#&quot; index=&quot;num&quot;&amp;gt;
  &amp;lt;cfif num GT input&amp;gt;
   &amp;lt;cfbreak /&amp;gt;
 &amp;lt;/cfif&amp;gt;
 &amp;lt;cfset last = num /&amp;gt;
&amp;lt;/cfloop&amp;gt;

#last#
&lt;/pre&gt;

	&lt;p&gt;I thought, how would I do this in ruby.  Here&#8217;s what I came up with.  Definitely more elegant than the above code:&lt;/p&gt;


&lt;pre&gt;
# our test input
input = 25

# change the list to an array
nums = &quot;32,48,64,72,144,160,200,288,320,400,512,576,640,720,800&quot;.split(&quot;,&quot;)

# find all the numbers which would be smaller
target = nums.find_all {|num| input &amp;gt;= num.to_i }

# take the last element of the found elements, or if nil return the first 
# element of the original array
puts target.last || nums.first
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.mcmoyer.com/">
    <author>
      <name>mcmoyer</name>
    </author>
    <id>tag:blog.mcmoyer.com,2007-09-18:26</id>
    <published>2007-09-18T18:45:00Z</published>
    <updated>2007-09-18T19:12:57Z</updated>
    <category term="Rails"/>
    <category term="rails"/>
    <category term="sqlserver"/>
    <link href="http://blog.mcmoyer.com/2007/9/18/using-ms-sqlserver-with-rails" rel="alternate" type="text/html"/>
    <title>Using MS SQLServer with Rails</title>
<content type="html">
            &lt;p&gt;Rails and Microsoft SQLServer don&#8217;t seem to be the best of friends, particularly when consider blob images.  I&#8217;ve outlined the steps that I had to cruft support for better binary support in MS SQLServer.  Now, not all of this is my doing.  A lot of the code was lifted from a sqlserver thread in the Ruby on Rails mailing list.&lt;/p&gt;


	&lt;p&gt;First off, download the &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; Native Client from Microsoft.  This new provider has better support for statements longer than 8k.  (About Time!)&lt;/p&gt;


	&lt;p&gt;Next, modify &lt;span class=&quot;caps&quot;&gt;ADO&lt;/span&gt;.rb so that the execute method reads like so:&lt;/p&gt;


&lt;pre&gt;
  def execute
    # TODO: use Command and Parameter
    # TODO: substitute all ? by the parametes
    # if there are no params, avoid the expensive scan operation of bind
    if @params.length &amp;gt; 0
        sql = bind(self, @statement, @params)
    else
        sql = @statement
    end

    @res_handle = @handle.Execute(sql) 
    # TODO: SELECT and AutoCommit finishes the result-set
    #       what to do?
    if @db['AutoCommit'] == true and not SQL.query?(@statement) then
      @db.commit
    end

  rescue RuntimeError =&amp;gt; err
    raise DBI::DatabaseError.new(err.message)
  end
&lt;/pre&gt;

	&lt;p&gt;There&#8217;s a relatively expensive scan operation in the bind operation that really chokes when binary content is sent to it.&lt;/p&gt;


	&lt;p&gt;In the sqlserver_adapter.rb file, modify the the following functions:&lt;/p&gt;


&lt;pre&gt;
  def self.string_to_binary(value)
    '0x'+value.unpack('H*').to_s
  end

  def self.binary_to_string(value)
    if value.kind_of? Array
      value.map {|c| c.chr}.join
    else
      value
    end
  end
&lt;/pre&gt;

	&lt;p&gt;Also, modify the Base class inside sqlserver adapter like so:&lt;/p&gt;


&lt;pre&gt;
module ActiveRecord
  class Base
    def self.sqlserver_connection(config) #:nodoc:
      require_library_or_gem 'dbi' unless self.class.const_defined?(:DBI)

      config = config.symbolize_keys

      mode        = config[:mode] ? config[:mode].to_s.upcase : 'ADO'
      username    = config[:username] ? config[:username].to_s : 'sa'
      password    = config[:password] ? config[:password].to_s : ''
      provider      = config[:provider] ? config[:provider].to_s : 'SQLOLEDB'
      autocommit  = config.key?(:autocommit) ? config[:autocommit] : true
      if mode == &quot;ODBC&quot; 
        raise ArgumentError, &quot;Missing DSN. Argument ':dsn' must be set in order for this adapter to work.&quot; unless config.has_key?(:dsn)
        dsn       = config[:dsn]
        driver_url = &quot;DBI:ODBC:#{dsn}&quot; 
      else
        raise ArgumentError, &quot;Missing Database. Argument ':database' must be set in order for this adapter to work.&quot; unless config.has_key?(:database)
        database  = config[:database]
        host      = config[:host] ? config[:host].to_s : 'localhost'
        driver_url = &quot;DBI:ADO:Provider=#{provider};Data Source=#{host};Initial Catalog=#{database};User Id=#{username};Password=#{password};&quot; 
      end
      conn      = DBI.connect(driver_url, username, password)
      conn[&quot;AutoCommit&quot;] = autocommit
      ConnectionAdapters::SQLServerAdapter.new(conn, logger, [driver_url, username, password])
    end
  end # class Base

&lt;/pre&gt;

&lt;pre&gt;
  def type_cast(value)
    return nil if value.nil? || value =~ /^\s*null\s*$/i
    case type
    when :datetime  then cast_to_datetime(value)
    when :timestamp then cast_to_time(value)
    when :time      then cast_to_time(value)
    when :date      then cast_to_datetime(value)
    when :boolean   then value == true or (value =~ /^t(rue)?$/i) == 0 or value.to_s == '1'
    else super
    end
  end
&lt;/pre&gt;

&lt;pre&gt;
  def quote(value, column = nil)
    return value.quoted_id if value.respond_to?(:quoted_id)

    case value
      when String
        if column &#38;&#38; column.type == :binary
            column.class.string_to_binary(value)
        else
            super
        end
      when TrueClass             then '1'
      when FalseClass            then '0'
      when Time, DateTime        then &quot;'#{value.strftime(&quot;%Y%m%d %H:%M:%S&quot;)}'&quot; 
      when Date                  then &quot;'#{value.strftime(&quot;%Y%m%d&quot;)}'&quot; 
      else                       super
    end
  end
&lt;/pre&gt;

	&lt;p&gt;Make sure to use &lt;span class=&quot;caps&quot;&gt;SQLNCLI&lt;/span&gt; as your provider in your database.yml and you should be golden!  I&#8217;ve tested this with files up to 12 meg.  50 meg files caused the interpreter to crash.&lt;/p&gt;
          </content>  </entry>
</feed>
