<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Alan&#039;s Ramblings - Tech category</title>
  <link>http://bleaklow.com:80/categories/tech/</link>
  <description>My opinions may be incorrect, but they are my own</description>
  <language>en</language>
  <copyright>Alan Burlison</copyright>
  <lastBuildDate>Wed, 23 Nov 2011 16:42:03 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>http://bleaklow.com/images/misc/logo.gif</url>
    <title>Alan&#039;s Ramblings (Tech category)</title>
    <link>http://bleaklow.com:80/</link>
  </image>
  <item>
    <title>Stupid BT router...</title>
    <link>http://bleaklow.com:80/2011/11/23/stupid_bt_router.html</link>
    <description>
          &lt;p&gt;
I have the misfortune to own a BT Business 2Wire router, and bleaklow.com sits behind that.  A while back it threw a fit and reconfigured itself and when I beat it into submission I didn&#039;t notice that it had also lost the port mappings for bleaklow.com.  As a result I&#039;ve been off-air for quite some time.  Bloody BT...
&lt;/p&gt;</description>
      <category>Web</category>
    <category>Tech</category>
    <comments>http://bleaklow.com:80/2011/11/23/stupid_bt_router.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2011/11/23/stupid_bt_router.html</guid>
    <pubDate>Wed, 23 Nov 2011 14:12:00 GMT</pubDate>
  </item>
  <item>
    <title>Hints on creating 256-colour themes for vim</title>
    <link>vim 256 colour</link>
    <description>
          &lt;p&gt;
Most existing &lt;a href=&#034;http://www.vim.org/&#034;&gt;vim&lt;/a&gt; colour themes are designed for the graphical version of vim, gvim.  They don&#039;t work properly at all if you are running vim in a terminal, and there are very few themes available for vim in terminal-mode. You are pretty much obliged to make your own if one of the small number of available ones doesn&#039;t suit.  Here&#039;s a list of hints and tips that I discovered in the process of creating one:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If your shell&#039;s setting for &lt;code&gt;$TERM&lt;/code&gt; is &lt;code&gt;xterm&lt;/code&gt; you won&#039;t get colour support.  It needs to be &lt;code&gt;xtermc&lt;/code&gt; or you need to add a &lt;code&gt;set term=xtermc&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Even with the terminal type set you may not get 256 colours if you are using gnome-terminal.  To fix that, put &lt;code&gt;set t_Co=256&lt;/code&gt; in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In vim, type &lt;code&gt;:help highlight&lt;/code&gt; to get instructions on how to specify colours in vim.&lt;/li&gt;
&lt;li&gt;To make the process of authoring a colour theme easier, install the &lt;a href=&#034;http://www.vim.org/scripts/script.php?script_id=85&#034;&gt;Mkcolorscheme.vim&lt;/a&gt; script in your vim plugin directory, uncommenting the four commands at the top of the file.  Read the instructions in the plugin, they give you hints on how to identify the colours currently being used by syntax elements.&lt;/li&gt;
&lt;li&gt;Open a new subwindow in vim and type &lt;code&gt;:so $VIMRUNTIME/syntax/hitest.vim&lt;/code&gt;.  That will display a table of the current settings, which will be updated as you interactively change colours.&lt;/li&gt;
&lt;li&gt;Open this &lt;a href=&#034;http://upload.wikimedia.org/wikipedia/commons/9/95/Xterm_color_chart.png&#034;&gt;colour chart&lt;/a&gt; in your browser, it gives you the colour numbers you&#039;ll need to set the colours.&lt;/li&gt;
&lt;li&gt;Open up a source file of the type that you want to set the syntax colouring for, put the cursor over an element and use the &lt;code&gt;:GetSyntax&lt;/code&gt; command to identify the element type, followed by the appropriate&lt;code&gt;:highlight&lt;/code&gt; command to set the element colour.&lt;/li&gt;
&lt;li&gt;When you are done, use the &lt;code&gt;:Mkcolorscheme&lt;/code&gt; command to generate a set of commands to generate the colour scheme settings.  Delete any lines containing &lt;code&gt;cleared&lt;/code&gt; as they aren&#039;t valid.&lt;/li&gt;
&lt;li&gt;Save the colour scheme to a file in your vim &lt;code&gt;colors&lt;/code&gt; directory and load the scheme with a &lt;code&gt;colorscheme&lt;/code&gt; command in your &lt;code&gt;.vimrc&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;</description>
      <category>Tech</category>
    <comments>http://bleaklow.com:80/2011/09/21/hints_on_creating_256_colour_themes_for_vim.html#comments</comments>
    <guid isPermaLink="true">vim 256 colour</guid>
    <pubDate>Wed, 21 Sep 2011 20:06:00 GMT</pubDate>
  </item>
  <item>
    <title>Beautiful Scala</title>
    <link>http://bleaklow.com:80/2011/08/23/beautiful_scala.html</link>
    <description>
          &lt;p&gt;
