<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Egregious Thoughts</title>
  <link>http://ghewgill.livejournal.com/</link>
  <description>Egregious Thoughts - LiveJournal.com</description>
  <lastBuildDate>Thu, 17 Dec 2009 11:09:04 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>ghewgill</lj:journal>
  <lj:journalid>1231916</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
  <image>
    <url>http://l-userpic.livejournal.com/6834531/1231916</url>
    <title>Egregious Thoughts</title>
    <link>http://ghewgill.livejournal.com/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/139896.html</guid>
  <pubDate>Thu, 17 Dec 2009 11:09:04 GMT</pubDate>
  <title>relight: restart a crashing process</title>
  <link>http://ghewgill.livejournal.com/139896.html</link>
  <description>&lt;p&gt;One of the projects I have running is a temperature monitor. I built a &lt;a href=&quot;http://www.qkits.com/serv/qkits/diy/pages/QK145.asp&quot;&gt;QK145&lt;/a&gt; temperature monitor kit a few years ago and have been monitoring &lt;a href=&quot;http://tempmon.hewgill.com/&quot;&gt;local temperature data&lt;/a&gt; for a few years now. However, the process I have monitoring and logging the temperature occasionally crashes with a bus error or illegal instruction or some other weird error. I don&apos;t know whether it&apos;s related to the old version of FreeBSD running the server, or dodgy hardware (memory?), a broken driver, or what. It doesn&apos;t happen often enough to get concerned about (yet).&lt;/p&gt;

&lt;p&gt;Anyway, I got annoyed with having to restart the monitor if it happened to fall over. The result is &lt;a href=&quot;http://github.com/ghewgill/relight&quot;&gt;relight&lt;/a&gt;, a small Python script that automatically restarts a process that crashes occasionally. Here&apos;s the usage:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;Usage: ./relight.py [options] command args ...

        -n restarts
            number of restarts within a minute before we give up (default 5)
        -l logfile
            name of log file (default relight.log)
        -w wait
            seconds to wait between restarts (default 5)
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Relight also comes with complete &lt;a href=&quot;http://github.com/ghewgill/relight/blob/master/test-relight.py&quot;&gt;unit tests&lt;/a&gt;! It was a bit tricky to write automated tests that deliberately killed a process spawned by a child process (a &quot;grandchild&quot; process). But by having the grandchild process echo its own pid, the test code was able to read that and send a SIGKILL to the correct process.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/139896.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/139532.html</guid>
  <pubDate>Mon, 14 Dec 2009 08:49:44 GMT</pubDate>
  <title>marginal costs of leisure activities</title>
  <link>http://ghewgill.livejournal.com/139532.html</link>
  <description>I just sent a resignation email to the &lt;a href=&quot;http://www.glidingcanterbury.org.nz&quot;&gt;Canterbury Gliding Club&lt;/a&gt;. I haven&apos;t been flying in something over a year, and I couldn&apos;t justify the continued membership expense if I&apos;m not even going to fly.&lt;br /&gt;&lt;br /&gt;Flying with &lt;a href=&quot;http://faultlineflyers.org&quot;&gt;Fault Line Flyers&lt;/a&gt; in Texas was pretty much a no-brainer for me at the time. It was about US$23 for a tow, and time in the air (glider rental) was a flat $3 or so per flight. I was living by myself and had plenty of time and enough money to spend on a weekend activity.&lt;br /&gt;&lt;br /&gt;Here, a similar tow is about NZ$50, and glider rental is just under $1 per &lt;em&gt;minute&lt;/em&gt; of flying time. As you can imagine, that adds up extremely quickly and the reality is it exceeds what I can justify for a weekend activity today. Especially since I like to spend weekend time with my wife (as one or both of us often seem to be busy during weeknights).&lt;br /&gt;&lt;br /&gt;Coming to this conclusion was tough because I truly enjoy flying, but was always conscious of how much it cost. Naturally, that dampened the enjoyment somewhat. I realised that there are two types of leisure activities: those that have a marginal cost, and those that don&apos;t. Activities with a marginal cost are those where you have to shell out some amount of cash &lt;em&gt;every time&lt;/em&gt; you do whatever it is. Gliding is definitely one of these activities; skiing, skydiving, and golfing are other examples. On the other hand, activities without a marginal cost usually require you to purchase equipment of some kind, but doing the activity &lt;em&gt;just once&lt;/em&gt; doesn&apos;t cost anything. There are many examples of this: cycling, surfing, hiking, fishing, diving, even things like sailing or motorcycling (where the initial cost might be substantial). I have discovered that I&apos;m a no-marginal-cost kind of guy. (Having said that, I&apos;ll still go skiing!)&lt;br /&gt;&lt;br /&gt;Speaking of gliding, congratulations to Terry Delore who just yesterday &lt;a href=&quot;http://www.stuff.co.nz/national/3155973/Gliding-on-to-a-world-record&quot;&gt;broke the world distance gliding record&lt;/a&gt; with a 2501 km flight!</description>
  <comments>http://ghewgill.livejournal.com/139532.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/139264.html</guid>
  <pubDate>Wed, 09 Dec 2009 08:49:06 GMT</pubDate>
  <title>debug line information in psil compiler</title>
  <link>http://ghewgill.livejournal.com/139264.html</link>
  <description>&lt;p&gt;I&apos;ve only had a bit of time to work on the Psil compiler, but it&apos;s coming along well. The compiler now generates Python AST code for many kinds of examples.&lt;/p&gt;

&lt;p&gt;As mentioned &lt;a href=&quot;http://ghewgill.livejournal.com/139113.html&quot;&gt;previously&lt;/a&gt;, I&apos;ve tried annotating the AST with line and column information to help locate Python runtime errors. The representation of lists that I&apos;m currently using (just a Python list) doesn&apos;t leave a lot of room to store the extra annotation information. For example, the code:&lt;/p&gt;

&lt;pre&gt;(print (+ foo 5))
&lt;/pre&gt;

&lt;p&gt;is represented as the following Python lists:&lt;/p&gt;

&lt;pre&gt;[Symbol(&quot;print&quot;), [Symbol(&quot;+&quot;), Symbol(&quot;foo&quot;), 5]]
&lt;/pre&gt;

&lt;p&gt;There&apos;s not a lot of room in this representation to store source line annotations. The first thing I tried was to declare a global &lt;code&gt;DebugInfo&lt;/code&gt; dictionary, indexed by the &lt;code&gt;id()&lt;/code&gt; of the list (Python&apos;s &lt;code&gt;id()&lt;/code&gt; represents a unique identifier such as a machine address). So for example, the above debug info might be:&lt;/p&gt;

&lt;pre&gt;DebugInfo[123456] = [(1, 2), (1, 8)]
DebugInfo[123460] = [(1, 9), (1, 11), (1, 15)]
&lt;/pre&gt;

&lt;p&gt;The first &lt;code&gt;DebugInfo[123456]&lt;/code&gt; represents the starting line and column of each element in the first (outer) list. The second &lt;code&gt;DebugInfo[123460]&lt;/code&gt; represents the same for the three elements of the inner list. This seemed like a great idea, and it was poised to work well for small examples. However, after some more complex examples particularly including macro expansion (very common in a Lisp language), the original code was garbage collected and the addresses of lists were re-used, causing the &lt;code&gt;DebugInfo&lt;/code&gt; addresses to align with &lt;em&gt;different&lt;/em&gt; source lists! This was tricky to track down.&lt;/p&gt;

&lt;p&gt;I&apos;ve moved that code to another branch until I figure out what to do with it. I may be able to manage it by not letting the original code as read from the source be garbage collected (by keeping a reference somewhere else), that could work. The information only needs to be kept during the compile phase, as soon as it&apos;s embedded in the AST it doesn&apos;t need to hang around any longer.&lt;/p&gt;

