<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>doMonkeydo - Home</title>
  <id>tag:www.domonkeydo.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://www.domonkeydo.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.domonkeydo.com/" rel="alternate" type="text/html"/>
  <updated>2008-04-17T13:21:56Z</updated>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-04-17:32</id>
    <published>2008-04-17T13:18:00Z</published>
    <updated>2008-04-17T13:21:56Z</updated>
    <link href="http://www.domonkeydo.com/2008/4/17/fix-the-cannot-unmount-disk-error-when-erasing-time-machine-backup" rel="alternate" type="text/html"/>
    <title>Fix the "Cannot unmount disk" error when erasing Time Machine backup</title>
<content type="html">
            &lt;p&gt;If you have tried to erase the contents of your Time machine backup (external drive) and received the &#8220;Cannot unmount disk&#8221; error &#8211; no fear.  I too have received the error and resolved it by plugging the external drive into a &lt;em&gt;different&lt;/em&gt; mac and used the disk utility to erase it.  &lt;em&gt;Don&#8217;t forget to choose the Max OS Extended (Journaled) option for Time Machine.&lt;/em&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-04-16:21</id>
    <published>2008-04-16T04:32:00Z</published>
    <updated>2008-04-16T04:38:15Z</updated>
    <link href="http://www.domonkeydo.com/2008/4/16/how-to-parse-a-response-soap-message-using-soap4r" rel="alternate" type="text/html"/>
    <title>How to parse a response soap message using soap4r</title>