This is, of course, beautiful:
&lt;/p&gt;
&lt;pre&gt;
def msort[T](less: (T, T) =&amp;gt; Boolean)
      (xs: List[T]): List[T] = {
  
    def merge(xs: List[T], ys: List[T]): List[T] =
      (xs, ys) match {
        case (Nil, _) =&amp;gt; ys
        case (_, Nil) =&amp;gt; xs
        case (x :: xs1, y :: ys1) =&amp;gt;
          if (less(x, y)) x :: merge(xs1, ys)
          else y :: merge(xs, ys1)
      }
  
    val n = xs.length / 2
    if (n == 0) xs
    else {
      val (ys, zs) = xs splitAt n
      merge(msort(less)(ys), msort(less)(zs))
    }
  }

scala&amp;gt; val intSort = msort((x: Int, y: Int) =&amp;gt; x &amp;lt; y) _
intSort: (List[Int]) =&amp;gt; List[Int] = &amp;lt;function1&amp;gt;
scala&amp;gt; intSort(List(3, 5, 1, 6, 2))
res3: List[Int] = List(1, 2, 3, 5, 6)
&lt;/pre&gt;
&lt;p&gt;
This is an example of a recursive &lt;a href=&#034;http://en.wikipedia.org/wiki/Merge_sort&#034;&gt;merge sort&lt;/a&gt; implemented using a technique known as &lt;a href=&#034;http://en.wikipedia.org/wiki/Currying&#034;&gt;currying&lt;/a&gt;, expressed in the language &lt;a href=&#034;http://www.scala-lang.org/&#034;&gt;Scala&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Some context:  I was looking for a Java-based scripting language to act as &#039;glue&#039; for my &lt;a href=&#034;http://oziapi-java.sourceforge.net/&#034;&gt;Java interface&lt;/a&gt; to &lt;a href=&#034;http://www.oziexplorer.com/&#034;&gt;OziExplorer&lt;/a&gt; which I&#039;m using for a fenceline survey I&#039;m doing for the &lt;a href=&#034;http://www.moorsforthefuture.org.uk/&#034;&gt;Moors For The Future&lt;/a&gt; project.  I initially looked at &lt;a href=&#034;http://groovy.codehaus.org/&#034;&gt;Groovy&lt;/a&gt; and came across an intriguing comment by James Strachan, the creator of Groovy:
&lt;/p&gt;
&lt;blockquote&gt;
I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon &amp; Bill Venners back in 2003 I&#039;d probably have never created Groovy.
&lt;/blockquote&gt;
&lt;p&gt;
That set me off on an exploration of the &lt;a href=&#034;http://www.scala-lang.org/&#034;&gt;Scala website&lt;/a&gt; which has lots of good tutorials and links, including one to an &lt;a href=&#034;http://www.simplyscala.com/&#034;&gt;online interpreter&lt;/a&gt; you can type examples into.  Scala is a really intriguing language - it sits on top of the JVM so you get &#039;for free&#039; Java&#039;s cross-platform support and access to the huge Java ecosystem, but Scala also blends together the features of some of the most influential languages that preceded it:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &#039;everything is an object&#039; nature of Smalltalk or Ruby&lt;/li&gt;
&lt;li&gt;The imperative nature of languages that have C or Java heritage&lt;/li&gt;
&lt;li&gt;Functional programming as per ML or Haskell&lt;/li&gt;
&lt;li&gt;Strongly typed but with sophisticated type inferencing that makes it look &amp; feel similar to Python or Groovy&lt;/li&gt;
&lt;li&gt;Uniform access to methods and fields, like Eiffel
&lt;li&gt;Actor-based concurrency similar to Erlang&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Scala also adds new features of its own as well, such as abstract types, traits and extractors.  It&#039;s also very easy to write domain-specific languages in Scala.  James Strachan wrote a good &lt;a href=&#034;http://macstrac.blogspot.com/2009/04/scala-as-long-term-replacement-for.html&#034;&gt;summary&lt;/a&gt; of Scala, from which the above quote is taken.
&lt;/p&gt;
&lt;p&gt;
I also ordered a copy of &lt;a href=&#034;http://www.artima.com/shop/programming_in_scala_2ed&#034;&gt;Programming in Scala, Second Edition&lt;/a&gt; which I&#039;m enjoying reading and can thoroughly recommend.  Unlike many programming books it&#039;s well written with a light but not overly-chatty style.  It explicitly assumes you have programming experience, so it picks up pace pretty quickly.  As I&#039;ve been going through the book, most of my &#034;Why did they do that?&#034; questions have had good answers, which gives the impression that Scala has been very carefully thought through - always a good sign.
&lt;/p&gt;
&lt;p&gt;
Now all I have to do is to think of a substantial project I can use Scala on :-)
&lt;/p&gt;</description>
      <category>Tech</category>
    <category>Scala</category>
    <comments>http://bleaklow.com:80/2011/08/23/beautiful_scala.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2011/08/23/beautiful_scala.html</guid>
    <pubDate>Tue, 23 Aug 2011 08:24:23 GMT</pubDate>
  </item>
  <item>
    <title>Childhood autism spikes in geek heartlands </title>
    <link>http://bleaklow.com:80/2011/06/24/childhood_autism_spikes_in_geek_heartlands.html</link>
    <description>
          &lt;p&gt;
