<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for minorityreport</title>
    <link>http://www.advogato.org/person/minorityreport/</link>
    <description>Advogato blog for minorityreport</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Tue, 21 May 2013 11:01:47 GMT</pubDate>
    <item>
      <pubDate>Wed, 4 Jan 2006 10:41:56 GMT</pubDate>
      <title>4 Jan 2006</title>
      <link>http://www.advogato.org/person/minorityreport/diary.html?start=1</link>
      <guid>http://www.advogato.org/person/minorityreport/diary.html?start=1</guid>
      <description>Using Guile Scheme to write resilient CGI scripts.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; I've been using &lt;a href="http://www.gnu.org/software/guile/guile.html" &gt;Guile&lt;/a&gt; for scripting purposes for a while now.  It's quite fun to use and very powerful.  Guile is a full implementation of the &lt;a href="http://en.wikipedia.org/wiki/Scheme programming language" &gt;Scheme programming language&lt;/a&gt;, which is a member of the &lt;a href="http://en.wikipedia.org/wiki/Lisp programming language" &gt;Lisp&lt;/a&gt; family of languges.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; More recently I've been using it to write CGI, or rather scripts that operate both in CGI mode and from the command line.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;b&gt;&lt;a href="http://tools.wikimedia.de/~tony_sidaway/vandalism_source.html" &gt;vandalism&lt;/a&gt; &lt;/b&gt; is a guile script that plots the incidence of vandalism on any one of (currently) nine different Wikipedias, between 2001 and the present day.  It's written in 100% guile with the guile-dbi module connecting to a live replication of Wikipedia's mysql databases.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; It's written mainly in a functional style--the strategy is to construct the xhtml document in text fragments which are appended together.  Once assembled the document is sent onwards to the http client.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; If the script fails, it sends a suitable error document according to whether it's operating in development mode or production mode--in either case the error message is carefully filtered to as to avoid accidentally displaying the mysql username and password which may appear in some of the guile structures related to the database.  In development mode, a sophisticated lazy-dispatch technique is used to capture the stack at the point of failure and thus deliver backtrace information, which is not normally available in guile when operating in script mode.  A great help in development!

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; Another feature I thought I'd build in to the script is the ability to produce a html page listing its own source.  Executing the script from the command line as &lt;tt&gt;./vandalism --source &amp;gt;vandalism_source.html&lt;/tt&gt; will produce an up-to-date listing of the source and all related data files.  As you may see, the source listing isn't particularly pretty yet, but give it time.

&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; I'm particularly pleased with the way in which Scheme &lt;a href="http://en.wikipedia.org/wiki/S-expression" &gt;S-expressions&lt;/a&gt; can be used to represent &lt;a href="http://en.wikipedia.org/wiki/XHTML" &gt;xhtml&lt;/a&gt;. It's much nicer than all that stuff with the angle brackets:

&lt;p&gt; &lt;tt&gt;(define (html-table-header columns legend)&lt;br/&gt;
&amp;nbsp;&amp;nbsp;(html-row&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(html:th&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(html:attr (list (cons 'colspan columns)))&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;legend)))&lt;/tt&gt;

&lt;p&gt; and here's another one that I like:

&lt;p&gt; &lt;tt&gt;(define (html-validation-button)&lt;br/&gt;
&amp;nbsp;&amp;nbsp;(html-link&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"http://validator.w3.org/check?uri=referer"&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(html:img&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(html:attr '((src . "http://www.w3.org/Icons/valid-xhtml10")&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(alt . "Valid XHTML 1.0 Transitional")&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(height . 31)(width . 88))))))&lt;/tt&gt;

&lt;p&gt; I &lt;i&gt;could&lt;/i&gt; just write this all as plain html with embedded variables and whatnot, but I'd probably forget the closing tags, and in any case it wouldn't look as pretty.  Of course you can do this kind of thing in other languages too, but Scheme and other languages in the Lisp family tend to encourage it.</description>
    </item>
    <item>
      <pubDate>Wed, 26 Oct 2005 19:16:41 GMT</pubDate>
      <title>26 Oct 2005</title>
      <link>http://www.advogato.org/person/minorityreport/diary.html?start=0</link>
      <guid>http://www.advogato.org/person/minorityreport/diary.html?start=0</guid>
      <description>I've created some templates on &lt;a href="http://en.wikipedia.org/" &gt;English Wikipedia&lt;/a&gt; to help Advogato members to network there.

&lt;p&gt; &lt;p&gt; &lt;p&gt; Put something like this on your user page:

&lt;p&gt; &lt;p&gt; &lt;p&gt; {{User advogato-1|minorityreport}}

&lt;p&gt; &lt;p&gt; &lt;p&gt; Replace minorityreport by your own username.  advogato-0 is observer, advogato-1 is apprentice, advogato-2 is journeyer, advogato-3 is master.  If you want to be coy, use advogato without any number, and we'll just have to tramp on over to Advogato to tell your certification level.

&lt;p&gt; Whether or not you use them, please feel free to say hello at &lt;a href="http://en.wikipedia.org/wiki/User_talk:Tony_Sidaway" &gt;my Wikipedia talk page.&lt;/a&gt;</description>
    </item>
  </channel>
</rss>
