<?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>Dave&#039;s Programming Blog</title>
	<atom:link href="http://dev.mcleish.id.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.mcleish.id.au</link>
	<description>The Church of Alan Turing of Latter-Day Sorcerers</description>
	<lastBuildDate>Mon, 12 Jul 2010 09:02:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Heap</title>
		<link>http://dev.mcleish.id.au/2010/07/heap/</link>
		<comments>http://dev.mcleish.id.au/2010/07/heap/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 09:02:54 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=68</guid>
		<description><![CDATA[Haven&#8217;t been blogging much because we&#8217;ve just moved, and before that we were on our honeymoon, and before that we were getting married, and before that we were planning a wedding and a honeymoon, all of which was a bit of a time sink. As a result I haven&#8217;t done much programming, apart from work, [...]]]></description>
			<content:encoded><![CDATA[<p>Haven&#8217;t been blogging much because we&#8217;ve just moved, and before that we were on our honeymoon, and before that we were getting married, and before that we were planning a wedding and a honeymoon, all of which was a bit of a time sink. As a result I haven&#8217;t done much programming, apart from work, which as usual I can&#8217;t talk about.</p>
<p>Although, today I implemented a heap from scratch in C for the first time in a while. It was therapeutic, somehow, to be doing low-level algorithmic stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/07/heap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vye Mini-v S37</title>
		<link>http://dev.mcleish.id.au/2010/02/vye-mini-v-s37/</link>
		<comments>http://dev.mcleish.id.au/2010/02/vye-mini-v-s37/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 06:02:31 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=60</guid>
		<description><![CDATA[So my Vye S37 just arrived. It came with Vista on it; I booted it once (actually about three times, after it did all its setup-reboot-repeat shenanigans&#8230; sheesh) to check that it worked, then booted Ubuntu 9.10 Netbook Remix from a USB drive.
Here&#8217;s a list of what works in UNR out of the box:

Everything.

Okay, technically [...]]]></description>
			<content:encoded><![CDATA[<p>So my <a href="http://dev.mcleish.id.au/2010/02/ipad-substitute/">Vye S37</a> just arrived. It came with Vista on it; I booted it once (actually about three times, after it did all its setup-reboot-repeat shenanigans&#8230; <em>sheesh</em>) to check that it worked, then booted <a href="http://www.canonical.com/projects/ubuntu/unr">Ubuntu 9.10 Netbook Remix</a> from a USB drive.</p>
<p>Here&#8217;s a list of what works in UNR out of the box:</p>
<ul>
<li>Everything.</li>
</ul>
<p>Okay, technically I don&#8217;t know that <em>everything</em> works &#8211; I haven&#8217;t tried Bluetooth or the card reader or most of the buttons on the display (in fact I suspect that at least the screen rotation button will need some custom fiddling), but the two main things that other people seemed to have trouble with in older versions of Ubuntu &#8211; WiFi and the touchscreen &#8211; work beautifully. Well, I haven&#8217;t tried to <em>use</em> WiFi yet, &#8217;cause all the routers around me are locked, but it can see them.</p>
<p>I am well pleased. I&#8217;ll post some thoughts on UNR after I&#8217;ve played with it for a while.</p>
<p>Ah&#8230; Just noticed that the touchscreen doesn&#8217;t quite go to the edge of the screen. I can live with that. If that&#8217;s what everyone else is complaining about then, frankly, what a bunch of whingers.</p>
<p><strong>Edit:</strong> Oh, I see, <em>menus</em> and whatnot are at the edge of the screen, which makes the touchscreen thing important. Well, I found the touchscreen maker&#8217;s site the other day and they seemed to have well-maintained Linux drivers (there&#8217;s an installer for the last several Ubuntu versions, including 9.10), so I&#8217;ll see what can be done about it later.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/02/vye-mini-v-s37/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPad Substitute</title>
		<link>http://dev.mcleish.id.au/2010/02/ipad-substitute/</link>
		<comments>http://dev.mcleish.id.au/2010/02/ipad-substitute/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 02:06:23 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=49</guid>
		<description><![CDATA[I seem to have developed a pattern of buying alternatives to Apple&#8217;s flagship products.
Instead of getting an iPod, I bought an iriver. Part of the rationale was that it supported Ogg Vorbis. It also turned out to be chunky and awful and churn through AA batteries, but meh.
I deliberated for a while about getting an [...]]]></description>
			<content:encoded><![CDATA[<p>I seem to have developed a pattern of buying alternatives to Apple&#8217;s flagship products.</p>
<p>Instead of getting an iPod, I bought an <a href="http://www.iriver.com.au/iriver/">iriver</a>. Part of the rationale was that it supported <a href="http://en.wikipedia.org/wiki/Vorbis">Ogg Vorbis</a>. It also turned out to be chunky and awful and churn through AA batteries, but meh.</p>
<p>I deliberated for a while about getting an iPhone, but on the verge of making the decision there was some controversy or other about the app store, which pushed me over the line to go for the Android-powered <a href="http://www.htc.com/www/product/hero/overview.html">HTC Hero</a> instead. The idea of an open platform for app development appealed to me enormously. So far I haven&#8217;t actually <em>done</em> any of said development, but it&#8217;s nice to know that I <em>could</em> in theory.</p>
<p>I don&#8217;t actually have a problem with Apple, and in fact I think their focus on a simple, seamless UI is something that should be imitated far more often. But being a geek, I actually like something with a few visible seams, because they can be picked apart. Like <a href="http://www.escapistmagazine.com/articles/view/comics/stolen-pixels/7112-Stolen-Pixels-165-The-Next-Big-Thing-from-Apple">Shamus</a>, I&#8217;m not really their target market.</p>
<p>Anyway, less than a week after the iPad announcement, I find myself having bought a <a href="http://www.vyeaus.com/products/view/2">Vye Mini-v S37</a> at auction. Notionally the idea is to have something small and light to travel with, especially on our honeymoon in May &#8211; an argument supported by its the fact that it has a CF card reader, will let me dump photos onto it. But really I just thought it was cool. Obviously I&#8217;m planning to put Linux on it (probably Xubuntu)&#8230; although I can&#8217;t find anywhere that explicitly says that someone&#8217;s tried that and everything works, which means that it could be&#8230; interesting. It&#8217;ll be disappointing if I&#8217;m stuck with Vista.</p>
<p>So the relevance of this to a blog about software and stuff (other than the fact that I&#8217;ve been otherwise occupied with work and wedding plans and the box set of Buffy and am struggling a bit to find something to write to break the silence) is that I&#8217;ll be posting some updates on how Linux holds up in the tablet-netbook-thing niche.</p>
<p><strong>Update:</strong> Apparently the Vye S37 is also sold as the <a href="http://kohjinsha.blogspot.com/">Kohjinsha SH8</a>. That link is to a blog describing an attempt to get Ubuntu 7.10 working on said Kohjinsha (and I thought <em>this</em> blog was too topic-specific <img src='http://dev.mcleish.id.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). So it looks like the problems, if I have them, will be WiFi and the touch screen&#8230; although I&#8217;m also quite optimistic about Ubuntu&#8217;s progress over the intervening two years.</p>
<p><strong>Update 2:</strong> The Ralink RT73 WiFi adapter allegedly <a href="https://help.ubuntu.com/community/WifiDocs/Driver/RalinkRT73">works out of the box in 9.10</a>. Should be okay on that front.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/02/ipad-substitute/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>n-queens Mexican Standoff</title>
		<link>http://dev.mcleish.id.au/2010/01/n-queens-mexican-standoff/</link>
		<comments>http://dev.mcleish.id.au/2010/01/n-queens-mexican-standoff/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 06:03:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Random experiments]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=41</guid>
		<description><![CDATA[The first day back at work has proved fruitful in the form of someone coming up with the opposite of the traditional n-queens problem: the n-queens Mexican standoff. Instead of minimising the number of mutually attacking queens (to zero), the objective of the standoff version is to maximise the number of attacks.
We haven&#8217;t done an [...]]]></description>
			<content:encoded><![CDATA[<p>The first day back at work has proved fruitful in the form of someone coming up with the opposite of the traditional <a href="http://en.wikipedia.org/wiki/N_queens"><em>n</em>-queens</a> problem: the <em>n</em>-queens Mexican standoff. Instead of minimising the number of mutually attacking queens (to zero), the objective of the standoff version is to <em>maximise</em> the number of attacks.</p>
<p>We haven&#8217;t done an exhaustive search yet, but I&#8217;ve been running a simulated-annealing-ish script for a while, and it looks like the most attacks is 34 (17 pairs of mutual attacks), in two configurations:</p>
<blockquote>
<pre>QQ.    .QQ.
QQQ or QQQQ
QQQ    .QQ.
</pre>
</blockquote>
<p>&#8230;either of which can be expanded by adding gaps between the queens, or rotating by multiples of 45 degrees.</p>
<blockquote>
<pre>Q.Q..   .Q.Q.   Q...Q..
.....   Q.Q.Q   .......
Q.Q.Q   .Q.Q.   ..Q...Q
.....   ..Q..   .......
Q.Q.Q           Q...Q..
                .......
                ..Q...Q</pre>
</blockquote>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 201px; width: 1px; height: 1px;">
<pre>Q...Q...</pre>
</div>
<p><strong>Update:</strong> Python code below the fold.</p>
<p><span id="more-41"></span></p>
<blockquote>
<pre>import random
from numpy import array, exp

def print_board((n, queens, board)):
    for row in board:
        for val in row:
            print ('.','#')[val],
        print

def new_board(n=8):
    board = array([[False] * n for i in range(n)])
    queens = []
    while len(queens) < n:
        x = random.randint(0, n-1)
        y = random.randint(0, n-1)
        if not (x,y) in queens:
            queens.append((x, y))
            board[x,y] = True
    return (n, queens, board)

def eval_attack((n, queens, board)):
    attacks = 0
    for (x,y) in queens:
        for (dx,dy) in ((-1,-1),(-1,0),(-1,1),
                        (0,-1),(0,1),
                        (1,-1),(1,0),(1,1)):
            (cx, cy) = (x, y)
            while True:
                cx += dx
                cy += dy
                if cx < 0 or cx >= n or cy < 0 or cy >= n:
                    break
                if board[cx,cy]:
                    attacks += 1
                    break
    return attacks

def move_queen((n, queens, board), q=None, dest=None):
    if q is None:
        q = random.randint(0, n-1)
    if dest is None:
        while True:
            x = random.randint(0, n-1)
            y = random.randint(0, n-1)
            if not board[x,y]:
                dest = (x,y)
                break
    prev = queens[q]
    queens[q] = dest
    board[prev] = False
    board[dest] = True
    return (q, prev)

def find_most_attack(board=None, n=8, temp=2.0, threshold=10000):
    if board is None:
        board = new_board(n)

    best = 0
    meta_best = best
    since_improve = 0
    while True:
        (prev_q, prev_pos) = move_queen(board)
        score = eval_attack(board)
        if score > best:
            best = score
            since_improve = 0
            if best >= meta_best:
                meta_best = best
                print_board(board)
                print score
        else:
            since_improve += 1
            if since_improve > threshold:
                since_improve = 0
                board = new_board(n)
                best = 0
            elif random.random() >= exp((score - best)/temp):
                move_queen(board, prev_q, prev_pos)
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/01/n-queens-mexican-standoff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Year&#8217;s Resolution</title>
		<link>http://dev.mcleish.id.au/2010/01/new-years-resolution/</link>
		<comments>http://dev.mcleish.id.au/2010/01/new-years-resolution/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 05:46:43 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/2010/01/new-years-resolution/</guid>
		<description><![CDATA[This year I intend to learn to use Emacs properly. I&#8217;ve always liked Emacs in principle but never really been able to remember the arcane command sequences to do anything beyond undo, search/replace, and some basic navigation and file stuff. This is the year to jump down the rabbit hole.
A backup resolution, in case the [...]]]></description>
			<content:encoded><![CDATA[<p>This year I intend to learn to use Emacs properly. I&#8217;ve always liked Emacs in principle but never really been able to remember the arcane command sequences to do anything beyond undo, search/replace, and some basic navigation and file stuff. This is the year to jump down the rabbit hole.</p>
<p>A backup resolution, in case the rabbit hole turns out to stink, is to switch to vi.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/01/new-years-resolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fibonacci music</title>
		<link>http://dev.mcleish.id.au/2010/01/fibonacci-music/</link>
		<comments>http://dev.mcleish.id.au/2010/01/fibonacci-music/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 05:13:09 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Random experiments]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=19</guid>
		<description><![CDATA[I spent most of today messing around with music based on the Fibonacci sequence. The result I&#8217;m happiest with has four voices, each using the Fibonacci sequence mod 12 to determine the pitch (in semitones), and using the sequence with other moduli (4, 5, 3 and 2 respectively) to determine the timing.
Fibonacci MIDI (9.8KB)
Fibonacci MP3 [...]]]></description>
			<content:encoded><![CDATA[<p>I spent most of today messing around with music based on the Fibonacci sequence. The result I&#8217;m happiest with has four voices, each using the Fibonacci sequence mod 12 to determine the pitch (in semitones), and using the sequence with other moduli (4, 5, 3 and 2 respectively) to determine the timing.</p>
<p><a href="http://dev.mcleish.id.au/wp-content/uploads/2010/01/fibonacci.midi">Fibonacci MIDI (9.8KB)</a></p>
<p><a href="http://dev.mcleish.id.au/wp-content/uploads/2010/01/fibonacci.mp3">Fibonacci MP3 (3.0MB)</a></p>
<p>It could generously be described as &#8220;atonal crap&#8221;, but it sort of has moments of not-completely-awful-ness. Sort of.</p>
<p>Python code below the fold.</p>
<p><span id="more-19"></span></p>
<p>This produces output that can be included in a <a href="http://lilypond.org/">Lilypond</a> file. For the record: I&#8217;m not actually expecting anyone to actually <em>do</em> this (other than me), I&#8217;m just sort of documenting it for posterity.</p>
<pre>SCALE = ['c','cis','d','dis','e','f','fis',
         'g','gis','a','ais','b']

class Fibonacci:
    def __init__(self, mod, offset=0, coeff=1, a=0, b=1):
        self.mod = mod
        self.offset = offset
        self.coeff = coeff
        self.a = a
        self.b = b

    def next(self):
        val = self.coeff * self.a + self.offset
        (self.a, self.b) = (self.b, (self.a + self.b) % self.mod)
        return val

def note(n):
    suffix = ''
    while n &lt; 0:
        suffix += ','
        n += len(SCALE)
    while n &gt;= len(SCALE):
        suffix += '\''
        n -= len(SCALE)
    return SCALE[n] + suffix

def make_music(n, voices):
    for (rests, note_seq, time_seq) in voices:
        print '{',

        count = rests * 16

        while rests &gt; 0:
            if rests &gt;= 4:
                print 'r1',
                rests -= 4
            elif rests &gt;= 2:
                print 'r2',
                rests -= 2
            elif rests &gt;= 1:
                print 'r4',
                rests -= 1

        while count &lt; n:
            time = 2**time_seq.next()
            print '%s%d' % (note(note_seq.next()), time),
            count += 64 // time
        print '}'

if __name__ == '__main__':
    make_music(9312, [
            (0, Fibonacci(12, 12), Fibonacci(4, 0)),
            (23, Fibonacci(12, 5), Fibonacci(5, 0)),
            (46, Fibonacci(12, 0), Fibonacci(3, 0)),
            (69, Fibonacci(12, -7), Fibonacci(2, 0))
            ])</pre>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/01/fibonacci-music/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://dev.mcleish.id.au/wp-content/uploads/2010/01/fibonacci.midi" length="5079" type="audio/midi" />
<enclosure url="http://dev.mcleish.id.au/wp-content/uploads/2010/01/fibonacci.mp3" length="3153149" type="audio/mpeg" />
		</item>
		<item>
		<title>Zendo and inductive logic</title>
		<link>http://dev.mcleish.id.au/2010/01/zendo-and-inductive-logic/</link>
		<comments>http://dev.mcleish.id.au/2010/01/zendo-and-inductive-logic/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 11:51:22 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Zendo]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=9</guid>
		<description><![CDATA[&#8230;is what I&#8217;m thinking about now. (Okay, technically, are what I&#8217;m thinking about now.)
Don&#8217;t have time for a fully explanatory post right now; I just wanted to get something on here so that the new blog doesn&#8217;t stagnate before it&#8217;s even started. So here&#8217;s a bullet-point-form introduction:

Zendo is a game where players try to guess [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;is what I&#8217;m thinking about now. (Okay, technically, <em>are</em> what I&#8217;m thinking about now.)</p>
<p>Don&#8217;t have time for a fully explanatory post right now; I just wanted to get something on here so that the new blog doesn&#8217;t stagnate before it&#8217;s even started. So here&#8217;s a bullet-point-form introduction:</p>
<ul>
<li><a href="http://www.koryheath.com/games/zendo/">Zendo</a> is a game where players try to guess the Master&#8217;s secret rule by probing it with examples.</li>
<li><a href="http://en.wikipedia.org/wiki/Inductive_reasoning">Inductive logic</a> is&#8230; the same thing, really, except generalised to not necessarily include players, a Master, or&#8230; plastic pyramids.</li>
<li>Doing either of these things algorithmically is, in general, hard. But in an interesting way.</li>
</ul>
<p>Also: colours!</p>
<p style="text-align: center;"><a href="http://dev.mcleish.id.au/wp-content/uploads/2010/01/zendo.jpg"><img class="size-medium wp-image-11 aligncenter" title="Zendo" src="http://dev.mcleish.id.au/wp-content/uploads/2010/01/zendo-300x200.jpg" alt="" width="300" height="200" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2010/01/zendo-and-inductive-logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oh looky, a new blog</title>
		<link>http://dev.mcleish.id.au/2009/12/oh-looky-a-new-blog/</link>
		<comments>http://dev.mcleish.id.au/2009/12/oh-looky-a-new-blog/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 06:10:19 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Meta]]></category>

		<guid isPermaLink="false">http://dev.mcleish.id.au/?p=3</guid>
		<description><![CDATA[&#8216;Cause I wasn&#8217;t neglecting the old one enough already.
This is a bit of an experiment. Until recently I thought the one-person-with-multiple-blogs-for-different-topics thing was a bad case of over-engineering. But I have a new theory that goes like this: none of you should have to read through my random thoughts on gardening and moustache-growth updates on [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;Cause I wasn&#8217;t neglecting <a href="http://blog.dmcleish.id.au/">the old one</a> enough already.</p>
<p>This is a bit of an experiment. Until recently I thought the one-person-with-multiple-blogs-for-different-topics thing was a bad case of over-engineering. But I have a new theory that goes like this: none of you should have to read through my random thoughts on gardening and moustache-growth updates on the slight offchance that I <em>might</em> say something intelligent about computers or whatever. Unless you&#8217;re my stalker, in which case you should probably stop doing that.</p>
<p>So this is an attempt to keep the &#8220;nonsense that only I care about&#8221; stuff separate from the&#8230; well, the &#8220;nonsense that only I care about but is to do with computing&#8221;. It&#8217;s also supposed to motivate me to do something about the dozen or so projects I have on the backburner at any given time. (Hey, it <em>could</em> work. You never know.)</p>
<p>Stay tuned for ramblings on all things programming, software, and computer-science-and-engineering-y.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.mcleish.id.au/2009/12/oh-looky-a-new-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