&lt;p&gt;Anyway, more work needed. Just writing this post helped me sort out some ideas. &lt;a href=&quot;http://github.com/ghewgill/psil&quot;&gt;Source on GitHub&lt;/a&gt;.</description>
  <comments>http://ghewgill.livejournal.com/139264.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/139113.html</guid>
  <pubDate>Wed, 25 Nov 2009 08:00:42 GMT</pubDate>
  <title>psil presentation and compiler details</title>
  <link>http://ghewgill.livejournal.com/139113.html</link>
  <description>&lt;p&gt;As &lt;a href=&quot;http://ghewgill.livejournal.com/138708.html&quot;&gt;promised last week&lt;/a&gt;, I&apos;ve been working on making Psil work in a Python 3 environment. But first, a small but entirely relevant digression which includes a video of me giving a presentation:&lt;/p&gt;

&lt;p&gt;A few weeks ago, I attended &lt;a href=&quot;http://nz.pycon.org/&quot;&gt;Kiwi PyCon&lt;/a&gt; here in Christchurch. I had thought about maybe possibly presenting something when I signed up, but I didn&apos;t actually prepare anything ahead of time. Immediately after lunch on the first day, there was a &quot;lightning talk&quot; session where people get 5 minutes to present something, no questions from the audience. During lunch, I decided that my opportunity was right then, and that if I didn&apos;t try to present something then I&apos;d probably be annoyed at myself for not having tried.&lt;/p&gt;

&lt;p&gt;Anyway, I hurriedly prepared a &lt;a href=&quot;http://hewgill.com/~greg/psil-lightning-talk.pdf&quot;&gt;presentation (PDF, 8 slides)&lt;/a&gt; in the 30 minutes before the presentation, and wondered whether I would even be able to find 5 minutes worth of stuff to say. It turns out I did, because although it felt like I had zipped through my presentation in like 3 minutes, I actually took slightly over 5 minutes. There is a video recording of my (terrible) presentation that you can &lt;a href=&quot;http://blip.tv/file/2829247/&quot;&gt;watch online&lt;/a&gt; (skip forward to about 52:00 using the slider).&lt;/p&gt;

&lt;p&gt;Right, now that you&apos;re back, I&apos;ll continue with what I was going to write about.&lt;/p&gt;

&lt;p&gt;The Psil compiler (as opposed to the interpreter) compiles Psil code into Python code, which is then executed directly by the Python runtime system. For example, here is a simple function and its use:&lt;/p&gt;

&lt;pre&gt;
    Psil                            Python
    ----                            ------

    (define (sq x) (* x x))         def sq(x):
                                        return x * x

    (print (sq (+ 2 3)))            print sq(2 + 3)
&lt;/pre&gt;

&lt;p&gt;Previously (before the current Python 3 migration), I did this by generating literal Python source code as shown in the right hand column above. But instead of generating the source code directly, I generated a Python AST (Abstract Syntax Tree) representation, then implemented a &quot;de-parser&quot; that creates equivalent Python source code from an AST. The original idea was to have Python compile and execte the AST directly (rather than going through the source code step), but I think the version of Python 2.x that I was using didn&apos;t support passing an AST to the &lt;code&gt;compile()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Since Psil now requires Python 3, the &lt;code&gt;compile()&lt;/code&gt; function supports direct compilation of an AST that represents Python code. So now Psil can generate the AST, pass it to &lt;code&gt;compile()&lt;/code&gt; without going through source code, and execute the resulting code object directly. One of the difficulties with this was that the internal Python AST changed &lt;em&gt;completely&lt;/em&gt; from version 2 to 3, so I had to rework most of the compiler code. Fortunately, it turned out to be reasonably straightforward. I also maintained the de-parser because debugging actual source code is a lot easier than debugging with only an AST.&lt;/p&gt;

&lt;p&gt;Right now I&apos;ve got this all working for simple examples. I still need to re-implement the &quot;lambda lift&quot; which promotes a Psil lambda expression (which may contain an arbitrary number of forms) to a Python function (because Python&apos;s lambdas can only contain a single expression).&lt;/p&gt;

&lt;p&gt;The next interesting thing I can do with an AST is annotate the nodes with source line and column numbers. This means that if a Python exception happens at runtime, the traceback will actually point to the location in the &lt;em&gt;Psil&lt;/em&gt; source code that caused it! That&apos;s a pretty cool feature and I&apos;m looking forward to playing with that.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/139113.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/138884.html</guid>
  <pubDate>Sat, 21 Nov 2009 03:47:03 GMT</pubDate>
  <title>thawte web-of-trust shut down, what next?</title>
  <link>http://ghewgill.livejournal.com/138884.html</link>
  <description>Since &lt;a href=&quot;http://www.thawte.com/resources/personal-email-certificates/index.html&quot;&gt;Thawte has shut down their free Personal Email Certificates&lt;/a&gt; program, there doesn&apos;t appear to be a free community-driven replacement for S/MIME certificates. &lt;strike&gt;Thawte&lt;/strike&gt; VeriSign offers personal email certificates for US$20 per year, but no thanks.&lt;br /&gt;&lt;br /&gt;It looks like we&apos;re back to the tried-and-true PGP for no-cost secure person-to-person communications.</description>
  <comments>http://ghewgill.livejournal.com/138884.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/138708.html</guid>
  <pubDate>Thu, 19 Nov 2009 08:45:30 GMT</pubDate>
  <title>python 2 to 3 upgrade and exception handling</title>
  <link>http://ghewgill.livejournal.com/138708.html</link>
  <description>&lt;p&gt;I&apos;ve just (partially) upgraded &lt;a href=&quot;http://github.com/ghewgill/psil&quot;&gt;Psil&lt;/a&gt; to Python 3. I had originally been developing it in Python 2, but there are a few particular things about Python 3 that make it a better choice. There&apos;s no particular reason it needs to run on Python 2, so I decided to not develop two parallel versions, and not try to &lt;a href=&quot;http://nedbatchelder.com/blog/200910/running_the_same_code_on_python_2x_and_3x.html&quot;&gt;run the same code in both Python 2 and 3&lt;/a&gt;, but just upgrade wholesale to Python 3 and not look back.&lt;/p&gt;