From the &lt;a href=&#034;http://www.newscientist.com&#034;&gt;New Scientist&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote&gt;
Childhood autism is two to four times as common in Eindhoven, the centre of the Dutch information technology industry, as it is in two comparably sized Dutch cities with far fewer IT employees.
&lt;br/&gt;&lt;br/&gt;
The result supports the suggestion that people who work in hi-tech engineering and computing industries, which demand the kinds of systemising and analytical skills often seen in people with autism, are more likely to have autistic children too.
&lt;br/&gt;&lt;br/&gt;
&lt;i&gt;&lt;a href=&#034;http://www.newscientist.com/article/dn20589-childhood-autism-spikes-in-geek-heartlands.html&#034;&gt;New Scientist, 20 June 2011, Childhood autism spikes in geek heartlands &lt;/a&gt;&lt;/i&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Who&#039;d have thought it :-)
&lt;/p&gt;</description>
      <category>Tech</category>
    <comments>http://bleaklow.com:80/2011/06/24/childhood_autism_spikes_in_geek_heartlands.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2011/06/24/childhood_autism_spikes_in_geek_heartlands.html</guid>
    <pubDate>Fri, 24 Jun 2011 11:10:15 GMT</pubDate>
  </item>
  <item>
    <title>A mention on the Pragmatic Programmer</title>
    <link>http://bleaklow.com:80/2011/05/08/a_mention_on_the_pragmatic_programmer.html</link>
    <description>
          &lt;p&gt;
