<?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>Defective Semantics &#187; Problems</title>
	<atom:link href="http://scarff.id.au/blog/category/software/the-struggle/feed/" rel="self" type="application/rss+xml" />
	<link>http://scarff.id.au</link>
	<description>Dean Scarff's perpetual struggle with technology, and other anecdotes</description>
	<lastBuildDate>Sun, 05 Sep 2010 04:34:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>dudders and reliable DNS zone updates</title>
		<link>http://scarff.id.au/blog/2010/dudders-and-reliable-dns-zone-updates/</link>
		<comments>http://scarff.id.au/blog/2010/dudders-and-reliable-dns-zone-updates/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 03:48:26 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[dudders]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=485</guid>
		<description><![CDATA[<p>I&#8217;ve released a new version of dudders, 1.04, and finally submitted it as a package to OpenWRT.  The focus of this release was on making the update more robust to network failure as the result of an email correspondence with Peter Holik.  I am of the opinion that DNS UPDATE is a strong candidate for being TCP by default (along with zone-transfers).</p>
<p>In RFC 1123 it is stipulated that:</p>
<blockquote cite="http://tools.ietf.org/html/rfc1123#page-75"><p>a DNS resolver or server that is sending a non-zone-transfer query MUST send a UDP query first.</p></blockquote>
<p>However, if you are doing a DNS UPDATE you really want the reliability that TCP offers, even if you don&#8217;t expect truncation to be an issue.  The update is sent to the relevant authority server, so the arguments about load on root servers in the RFC aren&#8217;t applicable.</p>
<p>I&#8217;ve made the UDP implementation retry by default, but I think if you need more&#8230; <a href="http://scarff.id.au/blog/2010/dudders-and-reliable-dns-zone-updates/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released a new version of dudders, 1.04, and finally submitted it as a package to OpenWRT.  The focus of this release was on making the update more robust to network failure as the result of an email correspondence with Peter Holik.  I am of the opinion that DNS UPDATE is a strong candidate for being TCP by default (along with zone-transfers).</p>
<p>In RFC 1123 it is stipulated that:</p>
<blockquote cite="http://tools.ietf.org/html/rfc1123#page-75"><p>a DNS resolver or server that is sending a non-zone-transfer query MUST send a UDP query first.</p></blockquote>
<p>However, if you are doing a DNS UPDATE you really want the reliability that TCP offers, even if you don&#8217;t expect truncation to be an issue.  The update is sent to the relevant authority server, so the arguments about load on root servers in the RFC aren&#8217;t applicable.</p>
<p>I&#8217;ve made the UDP implementation retry by default, but I think if you need more than 2 retries, you should be considering using TCP with its (much more advanced) retransmission algorithms.</p>
<p>Peter also found a bug in glibc&#8217;s <code>res_send</code> (actually in their <code>send_dg</code> function) whereby the resolver interprets the lack of the DNS &#8220;recursion available&#8221; flag in the header as an error.  However, that flag isn&#8217;t even meaningful for DNS UPDATE responses; according to RFC 2136, those bits:</p>
<blockquote cite="http://tools.ietf.org/html/rfc2136#page-5"><p>Should be zero (0) in all requests and responses.  A non-zero Z field should be ignored by implementations of this specification.</p></blockquote>
<p>As a result, glibc was setting errno to <code>ECONNREFUSED</code> or <code>ETIMEDOUT</code> even when the update was successful.  I&#8217;ve hacked dudders to double-check after <code>res_send</code>, but it&#8217;s making me question the wisdom of using <code>res_send</code> at all, given that I&#8217;m constantly working around it.</p>
<p><small class="postscript">Update: submitted glibc bug report <a href="http://sources.redhat.com/bugzilla/show_bug.cgi?id=11950">#11950</a></small></p>
<p>To get dudders-1.04 on OpenWRT, simply update the official package feed and select dudders from the Net &gt; DNS &gt; dudders menu in the buildroot config.  For systems other than OpenWRT, you can grab the source from <a href="http://dudders.sourceforge.net">sourceforge</a>, or even <a href="http://github.com/p00ya/dudders">github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/dudders-and-reliable-dns-zone-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XHTML fixes for the WordPress reCAPTCHA plugin</title>
		<link>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/</link>
		<comments>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:01:39 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=456</guid>
		<description><![CDATA[<p>The wp-recaptcha plugin for WordPress breaks when you&#8217;re serving pages as application/xhtml+xml.  I inadvertently broke comments when I installed it (silly me for not testing!).  I&#8217;ve written a patch that fixes it.</p>
<p>The default javascript API uses <code>document.write</code>, which isn&#8217;t a DOM method and hence is not a method of true XML documents.  It&#8217;s not a new issue either, wp-recaptcha has had a history of breaking XHTML.  The thing is, the WordPress plugin (which uses the PHP library by the recaptcha people) has an option to &#8220;Be XHTML 1.0 Strict compliant&#8221;; but this only fixes the use of iframes and noscript!</p>
<p><small class="postscript">Updated: pushed fork to github</small><br />
<span id="more-456"></span></p>
<p>Under firefox, you get an error like:</p>
<pre>
Error: uncaught exception:
[Exception... "Operation is not supported"  code: "9"
 nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
 location: "http://www.google.com/recaptcha/api/challenge?k=xxx Line: 12"]
</pre>
<p>While under Chrome it&#8217;s</p>
<pre>
Uncaught TypeError: Object #&#60;a Document&#62; has no method 'write'
api.recaptcha.net/challengek=xxx
</pre><p>&#8230; <a href="http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>The wp-recaptcha plugin for WordPress breaks when you&#8217;re serving pages as application/xhtml+xml.  I inadvertently broke comments when I installed it (silly me for not testing!).  I&#8217;ve written a patch that fixes it.</p>
<p>The default javascript API uses <code>document.write</code>, which isn&#8217;t a DOM method and hence is not a method of true XML documents.  It&#8217;s not a new issue either, wp-recaptcha has had a history of <a href="http://rickardandersson.com/recaptcha-and-xhtml">breaking XHTML</a>.  The thing is, the WordPress plugin (which uses the PHP library by the recaptcha people) has an option to &#8220;Be XHTML 1.0 Strict compliant&#8221;; but this only fixes the use of iframes and noscript!</p>
<p><small class="postscript">Updated: pushed fork to github</small><br />
<span id="more-456"></span></p>
<p>Under firefox, you get an error like:</p>
<pre>
Error: uncaught exception:
[Exception... "Operation is not supported"  code: "9"
 nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
 location: "http://www.google.com/recaptcha/api/challenge?k=xxx Line: 12"]
</pre>
<p>While under Chrome it&#8217;s</p>
<pre>
Uncaught TypeError: Object #&lt;a Document&gt; has no method 'write'
api.recaptcha.net/challengek=xxx
</pre>
<p>The real solution is to use the <a href="http://code.google.com/apis/recaptcha/docs/display.html#AJAX">reCAPTCHA AJAX API</a>, which for whatever reason isn&#8217;t exposed in the PHP library.  You can grab my <a href="http://github.com/p00ya/wp-recaptcha">xml fix for wp-recaptcha</a> from github.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicating ggplot axis labels</title>
		<link>http://scarff.id.au/blog/2010/duplicating-ggplot-axis-labels/</link>
		<comments>http://scarff.id.au/blog/2010/duplicating-ggplot-axis-labels/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 14:39:36 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ggplot]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=392</guid>
		<description><![CDATA[<p>I&#8217;ve been trying for a while to find an elegant solution for duplicating axis ticks and labels in a ggplot chart.  Hadley replied on the ggplot2 mailing list, but a working solution within ggplot2 seems a way off.</p>
<p>The situation is this: imagine you have a faceted plot that is tall enough that the x-axis ticks and labels become obscured (e.g. when using a clipped viewport such as a browser window).  This is particularly destructive when you&#8217;re using an x-scale with manual breaks or a transformation.</p>
<pre class="codeblock R">
library(ggplot2)
g &#60;- ggplot(diamonds, aes(carat, ..density..)) +
   geom_histogram(aes(fill = clarity), binwidth = 0.2) +
   facet_grid(cut ~ .)
print(g)
</pre>
<p></p>
<p>There simply isn&#8217;t a way to repeat the x-axis labels in ggplot2 at the moment without discarding faceting and rendering each facet as a separate ggplot call.  I&#8217;ve seen some examples of selective plotting used to good effect in combining multiple&#8230; <a href="http://scarff.id.au/blog/2010/duplicating-ggplot-axis-labels/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying for a while to find an elegant solution for duplicating axis ticks and labels in a ggplot chart.  Hadley <a href="http://groups.google.com/group/ggplot2/browse_thread/thread/499e438a7c79994f">replied on the ggplot2 mailing list</a>, but a working solution within ggplot2 seems a way off.</p>
<p>The situation is this: imagine you have a faceted plot that is tall enough that the x-axis ticks and labels become obscured (e.g. when using a clipped viewport such as a browser window).  This is particularly destructive when you&#8217;re using an x-scale with manual breaks or a transformation.</p>
<pre class="codeblock R">
library(ggplot2)
g &lt;- ggplot(diamonds, aes(carat, ..density..)) +
   geom_histogram(aes(fill = clarity), binwidth = 0.2) +
   facet_grid(cut ~ .)
print(g)
</pre>
<p><img src="http://scarff.id.au/blog/wp-content/uploads/2010/07/facets-clipped.png" alt="Faceted Plot where the x-axis labels have been clipped out" title="Faceted Plot" class="aligncenter size-full wp-image-482" /></p>
<p>There simply isn&#8217;t a way to repeat the x-axis labels in ggplot2 at the moment without discarding faceting and rendering each facet as a separate ggplot call.  I&#8217;ve seen some <a href="http://learnr.wordpress.com/2009/05/26/ggplot2-two-or-more-plots-sharing-the-same-legend/">examples of selective plotting</a> used to good effect in combining multiple plots with common elements, but I can&#8217;t find anything applicable to keep consistent scales and binning without duplicating a lot of the (internal) facet and bin logic.</p>
<p><span id="more-392"></span></p>
<p>Instead my best shot was to clone some of the grob elements and redraw them at different locations:</p>
<pre class="codeblock R">
grob &lt;- ggplotGrob(g)
xtext &lt;- getGrob(grob, "layout::axis_h::axis.text", grep = TRUE)
xtext &lt;- editGrob(xtext, gp = gpar(fontsize = 8))
downViewport("background::panels::layout::axis_h-13-3") # ids from grid.ls()
pushViewport(viewport(y = unit(34, "npc"), name = "axis_h_rep-1"))
 grid.draw(xtext)
popViewport()
</pre>
<p>Unfortunately I couldn&#8217;t find a consistent way of querying the grid graphics internals for the measurements necessary to move the &#8220;mirrored&#8221; axis labels to the right place.  The 34 there is a magic number I found with <code>grid.locator()</code> and trial-and-error; it changes depending on the graphics device.  At one point I hoped I could clone the entire <code>axis_h</code> viewport, pry some vertical space from in between the facet panels, and paste the clones in between.  Unfortunately grid layouts don&#8217;t seem to be very mutable once they&#8217;ve been created, and redrawing the text grob seemed like the best I could do to reuse the output.</p>
<p>While looking at the <a href="http://stackoverflow.com/questions/1532535/showing-multiple-axis-labels-using-ggplot2-with-facet-wrap-in-r">stackoverflow answer for the same problem</a>, I came across Harlan&#8217;s assessment:</p>
<blockquote><p>
GGplot&#8217;s philosophy is about doing the right thing with a minimum of customization, which means, naturally, that you can&#8217;t customize things as much as other packages.
</p></blockquote>
<p>This is more significant when contrasted with the context of R itself; in R, <a href="http://www.r-project.org/about.html">the user retains full control</a>.  Coming up against ggplot&#8217;s choice of only exposing high-level primitives often leaves the user with the choice of:</p>
<ul>
<li>accepting The Way ggplot Does Things and not getting what they want</li>
<li>waiting for Hadley to write a patch (next summer, if you&#8217;re lucky?)</li>
<li>wading through ggplot internals so you can duplicate its functionality with <code>plyr</code> and <code>grid</code> calls</li>
<li>abandoning ggplot completely</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/duplicating-ggplot-axis-labels/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debian almquist shell on Mac OS X</title>
		<link>http://scarff.id.au/blog/2010/debian-almquist-shell-on-mac-os-x/</link>
		<comments>http://scarff.id.au/blog/2010/debian-almquist-shell-on-mac-os-x/#comments</comments>
		<pubDate>Tue, 04 May 2010 13:15:35 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dash]]></category>
		<category><![CDATA[mac os x]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=342</guid>
		<description><![CDATA[<p>I&#8217;ve recently changed the default shell <code>/bin/sh</code> on my Leopard install to dash from bash.  Why would I do this?  Well, by bash&#8217;s own admission (see BUGS in its manpage), bash is &#8220;too big and too slow&#8221;.  dash is used for /bin/sh by default on Ubuntu nowadays, and it&#8217;s a goal for Debian (supposedly for Lenny, but I can&#8217;t see it noted in the release notes and it&#8217;s only &#8220;confirmed&#8221; in the Lenny goals).  dash is significantly smaller and faster.</p>
<p>Ubuntu and Debian ran into plenty of bashisms when they tried to change, how about Mac OS X?  So far I&#8217;ve found problems with <code>/usr/libexec/path_helper</code> (I just changed the shebang line to <code>#!/bin/bash</code>).  There was also a problem with X11&#8242;s startx, and my patch was quickly committed.</p>
<p>Interestingly enough, when I went to move the sh binary, there are actually two versions of bash in /bin.  Both report</p>
<blockquote><p>GNU bash,</p></blockquote><p>&#8230; <a href="http://scarff.id.au/blog/2010/debian-almquist-shell-on-mac-os-x/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently changed the default shell <code>/bin/sh</code> on my Leopard install to <a href="http://gondor.apana.org.au/~herbert/dash/">dash</a> from bash.  Why would I do this?  Well, by bash&#8217;s own admission (see BUGS in its manpage), bash is &#8220;too big and too slow&#8221;.  dash is used for /bin/sh by default on Ubuntu nowadays, and it&#8217;s a goal for Debian (supposedly for Lenny, but I can&#8217;t see it noted in the release notes and it&#8217;s only &#8220;confirmed&#8221; in the <a href="http://release.debian.org/lenny/goals.txt">Lenny goals</a>).  dash is significantly smaller and faster.</p>
<p>Ubuntu and Debian ran into plenty of bashisms when they tried to change, how about Mac OS X?  So far I&#8217;ve found problems with <code>/usr/libexec/path_helper</code> (I just changed the shebang line to <code>#!/bin/bash</code>).  There was also a problem with X11&#8242;s startx, and my patch was quickly <a href="http://cgit.freedesktop.org/xorg/app/xinit/commit/?id=8464a8ab360b72f6817b19ce99b12f0793fbee74">committed</a>.</p>
<p>Interestingly enough, when I went to move the sh binary, there are actually two versions of bash in /bin.  Both report</p>
<blockquote><p>GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)</p></blockquote>
<p>but differ at the binary level (they aren&#8217;t even the same size).  I wonder if Apple tried to optimize their /bin/sh given that it gets more usage.</p>
<p>I built dash-0.5.5.1 from the tarball without a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/debian-almquist-shell-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
