<?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>thanthese</title>
	<atom:link href="http://stephenmann.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://stephenmann.net</link>
	<description>a miscellany</description>
	<lastBuildDate>Sun, 01 Aug 2010 15:05:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>music utility now on github</title>
		<link>http://stephenmann.net/2010/08/01/music-utility-now-on-github/</link>
		<comments>http://stephenmann.net/2010/08/01/music-utility-now-on-github/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 15:05:55 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=743</guid>
		<description><![CDATA[I&#8217;ve completed a music-transcription utility; it&#8217;s up on github. It&#8217;s a command-line utility. It works thusly: $&#62; ./music -r c c eb f# Finding matches scales for notes c eb f#: Eb min: 1.00 Db min: 1.00 Db maj: 1.00 Degrees of notes in c: c : r eb : b3 f# : #11 In [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve completed a music-transcription utility; it&#8217;s up on <a class="reference external" href="http://github.com/thanthese/NetBeansProjects/tree/master/music/">github</a>.</p>
<p>It&#8217;s a command-line utility.  It works thusly:</p>
<pre class="literal-block">
$&gt; ./music -r c c eb f#

Finding matches scales for notes c eb f#:
    Eb min: 1.00
    Db min: 1.00
    Db maj: 1.00

Degrees of notes in c:
    c  : r
    eb : b3
    f# : #11
</pre>
<p>In this example I ask the program to analyse C, Eb, and F# in the context of the key of C.  It returns that those notes, together, are in exactly 3 scales.  It also tells me what degrees of the key of C those notes represent.</p>
<p>The code itself, in my opinion, is very clean.  TDD followed; 100% code coverage; lots of small, well-defined classes; short methods; some amount of documentation; open-source.</p>
<p>Check it out, it&#8217;s all online.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/08/01/music-utility-now-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Official move from Vim to Netbeans</title>
		<link>http://stephenmann.net/2010/07/17/official-move-from-vim-to-netbeans/</link>
		<comments>http://stephenmann.net/2010/07/17/official-move-from-vim-to-netbeans/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 16:19:55 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=737</guid>
		<description><![CDATA[The better you know me the more shocked you will be to learn this: I am officially switching my primary programming environment from Vim to Netbeans. And it&#8217;s all Martin Fowler&#8217;s fault. Background First, a bit of background. I currently use Vim for everything. Everything. I&#8217;m writing this post in it right now. It is, [...]]]></description>
			<content:encoded><![CDATA[<p>The better you know me the more shocked you will be to learn this: I am officially switching my primary programming environment from Vim to Netbeans.</p>
<p>And it&#8217;s all Martin Fowler&#8217;s fault.</p>
<div class="section" id="background">
<h3>Background</h3>
<p>First, a bit of background.  I currently use Vim for everything.  <em>Everything.</em>  I&#8217;m writing this post in it right now.  It is, and will probably always continue to be, the best text editing environment ever devised.  I will certainly continue to use it over ugly hacks like, for example, Word.</p>
<p>Vim is such a good text editor, such a good programmer&#8217;s text editor, that it has been able to meet all my programming and customization needs for the last year or so.  I use it at home, and at work as my IDE.</p>
<p>Then, as I said, Martin Fowler stepped in.</p>
</div>
<div class="section" id="the-problem">
<h3>The Problem</h3>
<p>Problems began when I picked up his book, <em>Refactoring</em>.  Being the excellent book it is, it naturally led me to want to refactor everything, constantly, and automatically.  This led me on a hunt for good refactoring tools, and this led me to modern IDEs &#8212; with Netbeans being a fine example.</p>
<p>See, Vim is somewhat aware of syntax, but only on a regex level.  For true refactoring assistance, the editor really needs to understand languages on an <a class="reference external" href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a> level.  To my dismay, Vim does not have comprehensive plugins to solve this problem for every language I regularity use.  Further, writing all those plugins would be, I think, more effort than it was worth.</p>
<p>And I so I follow the productivity fairy to Netbeans.</p>
</div>
<div class="section" id="making-the-switch">
<h3>Making the Switch</h3>
<p>At first I was tempted to use <a class="reference external" href="http://jvi.sourceforge.net/">jVi</a>, the excellent vim plugin for Netbeans.  I ran into two &#8212; but really only two &#8212; problems.  First, jVi selection is different from Netbeans selection.  It&#8217;s irritation, distracting, and time-consuming to be constantly switching between the two types.  Second, on a admittedly more emotional level, I wanted to sound Netbeans&#8217; depths.  Find out what it could do under its own steam.  Be &quot;pure&quot; in my experiment.</p>
<p>So I thought about what it is in Vim that I really like, and boiled it down to two things.</p>
<ol class="arabic simple">
<li>Hands remain on homerow.  Now mouse or arrow keys needed.</li>
<li>Quickly accomplish common programming tasks.</li>
</ol>
<p>As it happed, Netbeans can handle both aspects.</p>
<div class="section" id="homerow">
<h4>Homerow</h4>
<p>The solution was remapping <em>everything</em>, which was surprisingly easy.  My currently (and will certainly change) layout on my mac:</p>
<p><tt class="docutils literal">CTRL +</tt></p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
<col width="82%" />
</colgroup>
<thead valign="bottom">
<tr>
<th class="head">shortcut</th>
<th class="head">action</th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td>h, j, k, l</td>
<td>move cursor left, down, up, right (like in vim)</td>
</tr>
<tr>
<td>u, o</td>
<td>move cursor to the previous, next word</td>
</tr>
<tr>
<td>y, p</td>
<td>move cursor to beginning, end of line</td>
</tr>
<tr>
<td>,, .</td>
<td>contract, expand selection</td>
</tr>
<tr>
<td>t, b</td>
<td>top, bottom of document</td>
</tr>
<tr>
<td>e, d</td>
<td>scroll screen up, down one line</td>
</tr>
</tbody>
</table>
<p>Adding <tt class="docutils literal">SHIFT</tt> to any combination (except the last) adds messing with the current selection.</p>
<p>Together, this relatively small set of shortcuts nicely solves my homerow problem (and, if I do say so myself, better than emacs solves it).  This probably alone gives me 50% of why I like vim so much.</p>
</div>
<div class="section" id="common-programming-tasks">
<h4>Common Programming Tasks</h4>
<p>Vim is largely a generic tool that lets me solve <em>any</em> text editing problem quickly.  Netbeans is specialized to solve <em>most common</em> programming tasks quickly.  Apparently, when it comes to programming, I perform the same tasks as everybody else.</p>
<p>A quick example:</p>
<p>Programmers often need to rename a variable.  Vim makes this easy for me: I select the scope I care about, and fire off a quick regex search-replace to change that word &#8212; thereby using generalized tools to solve the problem.</p>
<p>In Netbeans, I <tt class="docutils literal"><span class="pre">CTRL-R</span></tt> on the variable I want to rename, and type in the new name &#8212; using a highly specific tool to give me slightly faster and slightly more accurate results.</p>
</div>
</div>
<div class="section" id="what-i-m-giving-up">
<h3>What I&#8217;m giving up</h3>
<p>Leaving Vim for Netbeans, there are some things I&#8217;ll be giving up.  In no particular order:</p>
<p><em>Speed</em>.  Vim is <em>fast</em>.  It starts up fast, it runs fast.  It waits for you, I&#8217;ve never waited for it.  Netbeans takes long enough to start up that I get impatient.  Also, sometimes it will randomly stop accepting input and start crunching on something behind the scenes that I may or may not have asked for.</p>
<p><em>Stability</em>.  Vim has only ever crashed on me, by which I mean I had to restart it, once &#8212; and that was when I was playing around with a broken plugin on several 200MB+ files.  Netbeans has out-and-out <em>crashed</em> on me before, and required two restarts just in setting it up this week.</p>
<p><em>Consistency</em>.  Vim&#8217;s keybindings haven&#8217;t changed in 30 years (or whatever).  What I learn on it will apply to every version of vim used by basically anyone anywhere, and for years to come.  Netbeans&#8217; interface is not anywhere near so stable.  There will be new things to learn &#8212; and things to <em>unlearn</em> come every release.</p>
<p><em>Universality</em>.  Vim is installed by default on all OSs that really matter.  Netbeans is an enormous, additional install.</p>
<p><em>One ring to rule them all</em>.  With Vim there was only one tool in my toolset: Vim.  I learned <em>one</em> tool, and could apply that knowledge to anything I did on a computer.  Now, with Netbeans, there are two camps to learn.  Now I am master of none.</p>
<p><em>Customizability</em>.  Have a problem with vim?  Change it.  Between myriad options, remappings, new commands, and an easy-to-use plugin system, there&#8217;s really nothing about the editor you can&#8217;t change in an hour or two.  Heck, I even wrote a <a class="reference external" href="http://www.vim.org/scripts/script.php?script_id=3093">typing tutor</a> program in the editor.  Netbeans proponents would no doubt argue that the same is true of Netbeans, but I would say that there is an important difference in <em>ease</em>.</p>
<p><em>No Dialog Boxes</em>.  I hate dialog boxes.  Vim doesn&#8217;t have them.  Netbeans has <em>lots</em>.</p>
<p><em>Aesthetic</em>.  When you&#8217;ve got a GNU Screen + Vim setup running fullscreen, it looks awesome: ASCII and ASCII alone, as far as the eye can see.  With Netbeans, you&#8217;re just using an IDE.</p>
</div>
<div class="section" id="conclusion">
<h3>Conclusion</h3>
<p>Vim is a text-editing <em>machine</em>.  Once you&#8217;ve mastered it, you can quickly solve text-related tasks no one&#8217;s ever thought of.</p>
<p>Netbeans is &quot;just&quot; a programming environment, and not really suited to say, writing blog posts.  However, it&#8217;s <em>very good</em> at being a programming environment.  It&#8217;s Extract Method functionality alone is worth making the switch for.  When combined with its good custom keybinding functionality, its larger development community (meaning, as just one example, built-in live templates for everything under the sun), and the project&#8217;s overall attention-to-detail, I feel confident that I&#8217;ve made the right choice.</p>
<p>There will still be plenty of days, though, when I fire up vim to do something Netbeans will never be able to touch.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/07/17/official-move-from-vim-to-netbeans/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vim and ruby koans</title>
		<link>http://stephenmann.net/2010/05/31/vim-and-ruby-koans/</link>
		<comments>http://stephenmann.net/2010/05/31/vim-and-ruby-koans/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 00:00:27 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=733</guid>
		<description><![CDATA[In this screencast I demonstrate the (okay, &#34;a&#34;) vim way to work through the ruby_koans. The crux of the method is vim&#8217;s awesome make command, which runs your makeprg (rake, in this case), hops you to the first error, and displays more information in the QuickFix window. I can&#8217;t imagine a more streamlined system for [...]]]></description>
			<content:encoded><![CDATA[<p>In <a class="reference external" href="http://screencast.com/t/YzM4Njlh">this screencast</a> I demonstrate the (okay, &quot;a&quot;) vim way to work through the <a class="reference external" href="http://github.com/edgecase/ruby_koans">ruby_koans</a>.</p>
<p>The crux of the method is vim&#8217;s awesome <tt class="docutils literal">make</tt> command, which runs your <tt class="docutils literal">makeprg</tt> (<tt class="docutils literal">rake</tt>, in this case), hops you to the first error, and displays more information in the QuickFix window.</p>
<p>I can&#8217;t imagine a more streamlined system for working through the koans.  I make a change, and &quot;seeing if I&#8217;m right and moving on to the next assert&quot; is only a single shortcut away (<tt class="docutils literal">&#64;:</tt> repeats the last command; I have it mapped to <tt class="docutils literal">tab</tt>).</p>
<p>ruby_koans is an innovative and fun way to learn the ruby language.  I highly recommend trying it out &#8212; with vim, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/31/vim-and-ruby-koans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim: paste yanked text</title>
		<link>http://stephenmann.net/2010/05/21/vim-paste-yanked-text/</link>
		<comments>http://stephenmann.net/2010/05/21/vim-paste-yanked-text/#comments</comments>
		<pubDate>Fri, 21 May 2010 22:03:42 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=730</guid>
		<description><![CDATA[Vim automatically yanks all text into the &#34;0 register, and deletes all text into the &#34;1 &#8211; &#34;9&#34; registers. This is handy if you want to yank out some useful text before deleting a section. Later, just &#34;0p to drop the good bit where you want it. But &#34;0p is pretty awkward to type. I [...]]]></description>
			<content:encoded><![CDATA[<p>Vim automatically yanks all text into the <tt class="docutils literal">&quot;0</tt> register, and deletes all text into the <tt class="docutils literal">&quot;1</tt> &#8211; <tt class="docutils literal">&quot;9&quot;</tt> registers.</p>
<p>This is handy if you want to yank out some useful text before deleting a section.  Later, just <tt class="docutils literal">&quot;0p</tt> to drop the good bit where you want it.</p>
<p>But <tt class="docutils literal">&quot;0p</tt> is pretty awkward to type.</p>
<p>I created these alternate mappings today, which are both easier to type and have better mnemonics.</p>
<pre class="code-block vim literal-block">
<span class="c">&quot; put last yanked text</span>
nmap yp <span class="c">&quot;0p</span>
nmap yP <span class="c">&quot;0P</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/21/vim-paste-yanked-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TortoiseTyping vim plugin</title>
		<link>http://stephenmann.net/2010/05/15/tortoisetyping-vim-plugin/</link>
		<comments>http://stephenmann.net/2010/05/15/tortoisetyping-vim-plugin/#comments</comments>
		<pubDate>Sat, 15 May 2010 22:02:59 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[portfolio]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=727</guid>
		<description><![CDATA[I&#8217;ve successfully uploaded my first vim plugin! It&#8217;s a minimal typing tutor aimed at touch-typists who would like to spend a few minutes a week sharpening their skills. I&#8217;ve noticed, for myself, that for less than 10 minutes a week I can increase my average speed from around 50 to 85 WPM, which seems worthwhile. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve successfully uploaded my <a class="reference external" href="http://www.vim.org/scripts/script.php?script_id=3093">first vim plugin</a>!  It&#8217;s a minimal typing tutor aimed at touch-typists who would like to spend a few minutes a week sharpening their skills.  I&#8217;ve noticed, for myself, that for less than 10 minutes a week I can increase my average speed from around 50 to 85 WPM, which seems worthwhile.</p>
<p>This script is called TortoiseTyping because with typing its slow, steady, and accurate wins the race.</p>
<p>I enjoy vim so much, it feels good to be able to give something back, however small.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/15/tortoisetyping-vim-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automatically trim trailing whitespace in vim</title>
		<link>http://stephenmann.net/2010/05/07/automatically-trim-trailing-whitespace-in-vim/</link>
		<comments>http://stephenmann.net/2010/05/07/automatically-trim-trailing-whitespace-in-vim/#comments</comments>
		<pubDate>Sat, 08 May 2010 01:24:15 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=723</guid>
		<description><![CDATA[Trailing whitespace is never necessary. To remove it automatically every time you save a file, add this to your .vimrc: &#34; on save any: trim trailing whitespace autocmd! BufWrite * mark ' &#124; silent! %s/\s\+$// &#124; norm '' The regular expression should be clear to anyone familiar with regular expressions. The junk immediately before and [...]]]></description>
			<content:encoded><![CDATA[<p>Trailing whitespace is never necessary.  To remove it automatically every time you save a file, add this to your <tt class="docutils literal">.vimrc</tt>:</p>
<pre class="code-block vim literal-block">
<span class="c">&quot; on save any: trim trailing whitespace</span>
autocmd<span class="p">!</span> <span class="nb">BufWrite</span> * mark <span class="s1">' | silent! %s/\s\+$// | norm '</span>'
</pre>
<p>The regular expression should be clear to anyone familiar with regular expressions.  The junk immediately before and after ensures that the cursor ends up where it started.  The <tt class="docutils literal">autocmd</tt> sets the command to fire on the <tt class="docutils literal">BufWrite</tt> event for all files.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/07/automatically-trim-trailing-whitespace-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improve S-expressions with python whitespace</title>
		<link>http://stephenmann.net/2010/05/06/improve-s-expressions-with-python-whitespace/</link>
		<comments>http://stephenmann.net/2010/05/06/improve-s-expressions-with-python-whitespace/#comments</comments>
		<pubDate>Fri, 07 May 2010 00:51:25 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=717</guid>
		<description><![CDATA[S-expressions are lisp&#8217;s great syntactical strength, and death-by-parentheses its greatest weakness. Why not take a page from python&#8217;s book and make whitespace significant? The rules are simple. ( or ) add a newline. ( adds an indentation level, while ) removes one. example 1 &#34; old way (a b c d) &#34; new way a [...]]]></description>
			<content:encoded><![CDATA[<p>S-expressions are lisp&#8217;s great syntactical strength, and death-by-parentheses its greatest weakness.  Why not take a page from python&#8217;s book and make whitespace significant?</p>
<p>The rules are simple.  <tt class="docutils literal">(</tt> or <tt class="docutils literal">)</tt> add a newline.  <tt class="docutils literal">(</tt> adds an indentation level, while <tt class="docutils literal">)</tt> removes one.</p>
<div class="section" id="example-1">
<h3>example 1</h3>
<pre class="literal-block">
&quot; old way
(a b c d)

&quot; new way
a b c d
</pre>
</div>
<div class="section" id="example-2">
<h3>example 2</h3>
<pre class="literal-block">
&quot; old way
(a b (c d e (f g)))

&quot; new way
a b
  c d e
    f g
</pre>
</div>
<div class="section" id="example-3">
<h3>example 3</h3>
<pre class="literal-block">
&quot; old way
(a b (c d (e f) g))

&quot; new way
a b
  c d
    e f
  g
</pre>
</div>
<div class="section" id="example-4">
<h3>example 4</h3>
<pre class="literal-block">
&quot; some conventional pseudo language
if a == 0 then 1 + 2 else 3 + 4

&quot; S-expression
(if (== a 0) (+ 1 2) (+ 3 4))

&quot; new way
if
  == a 0
  + 1 2
  + 3 4
</pre>
<p>Even modern languages have extra syntactic junk floating around.  Why not get rid of it?</p>
<p><strong>Update:</strong>  It was brought to my attention that this scheme breaks under some circumstances.  Specifically, whenever two or more open parentheses appear in a row &#8212; <tt class="docutils literal">((</tt> &#8212; double indenting and ambiguity can occur.</p>
<p>There are two fixes, neither great.</p>
<ol class="arabic simple">
<li>Make the using parentheses optional, so that they can be pulled out in the more complex situations.  Haskell&#8217;s &quot;on-sides&quot; strategy works like this (though for different reasons), where curly braces and semicolons <em>can</em> be used &#8212; though in practice no ones does.</li>
<li>In situations where <tt class="docutils literal">((</tt> would appear, introduce a place-holding element.  Maybe a <tt class="docutils literal">.</tt>, for example, between the two.  My understanding of lisp is weak, but I think this <em>might</em> bear some resemblance to its <tt class="docutils literal">let</tt>.</li>
</ol>
<p>Both cases require disallowing the &quot;<tt class="docutils literal">((</tt>&quot; situation.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/06/improve-s-expressions-with-python-whitespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL port woes on upgrade</title>
		<link>http://stephenmann.net/2010/05/04/postgresql-port-woes-on-upgrade/</link>
		<comments>http://stephenmann.net/2010/05/04/postgresql-port-woes-on-upgrade/#comments</comments>
		<pubDate>Wed, 05 May 2010 00:50:58 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=711</guid>
		<description><![CDATA[This consumed enough of my time that I thought I&#8217;d post something about it. When I installed Ubuntu 10.04 my postgres bumped from 8.3 to 8.4. In order to avoid stomping on 8.3&#8242;s old ports, 8.4 silently moved from port 5432 to 5433 &#8212; which is great except for the &#34;silent&#34; part. The only indication [...]]]></description>
			<content:encoded><![CDATA[<p>This consumed enough of my time that I thought I&#8217;d post something about it.</p>
<p>When I installed Ubuntu 10.04 my postgres bumped from 8.3 to 8.4.  In order to avoid stomping on 8.3&#8242;s old ports, 8.4 silently moved from port 5432 to 5433 &#8212; which is great except for the <em>&quot;silent&quot;</em> part.  The only indication I had of the change was everything exploding in my face.</p>
<p>To set 8.4&#8242;s port number back to 5432:</p>
<ol class="arabic">
<li>
<p class="first">create this line in your <tt class="docutils literal">.bashrc</tt></p>
<pre class="literal-block">
export PGPORT=5432
</pre>
</li>
<li>
<p class="first">and change this line in <tt class="docutils literal">/etc/postgresql/8.4/main/postgresql.conf</tt></p>
<pre class="literal-block">
port = 5432  # (change requires restart)
</pre>
</li>
<li>
<p class="first">I no longer trust the postgres restart, so restart with</p>
<pre class="literal-block">
$ sudo service postgres-8.4 stop
$ sudo service postgres-8.4 start
</pre>
</li>
</ol>
<p>And, hopefully, your frustrations will end sooner than mine did.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/04/postgresql-port-woes-on-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One-line recursive python function</title>
		<link>http://stephenmann.net/2010/05/01/one-line-recursive-python-function/</link>
		<comments>http://stephenmann.net/2010/05/01/one-line-recursive-python-function/#comments</comments>
		<pubDate>Sat, 01 May 2010 19:19:22 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=705</guid>
		<description><![CDATA[The original challenge posed to me was to create a one-line recursive function in python. To reach this solution I started with this function def shortAny(n): &#34;&#34;&#34;Return if any of a list of bools are True.&#34;&#34;&#34; if(n): if(n[0]): return True else: return shortAny(n[1:]) else: return False then &#34;simplified&#34; it to this def shortAny(n): return bool(n) [...]]]></description>
			<content:encoded><![CDATA[<p>The original challenge posed to me was to create a one-line recursive function in python.  To reach this solution I started with this function</p>
<pre class="code-block python literal-block">
<span class="k">def</span> <span class="nf">shortAny</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot;Return if any of a list of bools are True.&quot;&quot;&quot;</span>
  <span class="k">if</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
    <span class="k">if</span><span class="p">(</span><span class="n">n</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
      <span class="k">return</span> <span class="bp">True</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="n">shortAny</span><span class="p">(</span><span class="n">n</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
  <span class="k">else</span><span class="p">:</span>
    <span class="k">return</span> <span class="bp">False</span>
</pre>
<p>then &quot;simplified&quot; it to this</p>
<pre class="code-block python literal-block">
<span class="k">def</span> <span class="nf">shortAny</span><span class="p">(</span><span class="n">n</span><span class="p">):</span> <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">n</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">or</span> <span class="n">shortAny</span><span class="p">(</span><span class="n">n</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>

<span class="c"># basic testing</span>
<span class="n">T</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">f</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([])</span> <span class="o">==</span> <span class="n">f</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">f</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">f</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">f</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">f</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">f</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
<span class="k">assert</span> <span class="n">shortAny</span><span class="p">([</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">])</span> <span class="o">==</span> <span class="n">T</span>
</pre>
<p>This function would not have been possible without python&#8217;s short cutting feature for &quot;and&quot; and &quot;or&quot;.</p>
<p>Note that this was an intellectual exercise, and that code like this should never really be written by anyone.</p>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/05/01/one-line-recursive-python-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple python Rubik&#8217;s Cube timer</title>
		<link>http://stephenmann.net/2010/04/27/simple-python-rubiks-cube-timer/</link>
		<comments>http://stephenmann.net/2010/04/27/simple-python-rubiks-cube-timer/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 00:40:29 +0000</pubDate>
		<dc:creator>Stephen Mann</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rubik's cube]]></category>

		<guid isPermaLink="false">http://stephenmann.net/?p=701</guid>
		<description><![CDATA[In my quest for the sub-30 Rubik&#8217;s Cube solve, I realized that I needed data. To that end, I wrote the following python script. It times how long I take on each step of the solve, and provides depressing statistics afterwards. Efforts were made to make the code as clear as possible. I received assistance [...]]]></description>
			<content:encoded><![CDATA[<p>In my quest for the sub-30 Rubik&#8217;s Cube solve, I realized that I needed data.  To that end, I wrote the following python script.  It times how long I take on each step of the solve, and provides depressing statistics afterwards.</p>
<p>Efforts were made to make the code as clear as possible.  I received assistance from <a class="reference external" href="http://adamcolton.net">this guy</a>.</p>
<pre class="code-block python literal-block">
<span class="c">#!/usr/bin/env python</span>

<span class="kn">import</span> <span class="nn">timeit</span>

<span class="sd">&quot;&quot;&quot;
Stephen Mann
April 2010

Terminal program for timing Rubik's Cube solves using a
modified Roux method.

Intended to be used as a bash utility.  Run chmod +x on the
file and drop it in your PATH somewhere.  Now the script can
be run from anywhere on the system with just

  $ cuberun

Credits
-------

Editing and suggestions from Adam Colton,

http://adamcolton.net

&quot;&quot;&quot;</span>

<span class="n">stages</span> <span class="o">=</span> <span class="p">[</span>
  <span class="s">&quot;inspect&quot;</span><span class="p">,</span>
  <span class="s">&quot;left 2x2 block&quot;</span><span class="p">,</span>
  <span class="s">&quot;left 2x1 block&quot;</span><span class="p">,</span>
  <span class="s">&quot;right 2x2 block&quot;</span><span class="p">,</span>
  <span class="s">&quot;right 2x1 block&quot;</span><span class="p">,</span>
  <span class="s">&quot;permutate corners&quot;</span><span class="p">,</span>
  <span class="s">&quot;orient corners&quot;</span><span class="p">,</span>
  <span class="s">&quot;orient edges&quot;</span><span class="p">,</span>
  <span class="s">&quot;permutate R/L edges&quot;</span><span class="p">,</span>
  <span class="s">&quot;permutate M edges&quot;</span> <span class="p">]</span>

<span class="k">def</span> <span class="nf">wait</span><span class="p">(</span><span class="n">message</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot;
  Return how many seconds it takes the user to hit &lt;enter&gt;.
  Display message in meantime.
  &quot;&quot;&quot;</span>

  <span class="n">cmd</span> <span class="o">=</span> <span class="s">&quot;raw_input('  </span><span class="si">%s</span><span class="s">')&quot;</span> <span class="o">%</span> <span class="n">message</span>
  <span class="k">return</span> <span class="n">timeit</span><span class="o">.</span><span class="n">Timer</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span><span class="o">.</span><span class="n">timeit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="k">print</span>
<span class="k">print</span> <span class="s">&quot;=========================================&quot;</span>
<span class="k">print</span> <span class="s">&quot;press &lt;enter&gt; after completing each stage&quot;</span>
<span class="k">print</span> <span class="s">&quot;=========================================&quot;</span>

<span class="n">durs</span>  <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">stages</span><span class="p">)</span>  <span class="c"># durations</span>
<span class="n">nDurs</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="n">durs</span><span class="p">,</span> <span class="n">stages</span><span class="p">)</span>  <span class="c"># named durations</span>

<span class="n">total</span>   <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">durs</span><span class="p">)</span>
<span class="n">slowest</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">nDurs</span><span class="p">)</span>
<span class="n">fastest</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">nDurs</span><span class="p">)</span>

<span class="k">print</span>
<span class="k">print</span> <span class="s">&quot;results&quot;</span>
<span class="k">print</span> <span class="s">&quot;=======&quot;</span>

<span class="k">for</span> <span class="n">nDur</span> <span class="ow">in</span> <span class="n">nDurs</span><span class="p">:</span>
  <span class="k">print</span> <span class="s">&quot;</span><span class="si">%4.1f</span><span class="s">: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">nDur</span>

<span class="k">print</span> <span class="s">&quot;total: </span><span class="si">%.1f</span><span class="s"> seconds&quot;</span> <span class="o">%</span> <span class="n">total</span>
<span class="k">print</span>
<span class="k">print</span> <span class="s">'slowest stage at </span><span class="si">%4.1f</span><span class="s"> seconds was &quot;</span><span class="si">%s</span><span class="s">&quot;'</span> <span class="o">%</span> <span class="n">slowest</span>
<span class="k">print</span> <span class="s">'fastest stage at </span><span class="si">%4.1f</span><span class="s"> seconds was &quot;</span><span class="si">%s</span><span class="s">&quot;'</span> <span class="o">%</span> <span class="n">fastest</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://stephenmann.net/2010/04/27/simple-python-rubiks-cube-timer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