I was looking at my &lt;a href=&#034;http://www.google.com/analytics/&#034;&gt;Google Analytics&lt;/a&gt; and noticed I was getting referrals from the &lt;a href=&#034;http://www.pragprog.com&#034;&gt;Pragmatic Programmer&lt;/a&gt; site, specifically from an article in the April magazine issue entitled &lt;a href=&#034;http://www.pragprog.com/magazines/2011-04/advanced-arduino-hacking&#034;&gt;Advanced Arduino Hacking&lt;/a&gt;.  Turns out they were using my &lt;a href=&#034;/files/2010/Makefile.master&#034;&gt;Makefile.master&lt;/a&gt; as the basis of their article, which describes how to use the Arduino platform without having to use the not-very-good Arduino IDE.  OK, I suppose that&#039;s a little unfair - the IDE is clearly meant for beginners but if you are an experienced developer or are working on more complex projects it becomes very limiting very quickly, as noted in the article.
&lt;/p&gt;
&lt;p&gt;
There are a &lt;a href=&#034;http://users.jyu.fi/~mweber/software/arduino/Makefile.master&#034;&gt;number&lt;/a&gt; &lt;a href=&#034;http://code.google.com/p/arduino/issues/attachmentText?id=344&amp;aid=7568997944726479287&amp;name=Makefile.master&amp;token=aabb0d45600455086e9b95b1f977f91a&#034;&gt;of&lt;/a&gt; copies of my Makefile.master floating around, but I&#039;m updating it fairly regularly, so I recommend you grab the &lt;a href=&#034;/files/2010/Makefile.master&#034;&gt;original version&lt;/a&gt;.  Compared to the version on the PragProg site, the current version (at time of writing) has the following improvements: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The only really platform-specific parts of the Makefile are those that deal with running the serial monitor used to connect to the Arduino.  On Solaris I use &lt;a href=&#034;http://download.oracle.com/docs/cd/E19253-01/816-5165/6mbb0m9tt/index.html&#034;&gt;tip&lt;/a&gt; whereas on Linux you&#039;d probably want to use something such as &lt;a href=&#034;http://www.gnu.org/software/screen/&#034;&gt;screen&lt;/a&gt;.  I&#039;ve therefore added platform-specific sections to configure the serial monitor commands to the Makefile.master.  I don&#039;t currently have settings for MacOS, if someone wants to provide some suggestions, I&#039;ll add them in.&lt;/li&gt;
&lt;br/&gt;
&lt;li&gt;I hit a linker bug when using the &lt;a href=&#034;http://www.nongnu.org/avr-libc/user-manual/index.html&#034;&gt;avr-libc&lt;/a&gt; floating-point library, the workaround being to specify &lt;code&gt;-lm&lt;/code&gt; both first and last in the linker command-line arguments.&lt;/li&gt;
&lt;br/&gt;
&lt;li&gt;An optional &lt;code&gt;EXTRA_FLAGS&lt;/code&gt; macro that can be used to specify any additional flags that you want passed to gcc/g++.  I use this for enabling/disabling debugging, e.g. &lt;code&gt;EXTRA_FLAGS=-DDEBUG&lt;/code&gt; in my project Makefile.&lt;/li&gt;
&lt;br/&gt;
&lt;li&gt;The automatic tracking of &lt;code&gt;#include&lt;/code&gt; dependencies was being done via a separate invocation of the compiler, this has been collapsed into the main compilation step, thus halving the number of times the compiler is invoked.  If you don&#039;t know what automatic dependency checking is, there&#039;s a good explanation &lt;a href=&#034;http://mad-scientist.net/make/autodep.html&#034;&gt;here&lt;/a&gt; and also in the &lt;a href=&#034;http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites&#034;&gt;GNU make&lt;/a&gt; documentation.&lt;/li&gt;
&lt;br/&gt;
&lt;li&gt;The generated dependency files are stored in the &lt;code&gt;build&lt;/code&gt; subdirectory of the project, but they do tend to clutter things up.  I&#039;ve therefore  moved them all into hidden (dot) files.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
One final note, the PragProg Makefile.master uses &lt;code&gt;stty -f $(PORT) hupcl&lt;/code&gt; to trigger a reset on the arduino before uploading the hex image to it.  Not only is that platform-specific, it&#039;s also unnecessary if you are using a recent-ish version of &lt;a href=&#034;http://www.nongnu.org/avrdude/&#034;&gt;avrdude&lt;/a&gt; which will do the reset for you if you specify a programmer type of &lt;code&gt;arduino&lt;/code&gt; rather than &lt;code&gt;stk500&lt;/code&gt;.
&lt;/p&gt;</description>
      <category>Arduino</category>
    <category>Tech</category>
    <comments>http://bleaklow.com:80/2011/05/08/a_mention_on_the_pragmatic_programmer.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2011/05/08/a_mention_on_the_pragmatic_programmer.html</guid>
    <pubDate>Sun, 08 May 2011 14:01:41 GMT</pubDate>
  </item>
  </channel>
</rss>

