<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Software Warlock &#187; Warlock</title>
	<atom:link href="http://softwareblog.morlok.net/author/warlock/feed/" rel="self" type="application/rss+xml" />
	<link>http://softwareblog.morlok.net</link>
	<description></description>
	<lastBuildDate>Sat, 24 Dec 2011 16:06:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>OCaml to JavaScript</title>
		<link>http://softwareblog.morlok.net/2011/12/24/ocaml-to-javascript/</link>
		<comments>http://softwareblog.morlok.net/2011/12/24/ocaml-to-javascript/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 16:06:59 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[OCaml]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=438</guid>
		<description><![CDATA[I&#8217;ve always had a soft spot for OCaml, today I found an OCaml to JavaScript compiler. This could be interesting to use with the Opa framework.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always had a soft spot for OCaml, today I found an <a href="http://ocsigen.org/js_of_ocaml/">OCaml to JavaScript compiler</a>. This could be interesting to use with the <a href="http://opalang.org/">Opa framework</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/12/24/ocaml-to-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BugAid</title>
		<link>http://softwareblog.morlok.net/2011/12/23/bugaid/</link>
		<comments>http://softwareblog.morlok.net/2011/12/23/bugaid/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 13:52:22 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=435</guid>
		<description><![CDATA[I&#8217;m excited; I just read this blog post about BugAid, a Visual Studio add-on that has many features I&#8217;ve often wanted myself. Chief among them is the ability to search through a live object for data. When you are working &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/12/23/bugaid/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited; I just read <a href="http://visualstudioaddins.svprogramming.net/2011/12/22/bugaid-tool-for-visual-studio-review/">this blog post</a> about <a href="http://www.bugaidsoftware.com/">BugAid</a>, a Visual Studio add-on that has many features I&#8217;ve often wanted myself. Chief among them is the ability to search through a live object for data. When you are working with an unfamiliar code base and you are trying to track how data flows through the system, this can be very useful. Another cool feature is that it shows the partial evaluation of expressions within an if statement. Very cool. Going to install the beta today.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/12/23/bugaid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Taking a Screenshot From Scala</title>
		<link>http://softwareblog.morlok.net/2011/09/23/taking-a-screenshot-from-scala/</link>
		<comments>http://softwareblog.morlok.net/2011/09/23/taking-a-screenshot-from-scala/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 03:40:13 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=431</guid>
		<description><![CDATA[This is a bit of a cheat, it&#8217;s just really using the Java libraries from here and here. import java.awt._ import java.io._ import javax.imageio._ def captureScreenshot(filepath : String) = { val screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) val capture = new Robot().createScreenCapture(screenRect) &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/09/23/taking-a-screenshot-from-scala/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>This is a bit of a cheat, it&#8217;s just really using the Java libraries from <a href="http://www.codinguide.com/2010/04/capture-screen-shot-from-java.html">here</a> and <a href="http://stackoverflow.com/questions/58305/java-is-there-a-way-to-take-a-screenshot-using-java-and-save-it-to-some-sort-of">here</a>.</p>
<pre>
import java.awt._
import java.io._
import javax.imageio._

def captureScreenshot(filepath : String) = {
  val screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())
  val capture = new Robot().createScreenCapture(screenRect)
  ImageIO.write(capture, "png", new File(filepath, "screen.png"))
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/09/23/taking-a-screenshot-from-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting DOC&gt; output when running script in SQL*Plus</title>
		<link>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/</link>
		<comments>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 16:37:51 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[SQL*Plus]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=427</guid>
		<description><![CDATA[Just ran across a problem where I would run a script that worked fine in Oracle SQL Developer, but didn&#8217;t work in SQL*Plus. When I&#8217;d load the script, I&#8217;d see parts of the script output back to me even though &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just ran across a problem where I would run a script that worked fine in <a href="http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html">Oracle SQL Developer</a>, but didn&#8217;t work in SQL*Plus. When I&#8217;d load the script, I&#8217;d see parts of the script output back to me even though I had echo off:</p>
<pre>
SQL> @ "foo.sql"
DOC>
DOC>  -- The GUID of the document i
DOC>  doc_guid varchar2(33) not null
DOC>);
DOC>
DOC>create table mx_values (
DOC>  mx_values_id varchar2(33) not null primary key,
DOC>  value_id integer not null,
</pre>
<p>The problem turned out to be caused by having newlines in my SQL commands. E.g.:
<pre name="code" class="sql">
CREATE TABLE foo (
  -- The id of the foo
  id integer not null,

  -- The data of the foo
  data varchar2(200) not null
);
</pre>
<p>I did this to provide visual breaks in the code. SQL Developer was fine with it, but SQL*Plus blew up. My solution was to just make the empty lines comments using the <tt>--</tt> comment syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/08/15/getting-doc-output-when-running-script-in-sqlplus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error with MySQL 5.5.8 on OS X</title>
		<link>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/</link>
		<comments>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 02:33:04 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=423</guid>
		<description><![CDATA[I just installed MySQL 5.5.8 on my Mac and ran into problems when I tried to start it from the preferences pane. Looking in the console logs, I found the following message: 1/26/11 26 Jan 8:13:49 PM [0x0-0x1c61c6].com.apple.systempreferences[88942] /usr/local/mysql/support-files/mysql.server: line &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just installed MySQL 5.5.8 on my Mac and ran into problems when I tried to start it from the preferences pane.  Looking in the console logs, I found the following message:</p>
<p><tt>1/26/11  26 Jan 8:13:49 PM	[0x0-0x1c61c6].com.apple.systempreferences[88942]	/usr/local/mysql/support-files/mysql.server: line 256: my_print_defaults: command not found</tt></p>
<p>A <a href="http://bugs.mysql.com/bug.php?id=53232">MySQL bug thread</a> suggested that the server could be started directly:</p>
<p><tt>sudo /usr/local/mysql/support-files/mysql.server start</tt></p>
<p>however, I got the same error:</p>
<p><tt>$ sudo /usr/local/mysql/support-files/mysql.server start<br />
/usr/local/mysql/support-files/mysql.server: line 256: my_print_defaults: command not found<br />
Starting MySQL<br />
 ERROR! Couldn't find MySQL server (./bin/mysqld_safe)</tt></p>
<p>Later in that <a href="http://bugs.mysql.com/bug.php?id=53232">same bug thread</a>, the actual solution can be found. The problem was a recent update to the mysql.server script. By manually specifying the install location of MySQL on mysql.server line 46:</p>
<p><tt>basedir=/usr/local/mysql</tt></p>
<p>the problem is resolved
<p><tt>$ sudo /usr/local/mysql/support-files/mysql.server start<br />
Starting MySQL<br />
 SUCCESS!<br />
</tt></p>
<p>This also corrects the problem with the preference pane.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2011/01/26/error-with-mysql-5-5-8-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing POST with Rack::Test</title>
		<link>http://softwareblog.morlok.net/2010/12/18/testing-post-with-racktest/</link>
		<comments>http://softwareblog.morlok.net/2010/12/18/testing-post-with-racktest/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 21:00:26 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[Rack]]></category>
		<category><![CDATA[Rack::Test]]></category>
		<category><![CDATA[sintra]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=417</guid>
		<description><![CDATA[The Sinatra testing article gives some great examples of how to test your Sinatra app using Rack::Test. Unfortunately, all the examples given are for testing the GET method, and for those of us new to Ruby/Sinatra/Rack/everything, figuring out how to &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2010/12/18/testing-post-with-racktest/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.sinatrarb.com/testing.html">Sinatra testing article</a> gives some great examples of how to test your Sinatra app using Rack::Test. Unfortunately, all the examples given are for testing the GET method, and for those of us new to Ruby/Sinatra/Rack/everything, figuring out how to specify JSON post data in your POST tests is not immediately obvious. <a href="http://jaywiggins.com/2010/04/lost-sleep-over-json-and-rackpostbodycontenttypeparser/">This article by Jay Wiggins</a> got me on the right track, and I though I&#8217;d summarize.</p>
<p>
The second parameter to the <tt>post</tt> method (or any of the Rack::Test methods) is parameters that are sent up with your request. This is also where you specify your JSON data. The only other thing you need to do is specify your content type as JSON.
</p>
<p>For example, suppose you have specified the following endpoint in Sinatra that expects posted JSON data:</p>
<pre name="code" class="ruby">
post '/foo' do
    data = JSON.parse(request.body.read.to_s)
    # rest of logic here
end
</pre>
<p>You could test that endpoint by posting test JSON like this:</p>
<pre name="code" class="ruby">
def test_create_choice
    post '/foo', {:bar => "baz"}.to_json, "CONTENT_TYPE" => "application/json"
    # validate response here
end
</pre>
<p>Hope this helps any other n00bs out there wondering the same thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2010/12/18/testing-post-with-racktest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Tesseract</title>
		<link>http://softwareblog.morlok.net/2010/12/17/installing-tesseract/</link>
		<comments>http://softwareblog.morlok.net/2010/12/17/installing-tesseract/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 22:06:49 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[ldconfig]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ocr]]></category>
		<category><![CDATA[tesseract]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=415</guid>
		<description><![CDATA[Just a quick heads up for anyone installing Tesseract (Open Source OCR tool), the README does a great job explaining the dependencies and what you need to do to get up and running, but there is one little gotcha. After &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2010/12/17/installing-tesseract/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just a quick heads up for anyone installing <a href="http://code.google.com/p/tesseract-ocr/">Tesseract</a> (Open Source OCR tool), the <a href="http://code.google.com/p/tesseract-ocr/wiki/ReadMe">README</a> does a great job explaining the dependencies and what you need to do to get up and running, but there is one little gotcha. After you run</p>
<p><tt>$ sudo make install</tt></p>
<p>You may still get an error when trying to run tesseract:</p>
<p><tt>$ tesseract foo.png bar<br />
tesseract: error while loading shared libraries: libtesseract_api.so.3 cannot open shared object file: No such file or directory</tt></p>
<p>You need to update the cache for the runtime linker. The following should get you up and running:</p>
<p><tt>$ sudo ldconfig</tt></p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2010/12/17/installing-tesseract/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DataMapper defaults to socket; causes error</title>
		<link>http://softwareblog.morlok.net/2010/12/11/datamapper-defaults-to-socket-causes-error/</link>
		<comments>http://softwareblog.morlok.net/2010/12/11/datamapper-defaults-to-socket-causes-error/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 02:08:22 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[DataMapper]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=409</guid>
		<description><![CDATA[Just started migrating a Ruby project I&#8217;m working on to DataMapper and I found an interesting error. DataMapper.setup(:default, ENV['DATABASE_URL']) Where my DATABASE_URL was set as an environment variable to something along the lines of the following: DATABASE_URL=mysql://username:password@localhost:3306/database_name The key point &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2010/12/11/datamapper-defaults-to-socket-causes-error/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just started migrating a Ruby project I&#8217;m working on to DataMapper and I found an interesting error.</p>
<p><tt><br />
DataMapper.setup(:default, ENV['DATABASE_URL'])<br />
</tt></p>
<p>
Where my DATABASE_URL was set as an environment variable to something along the lines of the following:
</p>
<p><tt><br />
DATABASE_URL=mysql://username:password@localhost:3306/database_name<br />
</tt></p>
<p>The key point to note is that I&#8217;m trying to point it to TCP port 3306 on my local machine. When I&#8217;d trying to load up a model object and hit the database, I got the following error:</p>
<p><tt><br />
DataObjects::SQLError: Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)<br />
</tt></pre>
<p>Full stack trace:</p>
<pre>
DataObjects::SQLError: Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:76:in `initialize'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:76:in `send'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:76:in `__new'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:177:in `new'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:172:in `synchronize'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:172:in `new'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:119:in `new'
	/Library/Ruby/Gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:65:in `new'
	/Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:235:in `open_connection'
	/Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:260:in `with_connection'
	/Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:138:in `read'
	/Library/Ruby/Gems/1.8/gems/dm-core-1.0.2/lib/dm-core/repository.rb:162:in `read'
	/Library/Ruby/Gems/1.8/gems/dm-core-1.0.2/lib/dm-core/model.rb:379:in `first'
	./routes/services.rb:11:in `GET /v1/:choice_id'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:1032:in `call'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:1032:in `compile!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:620:in `instance_eval'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:620:in `route_eval'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:604:in `route!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:656:in `process_route'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:653:in `catch'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:653:in `process_route'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:603:in `route!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:602:in `each'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:602:in `route!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:741:in `dispatch!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:530:in `call!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:706:in `instance_eval'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:706:in `invoke'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:706:in `catch'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:706:in `invoke'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:530:in `call!'
	/Library/Ruby/Gems/1.8/gems/sinatra-1.1.0/lib/sinatra/base.rb:516:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/showexceptions.rb:24:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/lint.rb:48:in `_call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/lint.rb:36:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/showexceptions.rb:24:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/commonlogger.rb:18:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/content_length.rb:13:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/chunked.rb:15:in `call'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/handler/mongrel.rb:67:in `process'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/handler/mongrel.rb:38:in `run'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/server.rb:100:in `start'
	/Library/Ruby/Gems/1.8/gems/rack-1.2.1/bin/rackup:4
	/usr/bin/rackup:19:in `load'
	/usr/bin/rackup:19
</pre>
<p>Despite the fact that I was telling it to go after a TCP port, it was attempting to connect to MySQL via a socket (the reason it was getting the error is it was looking for the socket at /opt/local/var/run/mysql5/mysqld.sock and mine was configured /tmp/mysql.sock &mdash; but that's not the point, it shouldn't have been looking there to begin with</p>
<p>Through trial and error I found that it appears that DataMapper automatically falls back to socket based communication with MySQL when you specify localhost. I was able to correct the error by specifying an IP address instead:</p>
<p><tt><br />
DATABASE_URL=mysql://username:password@127.0.0.1:3306/database_name<br />
</tt></p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2010/12/11/datamapper-defaults-to-socket-causes-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with JavaScript Closures + Scoping</title>
		<link>http://softwareblog.morlok.net/2010/07/10/fun-with-javascript-closures-scoping/</link>
		<comments>http://softwareblog.morlok.net/2010/07/10/fun-with-javascript-closures-scoping/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 14:55:44 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[scoping]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=396</guid>
		<description><![CDATA[It&#8217;s easy to forget that variable scoping in JavaScript is at the function level and not a the block level like what you get with C/C++/C#/Java/etc. This can have some counter intuitive implications when you&#8217;re dealing with closures. Consider the &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2010/07/10/fun-with-javascript-closures-scoping/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy to forget that variable scoping in JavaScript is at the function level and not a the block level like what you get with C/C++/C#/Java/etc.  This can have some counter intuitive implications when you&#8217;re dealing with closures.  Consider the following example:</p>
<pre name="code" class="javascript">
var closure;

for(var i = 0; i <= 5; i++) {
  var x = i * i;
  if( i == 1 ) {
    closure = function() { alert(x); };
  }
}

closure();
</pre>
<p><script type="text/javascript">
function runme() {
var closure;
for(var i = 0; i <= 5; i++) {
  var x = i * i;
  if( i == 1 ) {
    closure = function() { alert(x); };
  }
}
closure();
}
</script></p>
<p> What do you think the output of the alert box will be?  At first blush it's easy to think it will be 1 because the variable x is declared within the <tt>for</tt> loop.</p>
<p><a href="javascript:runme()">Run Code</a></p>
<p>In reality, though, the output is 25 because despite the variable declaration in the <tt>for</tt> loop, the code is functionally equivalent to this:</p>
<pre name="code" class="javascript">
var closure;
var x;

for(var i = 0; i <= 5; i++) {
  x = i * i;
  if( i == 1 ) {
    closure = function() { alert(x); };
  }
}

closure();
</pre>
<p>This is important to remember when working with closures in loops.</p>
<p>So how do solve this problem? Manually create a new scope by creating and invoking an anonymous function.</p>
<pre name="code" class="javascript">
var closure;

for(var i = 0; i <= 5; i++) {
  var x = i * i;
  if( i == 1 ) {
    (function(x) {
      closure = function() { alert(x); };
    })(x);
  }
}

closure();
</pre>
<p><script type="text/javascript">
function runmefixed() {
var closure;
for(var i = 0; i <= 5; i++) {
  var x = i * i;
  if( i == 1 ) {
    (function(x) {
      closure = function() { alert(x); };
    })(x);
  }
}
closure();
}
</script></p>
<p><a href="javascript:runmefixed()">Run Code</a></p>
<p>With the newly introduce lexical scope, the program returns 1 as one would expect.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2010/07/10/fun-with-javascript-closures-scoping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Naming collision in ASMX web service</title>
		<link>http://softwareblog.morlok.net/2010/07/02/naming-collision-in-asmx-web-service/</link>
		<comments>http://softwareblog.morlok.net/2010/07/02/naming-collision-in-asmx-web-service/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 20:32:55 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=392</guid>
		<description><![CDATA[I ran into an interesting problem today while working on an ASMX web service. Everything compiled fine, but when I went to view the ASXM in the browser to manually invoke the methods to test it, the normal automatically generated &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2010/07/02/naming-collision-in-asmx-web-service/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I ran into an interesting problem today while working on an ASMX web service.</p>
<p>Everything compiled fine, but when I went to view the ASXM in the browser to manually invoke the methods to test it, the normal automatically generated info page didn&#8217;t come up.  Trying to grab the WSDL also gave me a blank page.</p>
<p>I then attached the debugger to IIS to observe what was happening when I tried to view the ASMX info page.  By breaking on exceptions, I was able to uncover the following error:</p>
<p><em>The XML element &#8216;XXX&#8217; from namespace &#8216;http://tempuri.org/&#8217; references a method and a type. Change the method&#8217;s message name using WebMethodAttribute or change the type&#8217;s root element using the XmlRootAttribute.</em></p>
<p>With a little more thinking, I was able uncover what I believe was going on.</p>
<p>I had defined a complex type to return as a response:</p>
<pre name="code" class="c#">
public class FooResponse {...}

[WebMethod]
public FooResponse Foo() {...}
</pre>
<p>Note that here the exact name pairing of Foo/Foo+Response is important. When I changed the method name as follows, the problem went away:</p>
<pre name="code" class="C#">
public class FooResponse {...}

[WebMethod]
public FooResponse Fooxxx() {...}
</pre>
<p>What I believe is happening is .NET is attempting to automatically wrap the response coming from the Foo method with an element named FooResponse. The use of that same name as the object you want to return creates ambiguity. By changing the name of my response object, or the name of my method I was able to avoid this collision.</p>
<p>I have also posted this information in response to a <a href="http://stackoverflow.com/questions/580042/c-web-service-client-multiple-web-service-methods-with-same-complex-return-ty/">question</a> on StackOverflow.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2010/07/02/naming-collision-in-asmx-web-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