<content type="html">
            &lt;p&gt;Soap4r is a very helpful utility.  Using &#8216;wsdl2ruby&#8217; you can generate local methods to invoke web service methods via &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt;.&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;wsdl2ruby.rb --wsdl path_to_your_wsdl --type client | server&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;The only problem I had with soap4r during my implementation was the difficulty I had with manually parsing the soap response from the web service.  Though the web service methods were generated perfectly, I needed additional information from the soap response (the soap header information, not to be confused with the http header info) that was not provided by the wsdl, thus left out of the wsdl2ruby code generation.&lt;/p&gt;


	&lt;p&gt;SOAP4r uses a private &lt;em&gt;send_post&lt;/em&gt; method in the HTTPStreamHandler class of the &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt; module.  In the &lt;em&gt;send_post&lt;/em&gt; method an net/http instance uses the &lt;em&gt;post&lt;/em&gt; method to post the message as a string to the whichever url was sent in the &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt; call.  The &lt;em&gt;post&lt;/em&gt; method returns the response from the remote server.  However, HTTPStreamHandler does not make this available to you.  To change all you need to do is make the response variable an instance variable.&lt;/p&gt;


	&lt;p&gt;The new &lt;em&gt;res&lt;/em&gt; instance variable will return an &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt;::Message class.  You will then need to access the body instance variable in the Body class.  However, this will also need an accessor method monkey-patched through &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt;::Message::Body.  (Also included below)&lt;/p&gt;


	&lt;h3&gt;Monkey-patch the private &lt;em&gt;send_post&lt;/em&gt; method in &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt;::HTTPStreamHandler to change the &lt;em&gt;res&lt;/em&gt; local variable to an instance variable&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt; &lt;pre&gt;module SOAP
  class HTTPStreamHandler
  attr_accessor :res
  private
    def send_post(url, conn_data, charset)
        conn_data.send_contenttype ||= StreamHandler.create_media_type(charset)
        if @wiredump_file_base
          filename = @wiredump_file_base + '_request.xml'
          f = File.open(filename, &quot;w&quot;)
          f &amp;lt;&amp;lt; conn_data.send_string
          f.close
        end

        extheader = {}
        extheader['Content-Type'] = conn_data.send_contenttype
        extheader['SOAPAction'] = &quot;\&quot;#{ conn_data.soapaction }\&quot;&quot; 
        extheader['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip?
        send_string = conn_data.send_string
        @wiredump_dev &amp;lt;&amp;lt; &quot;Wire dumped:\n\n&quot; if @wiredump_dev
        begin
          retry_count = 0
          while true
            %{color:red}@res% = @client.post(url, send_string, extheader)
            if RETRYABLE and HTTP::Status.redirect?(@res.status)
              retry_count += 1
                if retry_count &amp;gt;= MAX_RETRY_COUNT
                  raise HTTPStreamError.new(&quot;redirect count exceeded&quot;)
                end
              url = @res.header[&quot;location&quot;][0]
             puts &quot;redirected to #{url}&quot; if $DEBUG
            else
              break
            end
         end
        rescue
          @client.reset(url)
        raise
       end
       @wiredump_dev &amp;lt;&amp;lt; &quot;\n\n&quot; if @wiredump_dev
       receive_string = @res.content
       if @wiredump_file_base
         filename = @wiredump_file_base + '_response.xml'
         f = File.open(filename, &quot;w&quot;)
         f &amp;lt;&amp;lt; receive_string
         f.close
       end
       case @res.status
       when 405
         raise PostUnavailableError.new(&quot;#{ @res.status }: #{ @res.reason }&quot;)
       when 200, 202, 500
         # Nothing to do.  202 is for oneway service.
       else
        raise HTTPStreamError.new(&quot;#{ @res.status }: #{ @res.reason }&quot;)
       end

      # decode gzipped content, if we know it's there from the headers
      if @res.respond_to?(:header) and !@res.header['content-encoding'].empty? and
          @res.header['content-encoding'][0].downcase == 'gzip'
        receive_string = decode_gzip(receive_string)
      # otherwise check for the gzip header
      elsif @accept_encoding_gzip &#38;&#38; receive_string[0..1] == &quot;\x1f\x8b&quot; 
        receive_string = decode_gzip(receive_string)
      end
      conn_data.receive_string = receive_string
      conn_data.receive_contenttype = @res.contenttype
      conn_data
    end
  end
end

module HTTP
    class Message::Body    
      attr_accessor :body
    end
end
&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;After the monkey-patching, the response message will be accessible after invoking a web service method using the client class generated by wsdl2ruby.  The response message will become available in the res accessor method through the streamhandler method of the client class that was generated by wsdl2ruby.  The class will be called something like &#8220;ClientAPISoap&#8221; &#8211; this will be defined in the defaultDriver.rb file.&lt;/p&gt;


	&lt;p&gt;In my case:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt; driver = ClientAPISoap.new
results = driver.some_ws_method(with_parameters).getResults 
#getResults is also a ws method
raw_response_message = driver.streamhandler.res.body.body
&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;You can then use &lt;span class=&quot;caps&quot;&gt;REXML&lt;/span&gt; to parse whatever you need in the &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt; response message body.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-04-11:15</id>
    <published>2008-04-11T20:47:00Z</published>
    <updated>2008-04-11T20:50:28Z</updated>
    <link href="http://www.domonkeydo.com/2008/4/11/how-to-test-production-rails-exceptions-while-in-development-mode" rel="alternate" type="text/html"/>
    <title>How to test production rails exceptions while in development mode </title>
<content type="html">
            &lt;p&gt;Recently found an easy way to test rails exceptions raised in production while in development.&lt;/p&gt;


	&lt;p&gt;Though you could just as easily use:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;script/server -e production&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Short of that the following works perfectly:&lt;/p&gt;


	&lt;h3&gt;Update config/development.rb&lt;/h3&gt;


change: 
	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;config.action_controller.consider_all_requests_local = false&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


to:
	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;config.action_controller.consider_all_requests_local = true&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;h3&gt;Then update controllers/application.rb&lt;/h3&gt;


add as the last method (unless you have additional protected methods then add to those):
	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt; 
protected
  def local_request?
    false
  end
&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;This works because rails will check if a raised exception is a local request.  If it is a local request the &#8220;development&#8221; mode error screen will be presented to you like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://domonkeydo.com/assets/2008/4/11/local_exception_1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Otherwise the 500 or 404 error pages will be displayed to the user.&lt;/p&gt;


	&lt;p&gt;Both modifications are needed since there are two ways a request is considered local 1.) which is controlled in the config folder  and 2.) A request is also considered local if the request is being served on the local machine (127.0.0.1).&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-04-02:4</id>
    <published>2008-04-02T03:49:00Z</published>
    <updated>2008-04-02T03:50:45Z</updated>
    <link href="http://www.domonkeydo.com/2008/4/2/installing-ruby-on-rails-and-rmagick-on-leopard" rel="alternate" type="text/html"/>
    <title>Installing Ruby on Rails, mySQL and Rmagick on Leopard</title>
<content type="html">
            &lt;p&gt;I recently had to reinstall Ruby on Rails and Rmagick on Leopard.  There is a lot of debate surrounding the best way to go &#8211; whether it be by source, by MacPorts, by Fink or by anything else I don&#8217;t know about yet.&lt;/p&gt;


	&lt;p&gt;I&#8217;ve gone the Macports route and have yet to regret it.  As according to Paul Sturgess:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;MacPorts (formerly known as DarwinPorts) is a package manager that will download, compile and install software, while installing any required dependencies, automatically. You can easily upgrade or deactivate packages you download, it just makes managing everything that much easier.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;&lt;a href=&quot;http://paulsturgess.co.uk/articles/show/46-using-macportsdarwinports-to-install-ruby-on-rails-mysql-subversion-capistrano-and-mongrel-on-mac-os-x&quot;&gt;Paul Sturgess&#8217; article provides an excellent step-by-step guide that had me running on a Macported Ruby on Rails installation in no time at all.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Quick points from Paul Sturgess:&lt;/p&gt;


	&lt;h3&gt;Set up your path environment variables:&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;PATH=&quot;/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin&quot;&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;h3&gt;Install mySQL, Ruby, and maybe Subversion:&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;sudo port selfupdate
sudo port install mysql5 +server
sudo port install ruby
sudo port install rb-rubygems
sudo port install rb-termios
sudo port install rb-mysql
sudo port install subversion +tools
&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;h3&gt;Add a symbolic link to the mysql5 mysqld.sock:&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;sudo ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;h3&gt;Make sure Mysql5 starts up whenever the machine is rebooted with:&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;h3&gt;Install Ruby on Rails and others:&lt;/h3&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;sudo gem install -y rake
sudo gem install -y rails
sudo gem install -y capistrano
sudo gem install -y mongrel
sudo gem install -y mongrel_cluster&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;In addition, &lt;a href=&quot;http://nullstyle.com/2007/10/27/how-to-build-imagemagick-and-install-rmagick-with-macports-on-mac-os-x-leopard/&quot;&gt;Educate. Liberate.&lt;/a&gt; provides the simple rules to follow to get Rmagick properly installed once you&#8217;re rolling on Rails goodness.&lt;/p&gt;


	&lt;p&gt;Quick points from Educate.Liberate.:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&lt;pre&gt;sudo port install tiff -macosx
sudo port install ImageMagick
sudo gem install rmagick&lt;/pre&gt;&lt;/p&gt;
	&lt;/blockquote&gt;
          </content>  </entry>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-03-19:3</id>
    <published>2008-03-19T03:04:00Z</published>
    <updated>2008-03-19T03:10:46Z</updated>
    <link href="http://www.domonkeydo.com/2008/3/19/a-lesson-in-a-working-htaccess-dreamhost" rel="alternate" type="text/html"/>
    <title>A lesson in a working Dreamhost .htaccess</title>
<content type="html">
            &lt;pre&gt;
&lt;code&gt;
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
# 
# Example:
#   RewriteCond %{REQUEST_URI} ^/notrails.*
#   RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
# 
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
#   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
#   Alias /myrailsapp /path/to/myrailsapp/public
#   RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
# 
# Example:
#   ErrorDocument 500 /500.html

ErrorDocument 500 &quot;&amp;lt;h2&amp;gt;Application error&amp;lt;/h2&amp;gt;Rails application failed to start properly&quot;
&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://www.domonkeydo.com/">
    <author>
      <name>win</name>
    </author>
    <id>tag:www.domonkeydo.com,2008-03-18:1</id>
    <published>2008-03-18T04:13:00Z</published>
    <updated>2008-03-18T04:42:12Z</updated>
    <link href="http://www.domonkeydo.com/2008/3/18/rebirth-of-the-blog" rel="alternate" type="text/html"/>
    <title>Rebirth of the blog</title>
<content type="html">
            &lt;p&gt;I had a blog before this one - not a good one, or even one worth talking about - but I've decided to change it up anyway.  Its customary for curious neophytes of the geeky inclination to try out and explore the newest in technology so with this in mind I have traded in my Dreamhost-approved Wordpress for a brand-spanking new Ruby on Rails-powered supercool Mephisto blog.  However, before taking on such a task my research left me a little more than just a little intimidated about installing Mephisto on my Dreamhost account.&lt;/p&gt;

&lt;p&gt;Fortunately, braver and much smarter geeks ahead of me have decided to help us out by blogging their successes and more importantly their failures.  Of the blogs chronicling the journey of installing Mephisto on Dreamhost  &lt;a href=&quot;http://mede.us/2006/12/1/mephisto-and-dreamhost&quot;&gt;Medeus&lt;/a&gt; made the installation about as smooth as any I'd ever tried - WITH THE ADDITION of creating a new Dreamhost user to get rid of the common error below:&lt;/p&gt;
&lt;p&gt;FastCGI: incomplete headers (0 bytes) received from server&lt;/p&gt;

&lt;p&gt;Follow the instructions and you should be sailing in no time.&lt;/p&gt;
          </content>  </entry>
</feed>
