<?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:thr="http://purl.org/syndication/thread/1.0" xml:lang="en" xml:base="http://matschaffer.com/wp-atom.php">
	<title type="text">Mat Schaffer</title>
	<subtitle type="text">and his adventures in software</subtitle>

	<updated>2009-10-24T03:45:39Z</updated>
	<generator uri="http://wordpress.org/" version="2.8">WordPress</generator>

	<link rel="alternate" type="text/html" href="http://matschaffer.com" />
	<id>http://matschaffer.com/feed/atom/</id>
	

			<link rel="self" href="http://feeds.feedburner.com/MatSchaffer" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Call JRuby, Jython or other JVM scripting language from Maven]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/10/call-jruby-jython-from-maven/" />
		<id>http://matschaffer.com/?p=226</id>
		<updated>2009-10-24T03:45:39Z</updated>
		<published>2009-10-24T03:45:39Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="java" /><category scheme="http://matschaffer.com" term="maven" /><category scheme="http://matschaffer.com" term="ruby" /><category scheme="http://matschaffer.com" term="tools" />		<summary type="html"><![CDATA[Ever been frustrated trying to extend maven? Yeah me too. So here&#8217;s a trick I finally pounded out a couple weeks ago that I thought I&#8217;d share here.
It&#8217;s pretty common place to use the maven antrun plugin to perform some extra build work that you couldn&#8217;t otherwise do without writing a full-blown maven plugin. You [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/10/call-jruby-jython-from-maven/"><![CDATA[<p>Ever been frustrated trying to <a href="http://matschaffer.com/2008/09/more-work-on-corundum/">extend maven</a>? Yeah me too. So here&#8217;s a trick I finally pounded out a couple weeks ago that I thought I&#8217;d share here.</p>
<p>It&#8217;s pretty common place to use the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/">maven antrun plugin</a> to perform some extra build work that you couldn&#8217;t otherwise do without writing a full-blown maven plugin. You might even already use it to call scripts that move files around, compress CSS, or whatever. But wouldn&#8217;t it be nice if maven could download the script&#8217;s runtime for you? It can. Just throw these chunks into the appropriate sections of your pom.xml file.</p>
<pre><code>
  &lt;dependency&gt;
    &lt;groupId&gt;org.jruby&lt;/groupId&gt;
    &lt;artifactId&gt;jruby-complete&lt;/artifactId&gt;
    &lt;version&gt;1.3.1&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;

  &lt;properties&gt;
    &lt;jruby&gt;${settings.localRepository}/org/jruby/jruby-complete/1.3.1/jruby-complete-1.3.1.jar&lt;/jruby&gt;
  &lt;/properties&gt;

  &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;my_script&lt;/id&gt;
      &lt;phase&gt;compile&lt;/phase&gt;
      &lt;configuration&gt;
        &lt;tasks&gt;
          &lt;java jar="${jruby}" fork="true" failonerror="yes"&gt;
            &lt;arg value="${basedir}/src/main/ruby/myscript.rb" /&gt;
          &lt;/java&gt;
        &lt;/tasks&gt;
      &lt;/configuration&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
</code></pre>
<p>And of course the same technique should work for any language that you can run as an argument to a jar file (jython, rhino, clojure).</p>
<p>Now some of you might be asking &#8220;why not use the maven jruby plugin?&#8221;. Well because as best I can tell it still runs against JRuby 0.9.9. A bit too far behind the curve if you ask me. I expect you&#8217;ll find the same with Jython. So there.</p>
<p>Hope that helps some folks. I know it made wrangling my builds a world easier.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/10/call-jruby-jython-from-maven/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/10/call-jruby-jython-from-maven/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[JavaScript templates, build-time lovin&#8217;]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/10/javascript-templates/" />
		<id>http://matschaffer.com/?p=216</id>
		<updated>2009-10-04T04:04:16Z</updated>
		<published>2009-10-04T04:04:16Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="cim" /><category scheme="http://matschaffer.com" term="javascript" /><category scheme="http://matschaffer.com" term="maven" /><category scheme="http://matschaffer.com" term="tools" />		<summary type="html"><![CDATA[(Reposted from http://github.com/matschaffer/trimpath-templateRegistry)
Ever wanted to render HTML templates from javascript? Yeah, so did we. And so do a lot of people apparently. There are a lot of toolkits around for this.
We at CIM were evaluating some of them and had the realization that since we&#8217;re already processing JavaScript (compression) and CSS (from LESS and compression) [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/10/javascript-templates/"><![CDATA[<p>(Reposted from <a href="http://github.com/matschaffer/trimpath-templateRegistry">http://github.com/matschaffer/trimpath-templateRegistry</a>)</p>
<p>Ever wanted to render HTML templates from javascript? Yeah, so did we. And so do a lot of people apparently. There are <a href="http://beebole.com/pure/" title="PURE - JavaScript Template Engine">a</a> <a href="http://embeddedjs.com/" title="EJS - JavaScript Templates">lot</a> <a href="http://www.kuwata-lab.com/tenjin/" title="Tenjin - the fastest template engine in the world">of</a> <a href="http://code.google.com/p/jssmarty/" title="jssmarty - Project Hosting on Google Code">toolkits</a> <a href="http://code.google.com/p/trimpath/wiki/JavaScriptTemplates" title="JavaScriptTemplates - trimpath - Project Hosting on Google Code">around</a> for this.</p>
<p>We at CIM were evaluating some of them and had the realization that since we&#8217;re already processing JavaScript (compression) and CSS (from <a href="http://lesscss.org/" title="LESS - Leaner CSS">LESS</a> and compression) at build time, why not process the templates at build time as well?</p>
<p>So I give you <a href="http://github.com/matschaffer/trimpath-templateRegistry">TrimPath TemplateRegistry</a>. After evaluating all of the above mentioned template toolkits, we settled on <a href="http://code.google.com/p/trimpath/wiki/JavaScriptTemplates" title="JavaScriptTemplates - trimpath - Project Hosting on Google Code">TrimPath&#8217;s JST</a> because we all could agree that the syntax was reasonable (<a href="http://beebole.com/pure/" title="PURE - JavaScript Template Engine">Pure</a> was a little hit or miss) and it was able to produce fairly clean JavaScript after processing a template. And when I say clean in this case I mean the generated JavaScript also has no dependency on any library. Since we&#8217;ve already processed the templates, it&#8217;d be a shame if we still required the browser to parse the template toolkit at run time.</p>
<p>It seems to be working so far at least in theory. We haven&#8217;t applied this to production code yet, but hopefully we will soon. Check out client/demo.html for a rough sketch of the idea. The &#8220;client&#8221; folder is what&#8217;s intended for use at run-time. The &#8220;server&#8221; folder is what&#8217;s intended for use at build-time.</p>
<p>There&#8217;s still a lot of work to be done. My biggest outstanding question is how to handle the the template registration function name such that we can be pretty flexible about how/where the templates get loaded. And of course, we&#8217;ll need some specs now that I actually have some rough idea of what the heck I&#8217;m doing <img src='http://matschaffer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/10/javascript-templates/#comments" thr:count="4" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/10/javascript-templates/feed/atom/" thr:count="4" />
		<thr:total>4</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Harsh opinions on JavaScript testing]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/08/harsh-opinions-on-javascript-testing/" />
		<id>http://matschaffer.com/?p=206</id>
		<updated>2009-09-02T00:50:54Z</updated>
		<published>2009-08-26T13:49:27Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="javascript" /><category scheme="http://matschaffer.com" term="testing" /><category scheme="http://matschaffer.com" term="tools" /><category scheme="http://matschaffer.com" term="web" />		<summary type="html"><![CDATA[JavaScript testing has been a hot topic at CIM lately. Enough that I&#8217;ve managed to form some opinions on the matter that Arpit thought I should share with the world. So here&#8217;s a rundown of all the javascript testing tools I&#8217;ve looked at and my opinions on them.
Screw Unit: More than just a funny name, [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/08/harsh-opinions-on-javascript-testing/"><![CDATA[<p>JavaScript testing has been a hot topic at CIM lately. Enough that I&#8217;ve managed to form some opinions on the matter that <a href="http://arpitonline.com">Arpit</a> thought I should share with the world. So here&#8217;s a rundown of all the javascript testing tools I&#8217;ve looked at and my opinions on them.</p>
<p><strong><a href="http://github.com/nkallen/screw-unit">Screw Unit</a></strong>: More than just a funny name, this is so far the most enjoyable javascript testing tool I&#8217;ve used yet. BDD looks great in JavaScript. The jQuery-bias also works for us since jQuery is our framework of choice around here. And to top it off, it&#8217;s got a beautiful and functional runner which requires almost no boilerplate code allows focused testing with a single click. I wrote the test suite for <a href="http://github.com/matschaffer/isepta-train-view.wdgt">iSepta Train View</a> in Screw Unit and have been using it at work too.</p>
<p>The biggest downside to Screw Unit is the project momentum. The original authors don&#8217;t seem to be doing much with it these days and it&#8217;s difficult to find a source of truth. So in the mean time I look to <a href="http://github.com/trotter/screw-unit">Trotter Cashion&#8217;s fork</a> for stability since I know he&#8217;s used it for testing a number of production apps. His version also has a better Stubbing/Mocking toolkit than what Screw Unit originally comes with.</p>
<p>If you&#8217;re interested in a command line runner Screw Unit on Rails, check out <a href="http://github.com/relevance/blue-ridge">Blue Ridge</a>. Or for off rails (and on Mac), try <a href="http://github.com/nakajima/screw-driver">Screw Driver</a>.</p>
<p><strong><a href="http://github.com/pivotal/jasmine">Jasmine</a></strong>: I do have one gripe with Screw Unit that I blame Trotter for (I might not have noticed if he didn&#8217;t mention it). It uses snake_casing rather than JavaScript&#8217;s own camelCaseConvention. Jasmine gets that right. On top of that, it appears to stay framework and DOM independent. I&#8217;m a little concerned about the runner though since they don&#8217;t show it off in the readme and the docs recommend find/replace as a method for running focused tests which is super lame.</p>
<p><strong><a href="http://code.google.com/p/js-test-driver">JsTestDriver</a></strong>: Written by Java developers for Java developers. And as best I can tell offers no support for asynchronous tests. The browser capturing is cool, and I&#8217;ve seen some interesting advances in the <a href="http://googletesting.blogspot.com/2009/08/super-fast-js-testing.html">tooling</a> for this framework, but it doesn&#8217;t seem worth the Java culture that comes along for the ride.</p>
<p><strong><a href="http://jsunittest.com">JsUnitTest</a></strong>: This is a fork of prototype&#8217;s test suite but with the prototype dependency removed. I was excited about this early on, but had a lot of trouble getting it to run correctly across all browsers. The runner pages also require a fair bit of boilerplate which is a big turn-off.</p>
<p><strong><a href="http://www.jsunit.net">JsUnit</a></strong>: I&#8217;ll mention this purely for historical reasons. Don&#8217;t use it. It&#8217;s old, crufty and I&#8217;m pretty sure they spent more time on their logo than they did on the test runner. We started using this on our project originally and quickly grew to hate and ignore it.</p>
<p><strong><a href="http://visionmedia.github.com/jspec/">JSpec</a></strong>: I haven&#8217;t spent much time with JSpec but it does look fairly well thought out so I might give it another chance. What caused me to write it off initially was the introduction of a ruby-like test grammar rather than just straight JavaScript. Helpers for anonymous functions are cool and all but not at the cost of having to learn a new grammar which apparently even has issues running some operations correctly. As much as I love ruby, the JSpec grammar is an unnecessary complication. JavaScript is capable language, use it.</p>
<p><strong>Conclusion</strong>: So that&#8217;s it. Hope this saves some other people the pain of wading through a number of different testing frameworks. The JavaScript culture is a funny one but I&#8217;ve seen a lot of promise and progress lately. If you have any tools you like that I haven&#8217;t covered here, please comment!</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/08/harsh-opinions-on-javascript-testing/#comments" thr:count="8" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/08/harsh-opinions-on-javascript-testing/feed/atom/" thr:count="8" />
		<thr:total>8</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Installing ImageMagick on OS X Leopard]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/05/installing-imagemagick-on-os-x-leopard/" />
		<id>http://matschaffer.com/?p=201</id>
		<updated>2009-08-26T13:52:41Z</updated>
		<published>2009-05-18T03:04:52Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="graphics" /><category scheme="http://matschaffer.com" term="osx" /><category scheme="http://matschaffer.com" term="tools" /><category scheme="http://matschaffer.com" term="unix" />		<summary type="html"><![CDATA[So last night I tried to install ImageMagick on Leopard but couldn’t find the requisite blog article that detailed the installation. So I thought I’d write one. I managed to dig up some forum posts, so here’s the whole deal.
ImageMagick itself compiles fairly easily on OS X, but it’ll end up missing JPEG support, which [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/05/installing-imagemagick-on-os-x-leopard/"><![CDATA[<p>So last night I tried to install <a href="http://www.imagemagick.org/">ImageMagick</a> on Leopard but couldn’t find the requisite blog article that detailed the installation. So I thought I’d write one. I managed to dig up <a href="http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=9823">some forum posts</a>, so here’s the whole deal.</p>
<p>ImageMagick itself compiles fairly easily on <span class="caps">OS X</span>, but it’ll end up missing <span class="caps">JPEG</span> support, which was kind of a bummer. Here’s how to fix it without using <a href="http://www.macports.org/">MacPorts</a> (which I avoid these days since it tends to get updated too slowly for a lot of projects).</p>
<p>First get a copy of <a href="http://www.ijg.org/">libjpeg</a> and build it as a shared library:</p>
<pre><code>curl -O http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zxf jpegsrc.v7.tar.gz
cd jpeg-7/
ln -s `which glibtool` ./libtool
./configure --enable-shared --prefix=/usr/local
make
sudo make install</code></pre>
<p>Now get a copy of ImageMagick:</p>
<pre><code>curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -zxf ImageMagick.tar.gz
cd ImageMagick-*/
./configure --prefix=/usr/local
make
sudo make install</code></pre>
<p>Now you should have convert, mogrify, montage or whatever other ImageMagick tools you were interested in. <a href="http://rmagick.rubyforge.org/">RMagick</a> seems to install just fine after you do this, though I couldn’t get <a href="http://nubyonrails.com/pages/gruff">gruff</a> working because of what looks like a dependency on <a href="http://www.ghostscript.com/">GhostScript</a>. I’ll update this post once I get that worked out.</p>
<p><strong>Update (8/26)</strong>: Tweaked some of the commands here to account for new versions of libjpeg and ImageMagick. Thanks for the heads up, Amed!</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/05/installing-imagemagick-on-os-x-leopard/#comments" thr:count="5" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/05/installing-imagemagick-on-os-x-leopard/feed/atom/" thr:count="5" />
		<thr:total>5</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[What I learned about Cookies this week]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/05/what-i-learned-about-cookies-this-week/" />
		<id>http://matschaffer.com/?p=197</id>
		<updated>2009-05-09T16:59:29Z</updated>
		<published>2009-05-09T16:59:29Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="cim" /><category scheme="http://matschaffer.com" term="http" /><category scheme="http://matschaffer.com" term="web" />		<summary type="html"><![CDATA[A lot of people reading this are probably using frameworks that have decent session storage and don’t often need to worry about cookies. But over at CIM the thought of session state for many tens of millions of requests per day is daunting. As a result we use a lot of cookies. Probably too many, [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/05/what-i-learned-about-cookies-this-week/"><![CDATA[<p>A lot of people reading this are probably using <a href="http://www.rubyonrails.org">frameworks</a> that have decent session storage and don’t often need to worry about cookies. But over at <a href="http://www.comcast.net"><span class="caps">CIM</span></a> the thought of session state for many tens of millions of requests per day is daunting. As a result we use a lot of cookies. Probably too many, but that’s a story for another day.</p>
<p>Ever read the <a href="http://www.faqs.org/rfcs/rfc2965.html"><span class="caps">RFC</span> for cookies</a>? Neither had I. I probably wouldn’t have either until our company decided to standardize on <a href="http://tomcat.apache.org">Apache Tomcat</a> for our application containers. What we thought would be an easy conversion turned out to take a few days time because some of our important cookies apparently violate the <span class="caps">RFC</span>, but no browser or web server had complained yet. What rules did we break?</p>
<ul>
<li>The left hand side of a cookie definition can’t contain an ’@’ symbol (along with some others)</li>
<li>The right hand side of a cookie can’t contain ’=’ symbols, so no unescaped key=value pairs</li>
</ul>
<p>The <span class="caps">RFC</span> is a lot to wade through, but thanks to some information from <a href="https://issues.apache.org/jira/browse/WICKET-1834">Tomcat’s issue tracker</a> it was made pretty clear. Basically a cookie definition boils down to:</p>
<pre><code>
   av-pairs    =     av-pair *(";" av-pair)
   av-pair     =     attr ["=" value]              ; optional value
   attr        =     token
   value       =     token | quoted-string
</code></pre>
<p>Where the definition for token and quoted-string are provided in the <a href="http://www.faqs.org/rfcs/rfc2616.html"><span class="caps">HTTP</span>/1.1 spec.</a></p>
<pre><code>
    token          = 1*&lt;any CHAR except CTLs or separators&gt;
    separators     = "(" | ")" | "&lt;" | "&gt;" | "@"
                   | "," | ";" | ":" | "\" | &lt;"&gt;
                   | "/" | "[" | "]" | "?" | "="
                   | "{" | "}" | SP | HT

    quoted-string  = ( &lt;"&gt; *(qdtext | quoted-pair ) &lt;"&gt; )
    qdtext         = &lt;any TEXT except &lt;"&gt;&gt;
    quoted-pair    = "\" CHAR
</code></pre>
<p>So there you have it. And most web servers and browsers don’t seem to complain. But if you ever find yourself looking at your server logs or a debugger wondering where you cookies went or why they’re truncated. Then it might be time to double check the <span class="caps">RFC</span>.</p>
<p>Oh, and the fix? Well ideally we’ll fix our cookies to comply with the <span class="caps">RFC</span>, but that will take some time since we don’t control the creation of all the cookies in question. So the plan for now is to patch Tomcat’s Cookie class to be a bit less strict when it’s parsing the request.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/05/what-i-learned-about-cookies-this-week/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/05/what-i-learned-about-cookies-this-week/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[iSepta Train View, my time with Dashcode]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/03/isepta-train-view/" />
		<id>http://matschaffer.com/?p=172</id>
		<updated>2009-04-17T01:20:38Z</updated>
		<published>2009-03-30T03:33:50Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="septa" /><category scheme="http://matschaffer.com" term="widgets" />		<summary type="html"><![CDATA[
UPDATE: New version 1.1! Download it here.
UPDATE 2: Github now has issue tracking! So I&#8217;m dropping uservoice. If you have ideas, submit them here.
So over the past month I&#8217;ve been working with Dashcode trying to come up with a nice representation of Septa train data. I&#8217;ve managed to come up with a simple widget that [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/03/isepta-train-view/"><![CDATA[<p><img class="alignleft" title="iSepta Train View" src="http://matschaffer.com/files/iSeptaTrainView.png" alt="" width="284" height="368" /></p>
<p><strong>UPDATE:</strong> New version 1.1! <a href="http://cloud.github.com/downloads/matschaffer/isepta-train-view.wdgt/iSepta_Train_View-1.1.zip">Download it here</a>.</p>
<p><strong>UPDATE 2: </strong>Github now has issue tracking! So I&#8217;m dropping uservoice. If you have ideas, submit them <a href="http://github.com/matschaffer/isepta-train-view.wdgt/issues">here</a>.</p>
<p>So over the past month I&#8217;ve been working with <a href="http://developer.apple.com/tools/dashcode/">Dashcode</a> trying to come up with a nice representation of <a href="http://septa.org">Septa</a> train data. I&#8217;ve managed to come up with a simple widget that combines the data from <a href="http://isepta.org">iSepta</a> with the ontime/late data available from Septa&#8217;s <a href="http://trainview.septa.org">Train View</a> page. So far it seems to be working well. I&#8217;ve submitted the widget to <a href="http://www.apple.com/downloads/dashboard/">Apple downloads</a> and <a href="http://www.dashboardwidgets.com/showcase/details.php?wid=2413">Dashboard Widgets</a> so hopefully you&#8217;ll see it show up there soon too. So <a href="http://cloud.github.com/downloads/matschaffer/isepta-train-view.wdgt/iSepta_Train_View-1.1.zip"><strong>download</strong> your copy</a> and <a href="http://github.com/matschaffer/isepta-train-view.wdgt/issues">let me know what you think</a>!</p>
<p>As far as working with Dashcode goes, it&#8217;s been an interesting experience. I&#8217;m still a little lukewarm on it, but it definitely helped with the visual work. I&#8217;m not much of a designer, so having Dashcode&#8217;s gradient, rounded corner and &#8220;glass&#8221; effect helpers was perfect for me. It was also nice not having to hand-code the &#8220;i&#8221; button animation like I did with <a href="http://matschaffer.com/projects/#dwc">Digital World Clock</a>.</p>
<p>On the downside of things, I felt like the HTML and javascript generation over-complicated things in some cases. Dashcode provides &#8220;Parts&#8221; like labels, lists and indicators which are cool but the way you interact with them is a little odd. For example, to add items to a list part you&#8217;d do this:</p>
<pre class="brush: js">var list = document.getElementById(&#039;list&#039;).object;
list.setDataArray(trainList);</pre>
<p>Which isn&#8217;t terrible, but felt like more work than just manipulating a plain old &#8220;ul&#8221; with jQuery. Granted this specialized interface does also offer streaming-friendly setters, which could be useful for some folks. My bigger gripe is with the labels that get generated like this in the HTML:</p>
<pre class="brush: html">&lt;div apple-part=&quot;com.apple.Dashcode.part.text&quot; class=&quot;apple-text apple-no-children&quot; apple-default-image-visibility=&quot;hidden&quot; apple-text-overflow=&quot;ellipsis&quot; id=&quot;nextTrainLabel&quot; apple-style=&quot;part-height-dependent: true;&quot;&gt;&lt;/div&gt;</pre>
<p>Note the lack of contents. They get wired at run time by javascript. My guess is that this makes localization more accessible, but I wonder how many widgets really get localized.</p>
<p>These sort of things made me hesitant to muck around with the HTML and CSS which felt a little limiting when building the widget. But the graphics helpers and quick access to functions like &#8220;deploy to dashboard&#8221; were definitely nice. And the javascript debugging support felt even more solid than firebug. So all-in-all I&#8217;m a happy camper.</p>
<p>One more thing to be careful about if you&#8217;re working with Dashcode: when saving your project, Dashcode will regenerate most of the files and directories and blow away files that haven&#8217;t been imported into the project. So be careful not to save things under the dcproj bundle or you might lose them. I would bet this applies to .svn folders as well, but all the cool kids are using <a href="http://git-scm.com">git</a> nowadays anyway, right?</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/03/isepta-train-view/#comments" thr:count="6" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/03/isepta-train-view/feed/atom/" thr:count="6" />
		<thr:total>6</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Removing code is a feature]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/03/removing-code-is-a-feature/" />
		<id>http://matschaffer.com/?p=162</id>
		<updated>2009-03-03T05:11:26Z</updated>
		<published>2009-03-03T05:11:26Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="maven" /><category scheme="http://matschaffer.com" term="ruby" /><category scheme="http://matschaffer.com" term="workflow" />		<summary type="html"><![CDATA[
I saw a beautiful thing this evening in the ZenTest 4.0.0 release notes (emphasis mine):
2 minor enhancements:

Deleted autotest/screen &#8211; releasing as a separate gem soon.
Deleted test-rails and railstestaudit.


Removing unnecessary code has always given me a warm fuzzy feeling.
In today&#8217;s world of backups, version control and dependency management we need to learn to be ruthless with the delete [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/03/removing-code-is-a-feature/"><![CDATA[<p><a href="http://www.thinkgeek.com/homeoffice/gear/a639/images/"><img title="Delete" src="http://www.thinkgeek.com/images/products/additional/large/delete_key_eraser_inhand.jpg" alt="" width="400" height="400" /></a></p>
<p>I saw a beautiful thing this evening in the <a href="http://blog.zenspider.com/2009/03/zentest-version-400-has-been-r.html">ZenTest 4.0.0 release notes</a> (emphasis mine):</p>
<blockquote><p>2 minor enhancements:</p>
<ul>
<li><strong>Deleted</strong> autotest/screen &#8211; releasing as a separate gem soon.</li>
<li><strong>Deleted</strong> test-rails and rails<em>test</em>audit.</li>
</ul>
</blockquote>
<p>Removing unnecessary code has always given me a <em>warm fuzzy</em> feeling.</p>
<p>In today&#8217;s world of <a href="http://www.apple.com/macosx/features/timemachine.html">backups</a>, <a href="http://git-scm.com/">version control</a> and <a href="http://maven.apache.org">dependency management</a> we need to learn to be <strong>ruthless</strong> with the delete key.</p>
<p>Don&#8217;t comment it out. Don&#8217;t talk yourself into thinking you&#8217;ll use it later. <strong>Just delete it.</strong></p>
<p>This is one of the same principals behind the <em><a href="http://www.43folders.com/2006/03/14/delete">inbox zero</a></em> concept and it is just as applicable to code. Nice work, <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">ZenTest</a>. We should get you a <a href="http://nerdmeritbadges.com/">merit badge</a>.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/03/removing-code-is-a-feature/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/03/removing-code-is-a-feature/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[The Creep of Asynchronicity]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/02/the-creep-of-asynchronicity/" />
		<id>http://matschaffer.com/?p=140</id>
		<updated>2009-02-20T04:07:46Z</updated>
		<published>2009-02-20T04:07:46Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="ajax" /><category scheme="http://matschaffer.com" term="javascript" />		<summary type="html"><![CDATA[I&#8217;ve been doing a fair bit of JavaScript at work lately and while I really enjoy the language there&#8217;s something that&#8217;s been nagging at me which I&#8217;ve come to call The Creep of Asynchronicity. I&#8217;ll use some of the examples I&#8217;ve been working with to illustrate the idea.
Let&#8217;s start with a function to get all [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/02/the-creep-of-asynchronicity/"><![CDATA[<p>I&#8217;ve been doing a fair bit of JavaScript at work lately and while I really enjoy the language there&#8217;s something that&#8217;s been nagging at me which I&#8217;ve come to call <strong>The Creep of Asynchronicity</strong>. I&#8217;ll use some of the examples I&#8217;ve been working with to illustrate the idea.</p>
<p>Let&#8217;s start with a function to get all the videos on a device that looks like this:</p>
<pre class="brush: js">videos = device.getVideos();
doSomethingWith(videos);</pre>
<p><em>Simple</em>. Pretty much what you would expect in a &#8220;device&#8221; API, right? But now let&#8217;s assume that getVideos() requires a return trip to the web server to get the data. You have two options:</p>
<ol>
<li>Fly in the face of AJAX, make the call synchronously and lock up your UI.</li>
<li>Change the API to look something like this:</li>
</ol>
<pre class="brush: js">device.getVideos(function(videos) {
  doSomethingWith(videos);
}</pre>
<p>Now that&#8217;s not so bad, but consider the case where you also need an asynchronous call to get the device object. Now we have:</p>
<pre class="brush: js">user.getDevice(function(device) {
  device.getVideos(function(videos) {
    doSomethingWith(videos);
  }
}</pre>
<p><em>Ew&#8230;</em> getting kinda nasty there isn&#8217;t it? Imagine if we also had to make an asynchronous call to get some details on the videos, and so on.</p>
<p>So the crux of my argument is that without some sort of <strong>synchronization mechanism</strong>, any introduction of an asynchronous call requires that the whole application become asynchronous to support it. Even just a <strong>sleep</strong> function would help, but JavaScript has nothing of the sort. The best I&#8217;ve come up with so far is recursion, which helps in the event that your asychronous calls are acting upon a list of items uniformly. I used this to load a series of JavaScript libraries like so:</p>
<pre class="brush: js">function loadScripts(libraries, callback) {
  if (libraries.length &gt; 0) {
    var lib = libraries.shift();
    jQuery.getScript(lib, function() { loadScripts(libraries, callback); });
  } else {
    callback();
  }
}

loadScripts([&quot;/user.js&quot;, &quot;/device.js&quot;], function() {
  doStuffOnceScriptsHaveLoaded();
});</pre>
<p>This could conceivably be used to recurse down a list of asynchronous callbacks (which I did find on the web somewhere but seem to find it at the moment). But I think this might lead to an even nastier looking API.</p>
<p>I&#8217;m sure on some level, this just requires a shift in thinking. But there&#8217;s a part of me that still longs for that two liner at the top of this post&#8230; *sigh*</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/02/the-creep-of-asynchronicity/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/02/the-creep-of-asynchronicity/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Happy Valentine&#8217;s Day, Alton]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2009/02/happy-valentines-day-alton/" />
		<id>http://matschaffer.com/?p=131</id>
		<updated>2009-02-15T19:31:07Z</updated>
		<published>2009-02-15T19:27:58Z</published>
		<category scheme="http://matschaffer.com" term="Family" /><category scheme="http://matschaffer.com" term="food" /><category scheme="http://matschaffer.com" term="holidays" />		<summary type="html"><![CDATA[So here&#8217;s a non-technical tip for you: If you haven&#8217;t tried Alton Brown&#8217;s Pan Seared Ribyeye recipe yet, do it.
We had a quiet Valentine&#8217;s Day at home yesterday and I tried my hand at steak and potatoes. Alton&#8217;s steak recipe was awesome and stupid simple. I will definitely be doing this one again.
For the potatoes, [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2009/02/happy-valentines-day-alton/"><![CDATA[<p>So here&#8217;s a non-technical tip for you: If you haven&#8217;t tried <a href="http://www.foodnetwork.com/recipes/alton-brown/pan-seared-rib-eye-recipe/index.html">Alton Brown&#8217;s Pan Seared Ribyeye recipe</a> yet, do it.</p>
<p><a href="http://www.flickr.com/photos/schapht/3281565603/"><img class="alignleft" src="http://farm4.static.flickr.com/3574/3281565603_f17bc0542d_m.jpg" alt="Steak 'n Potatoes" /></a>We had a quiet Valentine&#8217;s Day at home yesterday and I tried my hand at steak and potatoes. Alton&#8217;s steak recipe was awesome and stupid simple. I will definitely be doing this one again.</p>
<p>For the potatoes, I used a <a href="http://allrecipes.com/Recipe/Rosemary-Red-Potatoes/Detail.aspx">roasted rosemary potatoes</a> recipe that didn&#8217;t work out quite as well. I&#8217;ve made something like this before, but couldn&#8217;t find that same recipe so I used this one. But the addition of garlic and onions was a bit much (my usual one is just butter and rosemary). I guess I&#8217;ll have to experiment to come up with something like my old way of doing it.</p>
<p><a href="http://www.flickr.com/photos/schapht/3281566021/"><img class="alignright" title="Chocolate fudge cake" src="http://farm4.static.flickr.com/3577/3281566021_7a223e623e_m.jpg" alt="" width="240" height="180" /></a></p>
<p>Kaori (the culinary genius of the family) made a delicious three-layer chocolate fudge cake for dessert. Yes, that&#8217;s a layer of fudge around each layer of cake, chocolate cream between the layers and dusted with cocoa powder. Combine that with a hot cup of <a href="http://www.teavana.com/Loose-Leaf-Teas/Black-Tea/Earl-Grey-Flavored-Black-Tea.axd">Earl Grey</a> and we&#8217;re in business!</p>
<p>I hope everyone else had a lovely Valentine&#8217;s Day!</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2009/02/happy-valentines-day-alton/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2009/02/happy-valentines-day-alton/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	</entry>
		<entry>
		<author>
			<name>Mat</name>
						<uri>http://www.matschaffer.com</uri>
					</author>
		<title type="html"><![CDATA[Groovy Unit Tests on Maven &amp; Eclipse]]></title>
		<link rel="alternate" type="text/html" href="http://matschaffer.com/2008/12/groovy-unit-tests-on-maven-eclipse/" />
		<id>http://matschaffer.com/?p=120</id>
		<updated>2008-12-27T18:17:58Z</updated>
		<published>2008-12-27T18:17:58Z</published>
		<category scheme="http://matschaffer.com" term="Technology" /><category scheme="http://matschaffer.com" term="groovy" /><category scheme="http://matschaffer.com" term="java" />		<summary type="html"><![CDATA[During our last sprint at work I got a good chance to get Groovy working for our unit tests. It took a bit of googling and trial and error, so hopefully this post will benefit others trying to do the same thing. Here&#8217;s what I did:
Set up your pom with the following dependency:

And the gmaven [...]]]></summary>
		<content type="html" xml:base="http://matschaffer.com/2008/12/groovy-unit-tests-on-maven-eclipse/"><![CDATA[<p>During our last sprint at work I got a good chance to get <a href="http://groovy.codehaus.org/">Groovy</a> working for our unit tests. It took a bit of googling and trial and error, so hopefully this post will benefit others trying to do the same thing. Here&#8217;s what I did:</p>
<p>Set up your pom with the following dependency:<br />
<script src="http://gist.github.com/40288.js"></script></p>
<p>And the gmaven plugin under the build section:<br />
<script src="http://gist.github.com/40289.js"></script></p>
<p>Note that I keep my tests under <code>src/test/java</code>, this avoids needing extra configuration from inside eclipse. <code>src/test/groovy</code> also works, but you&#8217;ll need to mark it as a source folder, and it seems to be a little flaky so I stopped that.</p>
<p>At this point you should be able to run your groovy tests with <code>mvn clean install</code>. Or use <code>-Dtest=MyGroovyTest</code> to run a single test.</p>
<p>For eclipse you&#8217;ll need the <a href="http://groovy.codehaus.org/Eclipse+Plugin">GroovyFeature</a> installed. I currently have version 1.5.6 installed.</p>
<p>Close your eclipse project and rebuild the configuration with <code>mvn eclipse:clean eclipse:eclipse</code>. Open the project back up.  You may need to fix the JRE settings for the project in the java build properties. On my machine maven tries to hook the project to a JRE other than the default, compile errors occur, switching back to the default Mac OS JRE resolves that.</p>
<p>Right click on the project root, go to &#8220;Groovy -&gt; Add Groovy Nature&#8221;.  If you use the eclipse maven plugin, don&#8217;t turn it on for this project. Enabling maven dependency management doesn&#8217;t seem to jive with the eclipse groovy plugin. If I turn it on, I get lots of class not found type errors and have to do <code>eclipse:clean eclipse:eclipse</code> and start over again.</p>
<p>Right click your .groovy test (a class that inherits from groovy.util.GroovyTestCase) and you should have Run As -&gt; JUnit test available.  I have my setUp and test methods as <code>void</code>.  I used <code>def</code>s originally, but this caused the methods to be ignored.</p>
<p>If you don&#8217;t see JUnit available, try cleaning the project. I&#8217;ve even turned off the automatic builds and manually ran &#8220;Build All&#8221; on occasion. Also watch out for compile errors in the groovy files.  Eclipse doesn&#8217;t reliably warn about it and I&#8217;ve seen compilation just silently fail. When in doubt have maven try to run it. Eclipse doesn&#8217;t always reliably build the groovy classes, and I often have to clean the compiled classes especially when adding new groovy methods or test functions. I&#8217;d say about 75% of the time it just runs.</p>
<p>Dan Schaffer on the groovy mailing list also mentioned noted that refactoring Java classes doesn&#8217;t seem to apply to Groovy files. There is <a href="http://groovy.ifs.hsr.ch/trac/GroovyRefactoring/wiki">a plugin</a> for that, but I haven&#8217;t tried it yet.</p>
<p>As usual, feel free to comment if you have any questions about my setup. Hope you find this useful.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://matschaffer.com/2008/12/groovy-unit-tests-on-maven-eclipse/#comments" thr:count="4" />
		<link rel="replies" type="application/atom+xml" href="http://matschaffer.com/2008/12/groovy-unit-tests-on-maven-eclipse/feed/atom/" thr:count="4" />
		<thr:total>4</thr:total>
	</entry>
	</feed>
