<?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>Thu, 03 Nov 2011 22:39:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Disabling hyphen substitution in Adium</title>
		<link>http://scarff.id.au/blog/2011/disabling-hyphen-substitution-in-adium/</link>
		<comments>http://scarff.id.au/blog/2011/disabling-hyphen-substitution-in-adium/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:06:34 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[adium]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=542</guid>
		<description><![CDATA[<p>By default Adium replaces two hyphens with an em-dash in text you type or paste.  This leads to subtly confusing behaviour when pasting commands:</p>
<pre class="codeblock sh">
foo --bar
</pre>
<p>becomes &#8220;foo —bar&#8221;, which can look very similar to <code>foo --bar</code> if your contact is using a terminal that supports variable-width glyphs for exotic character points.</p>
<p>It&#8217;s a quick fix: stop double-hyphens being transformed to a long dash by right clicking the Adium input field, and unticking Substitutions > Smart Dashes from the menu.</p>
]]></description>
			<content:encoded><![CDATA[<p>By default Adium replaces two hyphens with an em-dash in text you type or paste.  This leads to subtly confusing behaviour when pasting commands:</p>
<pre class="codeblock sh">
foo --bar
</pre>
<p>becomes &#8220;foo —bar&#8221;, which can look very similar to <code>foo --bar</code> if your contact is using a terminal that supports variable-width glyphs for exotic character points.</p>
<p>It&#8217;s a quick fix: stop double-hyphens being transformed to a long dash by right clicking the Adium input field, and unticking Substitutions > Smart Dashes from the menu.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2011/disabling-hyphen-substitution-in-adium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>window titles in screen and rxvt, from zsh</title>
		<link>http://scarff.id.au/blog/2011/window-titles-in-screen-and-rxvt-from-zsh/</link>
		<comments>http://scarff.id.au/blog/2011/window-titles-in-screen-and-rxvt-from-zsh/#comments</comments>
		<pubDate>Tue, 17 May 2011 14:47:58 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=534</guid>
		<description><![CDATA[<p>Recently I&#8217;ve been multiplexing work over many urxvt terminals: essential when you&#8217;re monitoring the logging output of several related binaries and managing several git branches related to each.  The sensibilities of awesome have eased the window management, but I&#8217;ve become increasingly reliant on the window title to identify particular sessions.  This is compounded one level further when I&#8217;m using screen; I want a useful identifier to show up in screen&#8217;s windowlist.</p>
<p>Getting nice prompts is a common need and there is plenty of information out there on setting your PS1, but for various reasons I&#8217;ve had problems finding a &#8216;nice&#8217; setup that&#8217;s just worked exactly the way I&#8217;ve wanted it to with titles.  Here are the pertinent parts of my working configuration:</p>
<ul>
<li>I get the working directory and current command in the title</li>
<li>I get the title in the screen windowlist if running in screen</li>
<li>I get the same</li></ul><p>&#8230; <a href="http://scarff.id.au/blog/2011/window-titles-in-screen-and-rxvt-from-zsh/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been multiplexing work over many urxvt terminals: essential when you&#8217;re monitoring the logging output of several related binaries and managing several git branches related to each.  The sensibilities of <a href="http://awesome.naquadah.org/">awesome</a> have eased the window management, but I&#8217;ve become increasingly reliant on the <a href="http://tronche.com/gui/x/icccm/sec-4.html#WM_NAME">window title</a> to identify particular sessions.  This is compounded one level further when I&#8217;m using screen; I want a useful identifier to show up in screen&#8217;s windowlist.</p>
<p>Getting nice prompts is a common need and there is plenty of information out there on setting your PS1, but for various reasons I&#8217;ve had problems finding a &#8216;nice&#8217; setup that&#8217;s just worked exactly the way I&#8217;ve wanted it to with titles.  Here are the pertinent parts of my working configuration:</p>
<ul>
<li>I get the working directory and current command in the title</li>
<li>I get the title in the screen windowlist if running in screen</li>
<li>I get the same title in the WM_NAME of an rxvt or xterm, or the titlebar of an iTerm2, whether or not screen is involved</li>
</ul>
<p><span id="more-534"></span><br />
Here&#8217;s how I set my PS1 in .zshrc:</p>
<pre class="codeblock sh">
case "$TERM" in
  # [skipping some esoteric terminal emulators...]

  screen|screen.rxvt)
     # Set a coloured prompt
     PS1=$'%{\e[00;32m%}%*%{\e[00;34m%}%2~ %# %{\e[00m%}'
     ;;
  rxvt|rxvt-unicode|xterm|xterm-color)
     # Set the title, and a coloured prompt containing some useful info
     PS1=$'%{\e]0;%-3~\a\e\[00;32m%}%*%{\e[00;30m%}!%! %{\e[00;34m%}%2~ %# %{\e[0m%}'
     ;;
esac
</pre>
<p>I want an abbreviated form of the full command line so that it will fit in awesome's tasklist.  I set the titles before a command is run in zsh's <a href="http://zsh.sourceforge.net/Doc/Release/Functions.html#index-preexec">preexec</a> hook.  The screen window title and the xterm title are set with two different escapes.</p>
<pre class="codeblock sh">
function preexec() {
  local a=${${1## *}[(w)1]}  # get the command
  local b=${a##*\/}   # get the command basename
  a="${b}${1#$a}"     # add back the parameters
  a=${a//\%/\%\%}     # escape print specials
  a=$(print -Pn "$a" | tr -d "\t\n\v\f\r")  # remove fancy whitespace
  a=${(V)a//\%/\%\%}  # escape non-visibles and print specials

  case "$TERM" in
    screen|screen.*)
      # See screen(1) "TITLES (naming windows)".
      # "\ek" and "\e\" are the delimiters for screen(1) window titles
      print -Pn "\ek%-3~ $a\e\\" # set screen title.  Fix vim: ".
      print -Pn "\e]2;%-3~ $a\a" # set xterm title, via screen "Operating System Command"
      ;;
    rxvt|rxvt-unicode|xterm|xterm-color|xterm-256color)
      print -Pn "\e]2;%m:%-3~ $a\a"
      ;;
  esac
}
</pre>
<p>This requires the title to be reset for screen (since it&#8217;s not reset by PS1), using zsh&#8217;s <a href="http://zsh.sourceforge.net/Doc/Release/Functions.html#index-precmd">precmd hook</a>:</p>
<pre class="codeblock sh">
function precmd() {
  case "$TERM" in
    screen|screen.rxvt)
      print -Pn "\ek%-3~\e\\" # set screen title
      print -Pn "\e]2;%-3~\a" # must (re)set xterm title
      ;;
  esac
}
</pre>
<p>The beauty of this method (unlike methods that bind screen&#8217;s <a href="http://www.gnu.org/software/termutils/manual/termcap-1.3/html_node/termcap_41.html">status line</a> escapes to xterm Operating System Command escapes) is that no termcapinfo hacks in .screenrc are necessary.</p>
<p><small class="postscript">Update: changed preexec to use zsh subscripting rather than splitting by IFS.  Fixes duplication of 0-argument commands, e.g. &#8220;top top&#8221;.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2011/window-titles-in-screen-and-rxvt-from-zsh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search engine optimization with git web interfaces</title>
		<link>http://scarff.id.au/blog/2010/search-engine-optimization-with-git-web-interfaces/</link>
		<comments>http://scarff.id.au/blog/2010/search-engine-optimization-with-git-web-interfaces/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 08:17:45 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=502</guid>
		<description><![CDATA[<p>I recently became frustrated with gitweb&#8217;s funky query-strings and decided to give cgit a try.  Although there are some patches that make gitweb more user (and search engine) friendly, cgit is a much better web-interface for git, both in terms of the code and the actual user experience.  However, there were still some opportunities for <acronym title="search engine optimization">SEO</acronym>.</p>
<p>I went through the HTML suggestions from the google webmaster tools and Google&#8217;s own SEO Starter Guide.  I&#8217;ve pushed the search engine optimized cgit to my seo branch on github.  You can see it in action at my git repositories.  I&#8217;m testing all of this using an Apache <code>ScriptAlias</code> directive, I&#8217;m hoping it will still work alright with whatever other URL-processing schemes cgit supports.  A short summary of the new SEO features so far:</p>
<ul>
<li>Use HTML <code>h1</code> and <code>h2</code> heading tags instead of custom-styled <code>div</code>s</li>
<li>Much better <code>title</code> tags; commits</li></ul><p>&#8230; <a href="http://scarff.id.au/blog/2010/search-engine-optimization-with-git-web-interfaces/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>I recently became frustrated with gitweb&#8217;s funky query-strings and decided to give <a href="http://hjemli.net/git/cgit/about/">cgit</a> a try.  Although there are <a href="http://kerneltrap.org/mailarchive/git/2010/4/11/28082">some patches</a> that make gitweb more user (and search engine) friendly, cgit is a much better web-interface for git, both in terms of the code and the actual user experience.  However, there were still some opportunities for <acronym title="search engine optimization">SEO</acronym>.</p>
<p>I went through the HTML suggestions from the google webmaster tools and Google&#8217;s own <a href="http://www.google.com/webmasters/docs/search-engine-optimization-starter-guide.pdf">SEO Starter Guide</a>.  I&#8217;ve pushed the <a href="http://github.com/p00ya/cgit/">search engine optimized cgit</a> to my seo branch on github.  You can see it in action at my <a href="/cgit/">git repositories</a>.  I&#8217;m testing all of this using an Apache <code>ScriptAlias</code> directive, I&#8217;m hoping it will still work alright with whatever other URL-processing schemes cgit supports.  A short summary of the new SEO features so far:</p>
<ul>
<li>Use HTML <code>h1</code> and <code>h2</code> heading tags instead of custom-styled <code>div</code>s</li>
<li>Much better <code>title</code> tags; commits have the commit subject, and the repo name has been added in a lot of places to avoid duplicate titles</li>
<li>The bread-crumb has been integrated into the heading</li>
<li>A configurable option to set <code>nofollow</code> relationships on links to non-HEAD commits, to avoid duplicate content being indexed</li>
</ul>
<p>Of course, you could take the popular option of just using github instead of self-hosting your own git web interfaces&#8230; but even they don&#8217;t do quite a good a job <acronym title="in my opinion">IMO</acronym>, they use the SHA1 in the web page titles, eww!</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/search-engine-optimization-with-git-web-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
	</channel>
</rss>

