<?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; Programs</title>
	<atom:link href="http://scarff.id.au/blog/category/software/programs/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>Window titles in screen and urxvt, from vim</title>
		<link>http://scarff.id.au/blog/2011/window-titles-in-screen-and-urxvt-from-vim/</link>
		<comments>http://scarff.id.au/blog/2011/window-titles-in-screen-and-urxvt-from-vim/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 18:14:14 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[rxvt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=557</guid>
		<description><![CDATA[<p>I previously posted about generating title escapes for screen and rxvt-unicode from zsh. I&#8217;ve since worked on getting a consistent title from vim, too.  It&#8217;s become complex enough that I&#8217;m spinning it out into a new post.</p>
<p>To set both titles from vim, use its termcap-title options to push the title to screen using the iconstring.  When not running under screen, the right titlestring escapes will be inferred from terminfo.</p>
<pre class="codeblock vimscript">
set title
auto BufEnter * let &#38;titlestring = s:MyTitle()

if &#38;term =~ 'screen\(\.\(xterm\&#124;rxvt\)\(-\(256\)\?color\)\?\)\?'
  " Set the screen title using the vim "iconstring"."
  set t_IS=<u>^[</u>k
  set t_IE=<u>^[</u>\
  set icon
  auto BufEnter * let &#38;iconstring = &#38;titlestring
  " Set the xterm title using the vim "titlestring"."
  set t_ts=<u>^[</u>]2;
  set t_fs=<u>^G</u>
endif
</pre>
<p>where the underlined characters are actual escapes input with ^V, not with literal carets.</p>
<p>As for generating a fancy title string like vim: there are some gotchas.&#8230; <a href="http://scarff.id.au/blog/2011/window-titles-in-screen-and-urxvt-from-vim/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>I previously posted about <a href="/blog/2011/window-titles-in-screen-and-rxvt-from-zsh/">generating title escapes</a> for screen and rxvt-unicode from zsh. I&#8217;ve since worked on getting a consistent title from vim, too.  It&#8217;s become complex enough that I&#8217;m spinning it out into a new post.</p>
<p>To set both titles from vim, use its <a href="http://vimdoc.sourceforge.net/htmldoc/term.html#termcap-title">termcap-title</a> options to push the title to screen using the iconstring.  When not running under screen, the right titlestring escapes will be inferred from terminfo.</p>
<pre class="codeblock vimscript">
set title
auto BufEnter * let &amp;titlestring = s:MyTitle()

if &amp;term =~ 'screen\(\.\(xterm\|rxvt\)\(-\(256\)\?color\)\?\)\?'
  " Set the screen title using the vim "iconstring"."
  set t_IS=<u>^[</u>k
  set t_IE=<u>^[</u>\
  set icon
  auto BufEnter * let &amp;iconstring = &amp;titlestring
  " Set the xterm title using the vim "titlestring"."
  set t_ts=<u>^[</u>]2;
  set t_fs=<u>^G</u>
endif
</pre>
<p>where the underlined characters are actual escapes input with ^V, not with literal carets.</p>
<p>As for generating a fancy title string like vim: there are some gotchas.  The biggest is that vim does not preserve logical directory names, so <code>getcwd()</code> will resolve symlinks, leading to a different location string than generated by zsh&#8217;s <q>%~</q>.  Rather than call <code>pwd -L</code>, we might as well unify the expansion syntax and call zsh.  Of course, it&#8217;s nice to have a fallback, too:</p>
<p><span id="more-557"></span></p>
<pre class="codeblock">
" Perform zsh-like prompt expansion using the template {prompt}.  See
" "EXPANSION OF PROMPT SEQUENCES" in zshmisc(1).
function s:ZshPromptExpn(prompt)
  if &amp;shell == "/bin/zsh"
    return system("print -Pn " . shellescape(a:prompt))
  else
    " Fallback to poor man's prompt expansion.
    " By no means equivalent to zsh.
    let idx = 0
    let result = ''
    let escapere = '%\([%)m]\|\(\(-\?[0-9]\+\)\?[~]\)\)'
    while idx &lt; len(a:prompt)
      let nextesc = match(a:prompt, escapere, idx)
      if nextesc &lt; 0
        let result .= a:prompt[idx :]
        break
      elseif idx &lt; nextesc
        let result .= a:prompt[idx : (nextesc - 1)]
      endif

      let idx = matchend(a:prompt, escapere, nextesc)
      let esc = a:prompt[nextesc : (idx - 1)]
      if esc == '%m'
        let result .= substitute(hostname(), '^\([^.]*\).*', '\1', '')
      elseif esc =~ '%-\?[0-9]*[~]'
        let result .= fnamemodify(getcwd(), ':~')[:-2]
      elseif esc == '%%'
        let result .= '%'
      endif
    endwhile
    return result
endfunction

function s:MyTitle()
  return s:ZshPromptExpn("%m:%-3~ ") .
  \ v:progname . " " . fnamemodify(expand("%:f"), ":.")
endfunction
</pre>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2011/window-titles-in-screen-and-urxvt-from-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RFC 3825 Geolocation configuration generator tool</title>
		<link>http://scarff.id.au/blog/2010/rfc-3825-geolocation-configuration-generator-tool/</link>
		<comments>http://scarff.id.au/blog/2010/rfc-3825-geolocation-configuration-generator-tool/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 08:15:53 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Programs]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=510</guid>
		<description><![CDATA[<p>While mobile devices (especially those with a GPS) have made people more aware of geolocation/geotagging, you don&#8217;t need a GPS in a device to make it location-aware, nor do you need to resort to IP-based reverse lookups.  Location information can be made available on any network that has a DHCP server using the Location Configuration Information DHCP Option defined in RFC 3825.  It makes sense: for most wired or wireless networks, the engineer responsible for setting up the DHCP server will know at the least where the server or AP is located, and maybe even static information about the locations of each terminal of a wired port.</p>
<p>The Option has a somewhat unorthodox binary format with non-power-of-2-width fixed point reals.  To make generating the DHCP configuration statements easier, I developed a web-based RFC 3825 location configuration generation tool.  It&#8217;s all client-side and even has a Google Maps preview of the&#8230; <a href="http://scarff.id.au/blog/2010/rfc-3825-geolocation-configuration-generator-tool/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>While mobile devices (especially those with a GPS) have made people more aware of geolocation/geotagging, you don&#8217;t need a GPS in a device to make it location-aware, nor do you need to resort to IP-based reverse lookups.  Location information can be made available on any network that has a DHCP server using the <a href="http://tools.ietf.org/html/rfc3825">Location Configuration Information DHCP Option</a> defined in RFC 3825.  It makes sense: for most wired or wireless networks, the engineer responsible for setting up the DHCP server will know at the least where the server or AP is located, and maybe even static information about the locations of each terminal of a wired port.</p>
<p>The Option has a somewhat unorthodox binary format with non-power-of-2-width fixed point reals.  To make generating the DHCP configuration statements easier, I developed a web-based <a href="/tools/rfc-3825-location-configuration.html">RFC 3825 location configuration generation tool</a>.  It&#8217;s all client-side and even has a Google Maps preview of the location!</p>
<p>Copy the configuration to your local DHCP server, grab an appropriate <a href="http://igtk.sourceforge.net/">geolocation library</a>, and you&#8217;re ready to go!  The tool generates a DHCP LCI Option for both dnsmasq and ISC&#8217;s dhcpd.</p>
<p>The lack of fixed point integers in Javascript made the implementation a little trickier than it would have been in, say, C.</p>
<p>Other lessons: Google Maps is <a href="http://freegeographytools.com/2007/positional-accuracy-in-google-maps-my-maps-vs-google-earth">not highly accurate</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/rfc-3825-geolocation-configuration-generator-tool/feed/</wfw:commentRss>
		<slash:comments>2</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>