&lt;p&gt;There were in fact only a few simple changes that were required. The most obvious is the &lt;code&gt;print()&lt;/code&gt; function, but I also ran into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The result of &lt;code&gt;map()&lt;/code&gt; is an iterator not a list (this affected some unit test code)&lt;/li&gt;
&lt;li&gt;Renaming of &lt;code&gt;raw_input()&lt;/code&gt; to &lt;code&gt;input()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use of &lt;code&gt;next(it)&lt;/code&gt; instead of &lt;code&gt;it.next()&lt;/code&gt; (and my use of a local variable called &lt;code&gt;next&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Need to use &lt;code&gt;f(*a)&lt;/code&gt; instead of &lt;code&gt;apply(f, a)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Lack of &lt;code&gt;callable(x)&lt;/code&gt; (use &lt;code&gt;hasattr(x, &quot;__call__&quot;)&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Exception syntax: &lt;code&gt;except Exception as e&lt;/code&gt; instead of &lt;code&gt;except Exception, e&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;reduce()&lt;/code&gt; now lives in the functools module&lt;/li&gt;
&lt;li&gt;Some test code needed to handle Unicode strings properly&lt;/li&gt;
&lt;li&gt;A difference in default exception handling (more on that below)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I certainly got a pretty good coverage of the major differences.&lt;/p&gt;

&lt;p&gt;The problem I had with exception handling was related to my &lt;a href=&quot;http://ghewgill.livejournal.com/123811.html&quot;&gt;unorthodox method of handling tail recursion&lt;/a&gt;. When I ran a program that used a lot of tail recursion, the memory usage immediately and quickly went through the roof! Clearly there was a memory leak, but Python is generally supposed to handle that for me with its garbage collector. The clue to solving this lay in an obscure warning in the documentation for &lt;code&gt;sys.exc_info&lt;/code&gt;:&lt;/p&gt;

&lt;div style=&quot;background-color: #ffe4e4; border: 1px solid #f66; margin-left: 1em&quot;&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Assigning the &lt;em&gt;traceback&lt;/em&gt; return value to a local variable in a function that is handling an exception will cause a circular reference. This will prevent anything referenced by a local variable in the same function or by the traceback from being garbage collected.&lt;/div&gt;

&lt;p&gt;I had read that warning, but I wasn&apos;t using the traceback of &lt;code&gt;sys.exc_info&lt;/code&gt; at all so I thought that shouldn&apos;t be a problem. However, Python 3 now automatically includes a &lt;code&gt;__traceback__&lt;/code&gt; attribute of every exception (see &lt;a href=&quot;http://www.python.org/dev/peps/pep-3134/&quot;&gt;PEP 3134&lt;/a&gt;). Due to the way I was calling a function referenced within the exception object itself, the presence of the traceback was creating a huge chain of unfreeable function and exception references.&lt;/p&gt;

&lt;p&gt;Fortunately, there was a simple solution:&lt;/p&gt;

&lt;pre&gt;
        except TailCall as t:
            a = t
            a.__traceback__ = None
&lt;/pre&gt;

&lt;p&gt;Setting the &lt;code&gt;__traceback__&lt;/code&gt; attribute explicitly to &lt;code&gt;None&lt;/code&gt; releases the reference to previous stack frames and my code no longer leaks memory.&lt;/p&gt;

&lt;p&gt;On the recommendation of the python-dev mailing list, I filed a &lt;a href=&quot;http://bugs.python.org/issue7340&quot;&gt;documentation bug&lt;/a&gt; to clarify the warning quoted above.&lt;/p&gt;

&lt;p&gt;Finally, I said at first that this was a partial upgrade, because I haven&apos;t even addressed the compiler part of Psil (that compiles Psil code to native Python). The modules and interfaces that I was using previously are either gone or changed in Python 3, so a slightly different approach is needed. More on that in a later post.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/138708.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/138361.html</guid>
  <pubDate>Thu, 12 Nov 2009 10:45:06 GMT</pubDate>
  <title>look before you leap</title>
  <link>http://ghewgill.livejournal.com/138361.html</link>
  <description>I started to investigate &lt;a href=&quot;http://ghewgill.livejournal.com/138142.html&quot;&gt;yesterday&apos;s idea of a shell implementation in Perl&lt;/a&gt;, and immediately got mired in the Byzantine shell quoting rules. The most basic thing about the shell turns out to be unnecessarily hard, and besides, it&apos;s already been done. Why did I think this was a good idea again?&lt;br /&gt;&lt;br /&gt;Somehow I had got it into my head that msysgit on Windows would only run from the msysgit shell. Since I don&apos;t &lt;em&gt;actually&lt;/em&gt; use Git on Windows, it turns out I was mistaken. If you run any Git command from the regular Windows command prompt, it already works. The appropriate shell is invoked to execute the shell script (git-rebase is one such shell script, instead of being part of the native C implementation).&lt;br /&gt;&lt;br /&gt;Nothing to see here, move along...</description>
  <comments>http://ghewgill.livejournal.com/138361.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/138142.html</guid>
  <pubDate>Wed, 11 Nov 2009 18:59:16 GMT</pubDate>
  <title>git on windows</title>
  <link>http://ghewgill.livejournal.com/138142.html</link>
  <description>&lt;a href=&quot;http://git-scm.com&quot;&gt;Git&lt;/a&gt; is mostly written in C, with some important parts in shell and Perl. This works well on Unix-like platforms, but unfortunately suffers on Windows because there is no native Windows (Bourne) shell. Git can be built under the Cygwin environment, but that is a heavyweight solution and Cygwin is not appropriate for general use. &lt;a href=&quot;http://code.google.com/p/msysgit/&quot;&gt;msysgit&lt;/a&gt; builds a native Windows executable plus uses the msys shell implementation, which provides a workable solution, but still requires Git operations to be done within the msys shell and not the native Windows command shell.&lt;br /&gt;&lt;br /&gt;I had a thought the other day, that one could implement a Bourne shell interpreter in a more widely available language such as Python. This would provide a more widely portable option for using Git, and on Windows in particular. Such a shell implementation would provide the minimum implementation necessary to run Git&apos;s shell scripts (and which would include minimal implementations of various utitilies such as grep, sed, and awk). That wouldn&apos;t solve the Perl script problem, so it seems obvious that a portable shell interpreter designed for use with Git should be written in Perl.&lt;br /&gt;&lt;br /&gt;A long time ago there was the &lt;a href=&quot;http://use.perl.org/~cwest/journal/20025&quot;&gt;Perl Power Tools&lt;/a&gt; project, which aimed to provide implementations of various Unix utilities in native Perl. Unfortunately, nobody ever submitted an implementation for &lt;tt&gt;sh&lt;/tt&gt;. Is there any existing implementation of a Bourne-like shell in Perl? More generally, is this a viable plan to make Git work better on Windows?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Update&lt;/strong&gt;: See the &lt;a href=&quot;http://ghewgill.livejournal.com/138361.html&quot;&gt;next post&lt;/a&gt; to find out just how far I got with this.</description>
  <comments>http://ghewgill.livejournal.com/138142.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/137964.html</guid>
  <pubDate>Sat, 07 Nov 2009 08:38:52 GMT</pubDate>
  <title>lnk.nu and google app engine</title>
  <link>http://ghewgill.livejournal.com/137964.html</link>
  <description>Last week, I was quietly working on my web server when all of a sudden the whole thing ground to a near-halt. It wasn&apos;t completely dead, because it would still ping and every few &lt;em&gt;minutes&lt;/em&gt; I would receive another packet of characters (I was literally in the middle of refreshing a screen I was looking at). Not knowing what was happening and not having any way to find out, I went and did something else for a while.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;45 minutes later&lt;/strong&gt;, my server returned to normal operation as if nothing had happened. This did not appear to be just a network congestion problem, it was definitely something my server was busy doing. A bit of investigation showed that the culprit was in fact &lt;a href=&quot;http://lnk.nu&quot;&gt;lnk.nu&lt;/a&gt;. Hundreds of machines all across Canada had all accessed the same short link at the same time, and completely pegged the PostgreSQL database processes, and also run my server out of memory. It&apos;s quite a testament to both FreeBSD and PostgreSQL that they survived at all.&lt;br /&gt;&lt;br /&gt;What I believe happened was that somebody had sent an email containing a lnk.nu link to a mailing list to which lots of people from Canada were subscribed. (The link in question happened to be a job opening at &lt;a href=&quot;http://who.int&quot;&gt;who.int&lt;/a&gt;.) Looking up the reverse PTR records for the machines that loaded the URL, there are names like &quot;mail&quot;, &quot;barracuda&quot;, &quot;filtre&quot;, &quot;antispam&quot;, &quot;mx1&quot;, &quot;incoming-smtp&quot;, &quot;guardian&quot;, etc. It seems that they all accessed the link for purposes of virus checking, all at pretty much exactly the same time. This was not good for my poor server.&lt;br /&gt;&lt;br /&gt;I decided that it might be time to move lnk.nu to a different server. It&apos;s written in Python, so it&apos;s an ideal candidate for &lt;a href=&quot;http://appengine.google.com&quot;&gt;Google App Engine&lt;/a&gt;, and I&apos;ve been looking for an excuse to play with GAE. So I downloaded the SDK, converted the code over to GAE (using Google&apos;s datastore instead of SQL), and made it work locally. This part was refreshingly easy and worked well.&lt;br /&gt;&lt;br /&gt;The next step is to set up the Google site so it responds to &lt;a href=&quot;http://lnk.nu&quot;&gt;http://lnk.nu&lt;/a&gt; and handles the requests appropriately. Given that I&apos;ve already got the code working locally, that should be straightforward. However, there is one gigantic caveat when using Google web site services (that I&apos;ve actually already run into for another project): &lt;a href=&quot;http://code.google.com/appengine/kb/general.html#naked_domain&quot;&gt;You cannot have Google&apos;s servers respond to a &quot;naked&quot; domain name that doesn&apos;t have a hostname&lt;/a&gt;. This means that having Google respond to &lt;a href=&quot;http://lnk.nu&quot;&gt;http://lnk.nu&lt;/a&gt; is not possible.&lt;br /&gt;&lt;br /&gt;(There is in fact a good technical reason for the above restriction. When you set up a site with Google hosting, you add a CNAME record to the DNS for your hostname, ie. &quot;www.example.com. CNAME ghs.google.com.&quot;. This lets Google completely manage the association between &quot;ghs.google.com&quot; and any particular IP address(es), which is critical for their load balancing setup. The caveat is that a record with a CNAME must not have any other DNS records associated with it, including an SOA record. The SOA record is required on a &quot;naked&quot; domain name like lnk.nu, so you can&apos;t add a CNAME there.)&lt;br /&gt;&lt;br /&gt;To work around this, I&apos;ll have to set up a hostname that Google can respond to, something like &lt;a href=&quot;http://a.lnk.nu&quot;&gt;http://a.lnk.nu&lt;/a&gt;. Of course, that&apos;s a pretty lame name for a link shortener to use, so I&apos;ll still want the published link to be &lt;a href=&quot;http://lnk.nu/blahblah&quot;&gt;http://lnk.nu/blahblah&lt;/a&gt;. This means that I&apos;ll have to have some other, non-Google server respond to a &lt;a href=&quot;http://lnk.nu/blahblah&quot;&gt;http://lnk.nu/blahblah&lt;/a&gt; request with a redirect to &lt;a href=&quot;http://a.lnk.nu/blahblah&quot;&gt;http://a.lnk.nu/blahblah&lt;/a&gt;. This adds another level of indirection to the resolution process for a shortened link, which adds another browser round-trip, which might slow the whole experience down no matter how fast GAE hosting ends up being.&lt;br /&gt;&lt;br /&gt;It turns out that Namecheap (my registrar for lnk.nu) offers &quot;URL redirection&quot; where their server will respond to a particular hostname and redirect the browser somewhere else. It can also be configured to retain URL path information, so &lt;a href=&quot;http://lnk.nu/blahblah&quot;&gt;http://lnk.nu/blahblah&lt;/a&gt; would redirect to &lt;a href=&quot;http://a.lnk.nu/blahblah&quot;&gt;http://a.lnk.nu/blahblah&lt;/a&gt;. This would completely take my own server out of the loop, hopefully avoiding any more problems like those last week.</description>
  <comments>http://ghewgill.livejournal.com/137964.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/137632.html</guid>
  <pubDate>Thu, 05 Nov 2009 11:20:51 GMT</pubDate>
  <title>earthquake widget update</title>
  <link>http://ghewgill.livejournal.com/137632.html</link>
  <description>Over the last couple of days, a few people have emailed me about my &lt;a href=&quot;http://hewgill.com/widgets/earthquakes&quot;&gt;Earthquakes Widget&lt;/a&gt; which displays the most recent earthquakes on a small world map on your desktop (it&apos;s a &lt;a href=&quot;http://widgets.yahoo.com/&quot;&gt;Yahoo! Widget&lt;/a&gt;). It seems that it had stopped displaying earthquakes due to an error loading the data file from the earthquake.usgs.gov server.&lt;br /&gt;&lt;br /&gt;It turns out that it was due to an URL change on the usgs.gov server, and the widget framework&apos;s XMLHttpRequest object doesn&apos;t seem to automatically follow the redirect. So I changed the link and it all seems to work again. I sent a new widget to the people who had emailed me to make sure that it solves their problem, and if it&apos;s all okay then I&apos;ll submit it to Yahoo! again (they approve widgets manually, so it pays to make sure it&apos;s right before submitting).&lt;br /&gt;&lt;br /&gt;If you&apos;re looking for the latest version (1.5) before it gets submitted to Yahoo!, see the &lt;a href=&quot;http://hewgill.com/widgets/earthquakes&quot;&gt;Earthquakes Widget&lt;/a&gt; page which has a direct download link.&lt;br /&gt;&lt;br /&gt;I&apos;ve uploaded the &lt;a href=&quot;http://github.com/ghewgill/quake-widget&quot;&gt;quake-widget repository to GitHub&lt;/a&gt;.</description>
  <comments>http://ghewgill.livejournal.com/137632.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/137463.html</guid>
  <pubDate>Wed, 28 Oct 2009 07:51:12 GMT</pubDate>
  <title>mandelbrot set viewer</title>
  <link>http://ghewgill.livejournal.com/137463.html</link>
  <description>A couple of years ago I had the idea to build a &lt;a href=&quot;http://en.wikipedia.org/wiki/Mandelbrot_set&quot;&gt;Mandelbrot set&lt;/a&gt; fractal viewer in the spirit of Google Maps. Google Maps itself has a method to display your own map data by implementing a &quot;tile&quot; server, but it seems specifically oriented toward geographical data and doesn&apos;t have features like arbitrary zoom depth (which you&apos;d clearly want for fractals). I looked around for other similar generic solutions and didn&apos;t find anything at the time.&lt;br /&gt;&lt;br /&gt;Back then, I implemented a drag-scrollable zoomable fractal viewer in Javascript from first principles. This involved doing all the crufty cross-browser compatibility work myself, which was really annoying and very nearly took all the fun out of the project. Recently, after playing with &lt;a href=&quot;http://jquery.com&quot;&gt;jQuery&lt;/a&gt; a bit, I thought it would be good to go back to the fractal viewer and reimplement it using jQuery.&lt;br /&gt;&lt;br /&gt;You can see the results of my efforts at my &lt;a href=&quot;http://hewgill.com/mandelbrot/&quot;&gt;Mandelbrot set viewer&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://hewgill.com/mandelbrot/&quot;&gt;&lt;img src=&quot;http://hewgill.com/~greg/seahorse-valley.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The controls are pretty much what you&apos;d expect. Panning and dragging work as expected (but sometimes you have to wait for the tile server to keep up). The zoom control zooms in 2x for each step, with an effective upper bound limited only by the floating point precision of Javascript. Double-clicking zooms in 2x on a particular point on the plane. The currently-unlabeled button below the zoom control allows you to generate a larger (desktop-sized) snapshot of your current view.&lt;br /&gt;&lt;br /&gt;I was talking to &lt;a href=&quot;http://rancidbacon.com/&quot;&gt;Phil&lt;/a&gt; today who suggested I look at &lt;a href=&quot;http://openlayers.org&quot;&gt;OpenLayers&lt;/a&gt;. Sure enough, in their &lt;a href=&quot;http://gallery.openlayers.org/&quot;&gt;Gallery&lt;/a&gt; there is already a &lt;a href=&quot;http://gis.ibbeck.de/ginfo/ibbOLClient/OLC2.2.html?KARTE=95000&quot;&gt;Fractal Browser&lt;/a&gt; which does almost exactly the work that I&apos;ve already done!&lt;br /&gt;&lt;br /&gt;Once again, somebody out there on the internet has already thought of the same idea. Nevertheless, I&apos;m happy with my viewer (even though it&apos;s not everything I had envisioned yet) and I think I&apos;ll leave it as is and move along to something else. Finally, because this is Open Source Wednesday, you can find the code in &lt;a href=&quot;http://github.com/ghewgill/mandelbrot&quot;&gt;ghewgill/mandelbrot on GitHub&lt;/a&gt;. Enjoy!</description>
  <comments>http://ghewgill.livejournal.com/137463.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/137074.html</guid>
  <pubDate>Sat, 24 Oct 2009 08:39:01 GMT</pubDate>
  <title>skiing around the world</title>
  <link>http://ghewgill.livejournal.com/137074.html</link>
  <description>The ski season in New Zealand runs from Queen&apos;s Birthday (first Monday in June) through to Labour Day (last Monday in October, this weekend). Unfortunately, Amy and I didn&apos;t manage to go skiing at all this season. While we were in Iceland last April, we stopped in &lt;a href=&quot;http://en.wikipedia.org/wiki/Akureyri&quot;&gt;Akureyri&lt;/a&gt; and drove up to the local ski hill on the slopes of &lt;a href=&quot;http://en.wikipedia.org/wiki/Hl%C3%ADðarfjall&quot;&gt;Hlíðarfjall&lt;/a&gt; (which is no more than about 10 minutes drive from town).&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://hewgill.com/photo/trips/islands-world-2009/iceland/IMG_7062.JPG.html&quot;&gt;&lt;img src=&quot;http://hewgill.com/~greg/akureyri-ski-hill.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We had a hot chocolate at the lodge, and seriously considered spending the day skiing. I said at the time that although it would be fun, I wouldn&apos;t be disappointed if we chose not to ski. We decided to press onward (since we only had a limited number of days left) and ended up spending our spare day in &lt;a href=&quot;http://hewgill.local/photo/trips/islands-world-2009/iceland/IMG_7121.JPG.html&quot;&gt;Stykkishólmur&lt;/a&gt; instead.&lt;br /&gt;&lt;br /&gt;However, I now think it would have been awesome to go skiing in Iceland. It was a gorgeous day (see above), not too cold, we had enough time, and Akureyri is a charming little town with an excellent hot pool. And all the red traffic lights in Akureyri are heart-shaped!&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://hewgill.local/photo/trips/islands-world-2009/iceland/IMG_7055.JPG.html&quot;&gt;&lt;img src=&quot;http://hewgill.com/~greg/akureyri-traffic-light.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;At night, you could also see lights across the fjord &lt;a href=&quot;http://en.wikipedia.org/wiki/Eyjafjörður&quot;&gt;Eyjafjörður&lt;/a&gt; that form a huge red heart. We didn&apos;t spend much time there, but I think Akureyri was one of my favourite places in Iceland.</description>
  <comments>http://ghewgill.livejournal.com/137074.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/136867.html</guid>
  <pubDate>Wed, 21 Oct 2009 10:09:39 GMT</pubDate>
  <title>xearth tropical storm overlay</title>
  <link>http://ghewgill.livejournal.com/136867.html</link>
  <description>Two new things for &lt;a href=&quot;http://xearth.org/live&quot;&gt;xearth&lt;/a&gt; this week. First, there is a new overlay for current tropical storm activity. The source data is the &lt;a href=&quot;http://www.solar.ifa.hawaii.edu/Tropical/tropical.html&quot;&gt;Tropical Storms, Worldwide&lt;/a&gt; data set from the University of Hawaii. I wrote a script to download the current tropical storm file (which is a flat ASCII file), some Python code to convert that to an SVG file, and then converted that to a transparent PNG for the overlay.&lt;br /&gt;&lt;br /&gt;The other new thing is xearth now supports &lt;em&gt;multiple&lt;/em&gt; overlay files. Here&apos;s an example showing all map and overlay features (the Living Earth base map, and earthquakes, storms, and clouds overlays).&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=mercator&amp;amp;pos=fixed&amp;amp;pos_lat=0&amp;amp;pos_lon=150&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=3&amp;amp;size_x=512&amp;amp;size_y=512&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;label=on&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=50&amp;amp;term=&amp;amp;ncolors=&amp;amp;mapfile=earth-living.jpg&amp;amp;overlayfile1=quakes.png&amp;amp;overlayfile2=storms.png&amp;amp;overlayfile3=clouds_2048.jpg&amp;amp;overlayfile4=none&amp;amp;overlayfile5=none&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?stars=1&amp;amp;nogrid=1&amp;amp;night=50&amp;amp;pos=fixed,0,150&amp;amp;label=1&amp;amp;noshade=1&amp;amp;proj=mercator&amp;amp;mag=3&amp;amp;nomarkers=1&amp;amp;overlayfile=quakes.png,storms.png,clouds_2048.jpg,none,none&amp;amp;mapfile=earth-living.jpg&amp;amp;size=300,300&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I&apos;m going to improve the presentation of the tropical storm map so the labels are more visible, especially when combined with the cloud overlay (white on white is not an ideal colour combination).</description>
  <comments>http://ghewgill.livejournal.com/136867.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/136695.html</guid>
  <pubDate>Tue, 20 Oct 2009 09:02:06 GMT</pubDate>
  <title>python enhancement proposal</title>
  <link>http://ghewgill.livejournal.com/136695.html</link>
  <description>&lt;p&gt;The other day while writing some code in Python, I had an idea. The bit of code I was writing was shaped something like this:&lt;/p&gt;

&lt;pre&gt;
    for a in results:
        if a.something:
            do_action(a)
&lt;/pre&gt;

&lt;p&gt;It occurred to me that if I were to write this as a list comprehension, then the &quot;if&quot; would combine with the &quot;for&quot; on the same line:&lt;/p&gt;

&lt;pre&gt;
    [do_action(a) for a in results if a.something]
&lt;/pre&gt;

&lt;p&gt;What if I could write this instead:&lt;/p&gt;

&lt;pre&gt;
    for a in results if a.something:
        do_action(a)
&lt;/pre&gt;

&lt;p&gt;This looks like a nice compact syntax for a reasonably common construct, which happens to also be nicely aligned with the list comprehension syntax. I thought I&apos;d have a go at modifying the Python language to accept this, and perhaps even submit a PEP (Python Enhancement Proposal) for the core language.&lt;/p&gt;

&lt;p&gt;I read about the &lt;a href=&quot;http://www.python.org/dev/peps/pep-0001/&quot;&gt;PEP process&lt;/a&gt;, found a &lt;a href=&quot;http://www.python.org/dev/peps/pep-3142/&quot;&gt;related PEP to enhance the generator syntax&lt;/a&gt; (from 2009), which led me to a &lt;a href=&quot;http://thread.gmane.org/gmane.comp.python.devel/99983&quot;&gt;long thread discussing that PEP&lt;/a&gt;, from which I found &lt;a href=&quot;http://mail.python.org/pipermail/python-dev/2008-October/082831.html&quot;&gt;a discussion about an &quot;if-syntax for regular for-loops&quot;&lt;/a&gt; (from 2008), and finally &lt;a href=&quot;http://mail.python.org/pipermail/python-dev/2006-May/065090.html&quot;&gt;Guido&apos;s opinion on the matter&lt;/a&gt; (from 2006), which states that he doesn&apos;t like it &lt;em&gt;and&lt;/em&gt; that it was proposed and rejected before. And as it turns out, after all that I agree with Guido.&lt;/p&gt;

&lt;p&gt;Lessons learned (none the hard way!):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ideas you think are new probably aren&apos;t.&lt;/li&gt;
&lt;li&gt;Do research before committing too much time or energy to a new idea.&lt;/li&gt;
&lt;li&gt;Open development processes are great because there is a permanent record of what has been discussed before.&lt;/li&gt;
&lt;/ul&gt;</description>
  <comments>http://ghewgill.livejournal.com/136695.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>5</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/136236.html</guid>
  <pubDate>Wed, 14 Oct 2009 11:15:05 GMT</pubDate>
  <title>svg adventures (and earthquakes)</title>
  <link>http://ghewgill.livejournal.com/136236.html</link>
  <description>Well, that was thoroughly frustrating. I wanted to render an SVG file to a PNG file (I&apos;ll get to why in a moment). So I did a quick search and found &lt;a href=&quot;http://librsvg.sourceforge.net/&quot;&gt;librsvg&lt;/a&gt; that includes a handy command-line program called &lt;tt&gt;rsvg&lt;/tt&gt; that does exactly what I want. I seem to have already installed it on my laptop, and confirmed that it was what I needed. I then proceeded to install it on my FreeBSD server, so I installed &lt;tt&gt;graphics/librsvg&lt;/tt&gt; from the Ports system. It turns out that the build pulled in a zillion Gnome-related libraries, so the build took quite a while. It installed ... but no &lt;tt&gt;rsvg&lt;/tt&gt; command. It turns out that was the &lt;em&gt;old&lt;/em&gt; version of the library. So I thought I&apos;d update my Ports system to the latest version, but archived a copy of the previous one to save. While I was updating, I noticed it updated a library called &lt;tt&gt;librsvg2&lt;/tt&gt;, which sounded promising. So I went to install that, but it complained that some dependent library was out of date and I was a bit hesitant to just update my whole system to the latest version of everything. So I reverted back to the previous Ports system I had installed (remember that backup I cleverly made?) and tried to install &lt;tt&gt;librsvg2&lt;/tt&gt;. After a couple of hours of building &lt;em&gt;more&lt;/em&gt; Gnome dependencies (why does an SVG renderer need audio libraries? or an object request broker?) somebody said &quot;hey, why not just use the &lt;a href=&quot;http://imagemagick.org&quot;&gt;ImageMagick&lt;/a&gt; convert program?&quot; I thought ImageMagick only handled raster graphics, but it turns out I was wrong. ImageMagick happily renders SVG files into PNG in exactly the form I wanted. Augh!&lt;br /&gt;&lt;br /&gt;Now my server (which is sort of low on disk space already) had a ton more useless crap installed that I don&apos;t need and don&apos;t really know what can be safely removed.&lt;br /&gt;&lt;br /&gt;Anyway, on to the interesting part. Xearth for Windows has an &quot;earthquake&quot; feature where recent earthquakes are displayed as yellow circles on the earth image, with a size proportional to the magnitude of the earthquake. It was a fairly quick and dirty implementation because it just draws a circle on the screen without regard to the map projection at all. With the new overlay support in xearth, I thought a good way to implement earthquakes would be to render the earthquake circles onto a mostly-transparent PNG file, and then overlay that over the map image. Here&apos;s what you get:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=orthographic&amp;amp;pos=fixed&amp;amp;pos_lat=0&amp;amp;pos_lon=180&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=1&amp;amp;size_x=512&amp;amp;size_y=512&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=&amp;amp;term=&amp;amp;ncolors=&amp;amp;overlayfile=none&amp;amp;cloudfile=quakes.png&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?stars=1&amp;amp;nogrid=1&amp;amp;nolabel=1&amp;amp;pos=fixed,0,180&amp;amp;noshade=1&amp;amp;cloudfile=quakes.png&amp;amp;proj=orthographic&amp;amp;mag=1&amp;amp;nomarkers=1&amp;amp;overlayfile=none&amp;amp;size=300,300&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If there are any earthquakes visible (there ought to be), they will appear as yellow circles. This is done by downloading the current earthquake list (magnitude 5 or greater) from the USGS, using XSLT to transform it into SVG, then converting it to PNG for use by xearth. The earthquake list is updated once an hour.</description>
  <comments>http://ghewgill.livejournal.com/136236.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/135999.html</guid>
  <pubDate>Sat, 10 Oct 2009 23:40:51 GMT</pubDate>
  <title>cherries</title>
  <link>http://ghewgill.livejournal.com/135999.html</link>
  <description>&lt;div style=&quot;float: right&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3998800127/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2464/3998800127_3966e0a160_m.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Well, not &lt;em&gt;yet&lt;/em&gt; cherries. About a month ago, we bought a dwarf cherry tree for our front yard. It was essentially just a stick with roots at the time, not looking much like a tree at all. But we planted it and fed it, and it seems to be quite happy. Just in the last week or two, it has sprouted a full complement of leaves and is looking resplendent in its foliage!&lt;/p&gt;

&lt;p&gt;Apparently these trees start producing fruit after about three years.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/135999.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/135887.html</guid>
  <pubDate>Fri, 09 Oct 2009 06:43:11 GMT</pubDate>
  <title>christchurch bus system changes</title>
  <link>http://ghewgill.livejournal.com/135887.html</link>
  <description>Just this morning, I was thinking how nice it was that the number 17 bus, which is the fastest one from the city centre to work, just happens to go right by my house which is nearly on the other side of town. I can leave the house at a predictable time, walk two minutes to the bus stop, get on, and not worry about having to change buses until I get off at the stop five minutes walk away from work.&lt;br /&gt;&lt;br /&gt;I happened to check the &lt;a href=&quot;http://metroinfo.org.nz&quot;&gt;local bus info&lt;/a&gt; web site this afternoon, and found an announcement of some changing schedules. Fine, I thought, they do that from time to time. But this time &lt;em&gt;everything&lt;/em&gt; has changed: New routes, deleted routes, changed schedules, changed route names and numbers. Just when I was starting to learn the system pretty well!&lt;br /&gt;&lt;br /&gt;Ultimately this change is a good thing because they seem to have improved most schedules to 20 minutes between buses (was 30). I&apos;ll have to see how the new schedule works out with having to change buses to get to work.&lt;br /&gt;&lt;br /&gt;But most days I still ride my bike anyway, unless the weather is unseasonably cold and rainy like today!</description>
  <comments>http://ghewgill.livejournal.com/135887.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/135614.html</guid>
  <pubDate>Thu, 08 Oct 2009 10:02:04 GMT</pubDate>
  <title>is spamassassin still state of the art?</title>
  <link>http://ghewgill.livejournal.com/135614.html</link>
  <description>What is the state of the art in (open source) antispam content filtering software? Is &lt;a href=&quot;http://spamassassin.apache.org/&quot;&gt;SpamAssassin&lt;/a&gt; still it? There hasn&apos;t been a new SpamAssassin release at all in over a year, and the last major release was nearly 2.5 years ago.&lt;br /&gt;&lt;br /&gt;I&apos;m not terribly happy with the performance of SpamAssassin these days (it blocks a lot of spam, but an annoying amount still slips through, 5-10 per day) and am wondering whether there is anything better out there now.&lt;br /&gt;&lt;br /&gt;I&apos;ve read briefly about &lt;a href=&quot;http://www.nuclearelephant.com/&quot;&gt;Dspam&lt;/a&gt;, but don&apos;t know much about it yet, has anybody used that?&lt;br /&gt;&lt;br /&gt;Note that I use SpamAssassin as a MUA delivery content filter (through procmail), and have all the usual MTA-based antispam knobs turned up to 11 in Postfix.</description>
  <comments>http://ghewgill.livejournal.com/135614.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>4</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/135410.html</guid>
  <pubDate>Wed, 07 Oct 2009 08:34:30 GMT</pubDate>
  <title>cloud overlay in xearth</title>
  <link>http://ghewgill.livejournal.com/135410.html</link>
  <description>The Xplanet project provides a nice &lt;a href=&quot;http://xplanet.sourceforge.net/maps.php&quot;&gt;cloud map&lt;/a&gt; which is updated every 3 hours and provides a worldwide view of the current cloud cover. I&apos;ve added support to xearth for rendering the cloud map as an alpha-blended overlay over any other xearth map. Here&apos;s what it looks like in a worldwide context:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=mercator&amp;amp;pos=fixed&amp;amp;pos_lat=0&amp;amp;pos_lon=0&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=1&amp;amp;size_x=400&amp;amp;size_y=250&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=&amp;amp;term=&amp;amp;ncolors=&amp;amp;overlayfile=none&amp;amp;cloudfile=clouds_2048.jpg&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?stars=1&amp;amp;nogrid=1&amp;amp;nolabel=1&amp;amp;pos=fixed,0,0&amp;amp;noshade=1&amp;amp;cloudfile=clouds_2048.jpg&amp;amp;proj=mercator&amp;amp;mag=1&amp;amp;nomarkers=1&amp;amp;overlayfile=none&amp;amp;size=400,250&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can see how it enhances an existing image with this side-by-side comparison:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=orthographic&amp;amp;pos=sunrel&amp;amp;pos_lat=&amp;amp;pos_lon=&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=1&amp;amp;size_x=500&amp;amp;size_y=500&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;shade=on&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=&amp;amp;term=&amp;amp;ncolors=&amp;amp;overlayfile=earth-living.jpg&amp;amp;cloudfile=none&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?mag=1&amp;amp;nogrid=1&amp;amp;nolabel=1&amp;amp;pos=sunrel,,&amp;amp;stars=1&amp;amp;cloudfile=none&amp;amp;proj=orthographic&amp;amp;shade=1&amp;amp;nomarkers=1&amp;amp;overlayfile=earth-living.jpg&amp;amp;size=200,200&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=orthographic&amp;amp;pos=sunrel&amp;amp;pos_lat=&amp;amp;pos_lon=&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=1&amp;amp;size_x=500&amp;amp;size_y=500&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;shade=on&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=&amp;amp;term=&amp;amp;ncolors=&amp;amp;overlayfile=earth-living.jpg&amp;amp;cloudfile=clouds_2048.jpg&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?mag=1&amp;amp;nogrid=1&amp;amp;nolabel=1&amp;amp;pos=sunrel,,&amp;amp;stars=1&amp;amp;cloudfile=clouds_2048.jpg&amp;amp;proj=orthographic&amp;amp;shade=1&amp;amp;nomarkers=1&amp;amp;overlayfile=earth-living.jpg&amp;amp;size=200,200&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Finally, by tweaking the display parameters a bit you can view more localised cloud cover:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://xearth.org/live?nodef=on&amp;amp;proj=orthographic&amp;amp;pos=fixed&amp;amp;pos_lat=-40&amp;amp;pos_lon=170&amp;amp;rot=&amp;amp;sunpos_lat=&amp;amp;sunpos_lon=&amp;amp;mag=2&amp;amp;size_x=500&amp;amp;size_y=500&amp;amp;shift_x=&amp;amp;shift_y=&amp;amp;labelpos_x=&amp;amp;labelpos_y=&amp;amp;stars=on&amp;amp;starfreq=&amp;amp;bigstars=&amp;amp;grid1=&amp;amp;grid2=&amp;amp;day=&amp;amp;night=20&amp;amp;term=20&amp;amp;ncolors=&amp;amp;overlayfile=none&amp;amp;cloudfile=clouds_2048.jpg&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?term=20&amp;amp;stars=1&amp;amp;nogrid=1&amp;amp;nolabel=1&amp;amp;night=20&amp;amp;pos=fixed,-40,170&amp;amp;noshade=1&amp;amp;cloudfile=clouds_2048.jpg&amp;amp;proj=orthographic&amp;amp;mag=2&amp;amp;nomarkers=1&amp;amp;overlayfile=none&amp;amp;size=200,200&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The next big step for xearth is to merge my &lt;a href=&quot;http://hewgill.com/xearth/&quot;&gt;xearth for Windows&lt;/a&gt; code into the main code base. This will displace the X drawing code from being the default GUI for xearth, and put them both on an equal footing. Naturally, other platform ports will then follow. (But I probably won&apos;t have that done by next week!)</description>
  <comments>http://ghewgill.livejournal.com/135410.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/135076.html</guid>
  <pubDate>Wed, 30 Sep 2009 11:02:07 GMT</pubDate>
  <title>xearth interactive page</title>
  <link>http://ghewgill.livejournal.com/135076.html</link>
  <description>&lt;p&gt;Just a bit of work on xearth this week. I&apos;ve made an &lt;a href=&quot;http://xearth.org/live&quot;&gt;interactive page&lt;/a&gt; where you can experiment with different xearth options including the new &quot;overlay&quot; feature.&lt;/p&gt;

&lt;p style=&quot;align: center&quot;&gt;&lt;a href=&quot;http://xearth.org/live&quot;&gt;&lt;img src=&quot;http://xearth.org/xearth?size=200,200&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image shows the current position of the earth as viewed from the sun.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/135076.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/134747.html</guid>
  <pubDate>Thu, 24 Sep 2009 19:14:15 GMT</pubDate>
  <title>travel photo slideshows</title>
  <link>http://ghewgill.livejournal.com/134747.html</link>
  <description>&lt;p&gt;Amy has been doing some great work collecting our best travel photos into video slideshows. Here are the two she&apos;s done so far plus some related videos:&lt;/p&gt;

&lt;dl&gt;
&lt;dt&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=uG2eM-7rJro&quot;&gt;Islands of the World Tour 2009&lt;/a&gt;
&lt;dd&gt;Our 6-week trip to Canada, Texas, Frankfurt, Ireland, Iceland, London, and Tokyo earlier this year.

&lt;dt&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=KblUFXiqzAk&quot;&gt;Tossing snow into an ice vent in Iceland&lt;/a&gt;
&lt;dd&gt;This very short video shows how snow melts immediately with a &quot;poof&quot; when you toss it onto a steam vent.

&lt;dt&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=2nfQGyiRn9o&quot;&gt;Otago Rail Trail December 2008&lt;/a&gt;
&lt;dd&gt;Last Christmas we cycled the Otago Rail Trail, roughly 150 km over what was previously a railway line.

&lt;dt&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=qMz3gjl9x-M&quot;&gt;Daniel Tammet - The Boy With The Incredible Brain&lt;/a&gt;
&lt;dd&gt;Finally, in related nows: This TV clip shows a guy who learned Icelandic in a week, from scratch, and then appeared on national TV.
&lt;/dl&gt;&lt;/dt&gt;&lt;/dt&gt;&lt;/dt&gt;&lt;/dt&gt;&lt;/dd&gt;&lt;/dd&gt;&lt;/dd&gt;&lt;/dd&gt;</description>
  <comments>http://ghewgill.livejournal.com/134747.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/134433.html</guid>
  <pubDate>Wed, 23 Sep 2009 11:12:23 GMT</pubDate>
  <title>xearth bmp output, true colour, and fonts</title>
  <link>http://ghewgill.livejournal.com/134433.html</link>
  <description>Xearth has long had the ability to draw markers and labels on the image when it draws in a &quot;live&quot; context, that is in a GUI like X. However, it uses the native text drawing and font support to do this, so it never allowed the &lt;tt&gt;-label&lt;/tt&gt; option when drawing to a bitmap file.&lt;br /&gt;&lt;br /&gt;I hacked support for labels into the Windows port a long time ago, using the Windows GDI support to draw text onto an in-memory device context. While this worked for bitmap files, it wasn&apos;t very flexible and was done at the wrong layer.&lt;br /&gt;&lt;br /&gt;I have just added support for drawing text to the base xearth code. This uses an in-memory representation of a bitmap font, and draws the text before the output functions even run. The text output works for all kinds of image file output now.&lt;br /&gt;&lt;br /&gt;While I was looking for a description of the internals of Windows &lt;tt&gt;.fon&lt;/tt&gt; files (which are a convenient source of bitmap fonts), I came across &lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/fonts/&quot;&gt;Simon Tatham&apos;s Fonts Page&lt;/a&gt; which has some utilities for reading and writing FON files. Not only was there code to read FON files, but there was a public domain version of the X &quot;fixed&quot; 6x13 font which is a handy default font to use in xearth.&lt;br /&gt;&lt;br /&gt;As an aside, Simon Tatham is the author of the popular &lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/putty/&quot;&gt;PuTTY&lt;/a&gt; terminal program, but also has some other cool stuff on his site. A really slick collection of puzzle games is his &lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/puzzles/&quot;&gt;Portable Puzzle Collection&lt;/a&gt;, which are written in C for GTK, Windows, or OS X but with some clever wizardry can also run as Java applets. &lt;br /&gt;&lt;br /&gt;Anyway, another thing I added to xearth this week was BMP output file support. This is done without reference to the actual Windows header files, so that xearth on any platform can create BMP output files. I&apos;ll need this when I finally merge in the Windows port code.&lt;br /&gt;&lt;br /&gt;Finally, I added a &lt;tt&gt;-ncolors true&lt;/tt&gt; option that enables 24-bit colour output for PNG and BMP files (GIF files are limited to 256 colours, and JPEG files are always true colour). Using the &lt;tt&gt;-overlayfile&lt;/tt&gt; option automatically enables true colour output, because no assumptions are made about the colour palette of the overlay file. This implies that &lt;tt&gt;-gif&lt;/tt&gt; cannot be combined with &lt;tt&gt;-overlayfile&lt;/tt&gt;, but that&apos;s an inconsequential limitation.&lt;br /&gt;&lt;br /&gt;As always, you can find the latest xearth code in &lt;a href=&quot;http://github.com/ghewgill/xearth/&quot;&gt;xearth on Github&lt;/a&gt;.</description>
  <comments>http://ghewgill.livejournal.com/134433.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/134390.html</guid>
  <pubDate>Sat, 19 Sep 2009 13:25:08 GMT</pubDate>
  <title>the general public on twitter</title>
  <link>http://ghewgill.livejournal.com/134390.html</link>
  <description>&lt;p&gt;I was chatting with &lt;a href=&quot;http://rancidbacon.com/&quot;&gt;Phil&lt;/a&gt; the other day and he was working on some statistical analysis tools for the Twitter API. I was reminded of a little project that had popped into my head a while ago: How hard would it be to identify the language in which a twitter status update is written? With only 140 characters, some of which are going to be a URL or something, there won&apos;t be much info there. Is it possible?&lt;/p&gt;

&lt;p&gt;The Twitter API provides a method to get the most recent 20 updates from the general public on twitter. You can see this &lt;a href=&quot;http://twitter.com/statuses/public_timeline.html&quot;&gt;public timeline&lt;/a&gt; in your browser as well as getting it via XML or JSON or whatever. I took one look at that page and was immediately struck by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the wide range of languages represented (I imagine this varies by time of day)
&lt;li&gt;the high frequency of spelling errors, both active (because of the 140 character limit) and passive (because people can&apos;t or won&apos;t spell properly)
&lt;li&gt;the wide range of &quot;words&quot; used that simply aren&apos;t in any dictionary (mmmmm, XD, arrr, dat) (well, &quot;arrr&quot; is permissible because it&apos;s &lt;a href=&quot;http://en.wikipedia.org/wiki/International_Talk_Like_a_Pirate_Day&quot;&gt;International Talk Like A Pirate Day&lt;/a&gt; today, of course)
&lt;li&gt;the low information content of most of the crap people post on twitter
&lt;li&gt;the (attempted) spam (who would actually read or click on your gratuitous message about affiliate marketing?)
&lt;/ul&gt;

&lt;p&gt;I was disheartened by what I saw, ready to give up on the project. Here&apos;s a typical gem:&lt;/p&gt;

&lt;blockquote&gt;ne1 der.....2 b frndz wid me..&lt;/blockquote&gt;

&lt;p&gt;But you know what? Regardless of whether any of this could be considered correct, literate, crap, spam, or what have you, it&apos;s what people are &lt;em&gt;actually&lt;/em&gt; writing. It&apos;s (mostly) human communication, even if it has a low information content. Doesn&apos;t it deserve analysis anyway? Real world problems are almost never the easy ones.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/134390.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/133935.html</guid>
  <pubDate>Wed, 16 Sep 2009 19:38:41 GMT</pubDate>
  <title>on learning programming</title>
  <link>http://ghewgill.livejournal.com/133935.html</link>
  <description>&lt;p&gt;I didn&apos;t get as much done on &lt;a href=&quot;http://xearth.org&quot;&gt;xearth&lt;/a&gt; today as I had planned to. Instead, I got involved in a long conversation at &lt;a href=&quot;http://chchspace.nztech.org/&quot;&gt;chchspace&lt;/a&gt; about programming languages, which migrated toward a discussion about a way to introduce programming to young people. For example:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;class Hello {
    public static void main(String[] args) {
        System.out.println(&quot;Hello, world&quot;);
    }
}
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;is a lot more crap to have to explain (just how long does it take to explain away &quot;public static void main&quot;?) than:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;print &quot;Hello, world&quot;
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;But even then, &quot;Hello, world&quot; is a major let-down as far as a first program goes. &lt;em&gt;My&lt;/em&gt; first ever program was a graphics program: It drew a diagonal line from the top left to the bottom right of an Apple ][+ high-res graphics screen. Printing text came later, on an as-needed basis (probably when I first needed to debug something). I think it&apos;s important to introduce programming using a medium that&apos;s more malleable than plain old ASCII text.&lt;/p&gt;

&lt;p&gt;Text is symbolic. By itself, it rarely &lt;em&gt;looks&lt;/em&gt; interesting, but it&apos;s a &lt;em&gt;representation&lt;/em&gt; of something interesting (maybe). It requires a bunch of cognitive processing to go from the letters on the screen, to ideas that are meaningful. When you&apos;re learning a new method of expression such as programming, having to apply this extra cognitive load to everything you do (that is, having to read and understand the program output) detracts from the learning process. Young children learn to draw pictures before learning to write words; even &lt;a href=&quot;http://en.wikipedia.org/wiki/Koko_(gorilla)&quot;&gt;Koko&lt;/a&gt; can &lt;a href=&quot;http://www.koko.org/world/art.html&quot;&gt;draw pictures&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What&apos;s the right answer? Is it &lt;a href=&quot;http://en.wikipedia.org/wiki/Logo_(programming_language)&quot;&gt;Logo&lt;/a&gt;? Maybe they were on to something in 1967. Is it Adobe Flex? Silverlight? Yahoo! Widgets? I believe it&apos;s likely to be something like that. It is definitely not &quot;public static void main&quot;.&lt;/p&gt;</description>
  <comments>http://ghewgill.livejournal.com/133935.html</comments>
  <category>osw</category>
  <lj:security>public</lj:security>
  <lj:reply-count>7</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://ghewgill.livejournal.com/133605.html</guid>
  <pubDate>Thu, 10 Sep 2009 10:25:52 GMT</pubDate>
  <title>the essence of the port hills</title>
  <link>http://ghewgill.livejournal.com/133605.html</link>
  <description>Last weekend I went for a walk up the Port Hills south of Christchurch. I cycled to the top of the road in Bowenvale Valley, then walked up the Hidden Valley track to the Crater Rim walkway, west across to the car park with a view of Governor&apos;s Bay, then back down Bowenvale Valley. It was a gorgeous spring day and the fruit trees were in full blossom. Here are some photos:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891934138/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2473/3891934138_32610b0c55_m.jpg&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891161635/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2575/3891161635_b024365706_m.jpg&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891956940/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2487/3891956940_dfce5c87a9_m.jpg&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891179723/&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3534/3891179723_d7d7a2c24d_m.jpg&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891973140/&quot;&gt;&lt;img src=&quot;http://farm4.static.flickr.com/3073/3891973140_53481870b7_m.jpg&quot;&gt;&lt;/a&gt; &lt;a href=&quot;http://www.flickr.com/photos/ghewgill/3891193567/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2674/3891193567_db1c5a7265_m.jpg&quot;&gt;&lt;/a&gt;</description>
  <comments>http://ghewgill.livejournal.com/133605.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
