<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>The Occasional Occurence</title>
    <link>http://blog.dowski.com/</link>
    <description>Unfortunately, Christian had a thwart and the magpie stayed in play.</description>
    <pubDate>Sat, 16 Feb 2013 22:17:10 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Bit Packing</title>
      <link>http://blog.dowski.com/2013/2/16/bit-packing</link>
      <pubDate>Sat, 16 Feb 2013 17:08:00 EST</pubDate>
      <category><![CDATA[python]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/2013/2/16/bit-packing</guid>
      <description>Bit Packing</description>
      <content:encoded><![CDATA[<div class="document">
<p>I started writing this blog post on 2012/1/10 at 11:04:00 AM. Over a year ago!</p>
<p>It began:</p>
<blockquote>
I've been reading a book called <a class="reference external" href="http://www.charlespetzold.com/code/">Code</a>, researching <a class="reference external" href="http://en.wikipedia.org/wiki/Bloom_filter">Bloom Filters</a> and
generally thinking more about bits. I don't think about bits very often.
I do most of my programming in <a class="reference external" href="http://python.org/">Python</a> and <em>bits are a few levels of abstraction
below my typical operating plane</em>.</blockquote>
<p>A fair &quot;bit&quot; has changed since then.</p>
<p>I finished that book. It was fantastic, and gave me more of a general appreciation of the
electronics that underly so much of what I get to do.</p>
<p>I'm now fairly comfortable operating at a lower level of abstraction; namely
coding in <a class="reference external" href="http://en.wikipedia.org/wiki/C_(programming_language)">C</a>.  I've had a hand in a number of C codebases over the past year.
First was extending a <a class="reference external" href="http://en.wikipedia.org/wiki/K-d_tree">k-d tree</a> library with range query support. Then it was
helping to build an application that made use of the library. Most recently
I've been retooling that k-d tree library to support disk-based persistence and
tinkering with writing a Python extension module in C.  Oh, I also released a
silly utility called <a class="reference external" href="https://github.com/dowski/preptime">preptime</a> that prepends a timestamp to lines of input that
are fed to it.</p>
<p>I don't have too much more to say about that. I mostly just thought I should finish
this poor blog post when I saw it sitting there all lonely and unpublished.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Must Wash Hands</title>
      <link>http://blog.dowski.com/2012/1/4/wash-hands</link>
      <pubDate>Wed, 04 Jan 2012 10:43:00 EST</pubDate>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/2012/1/4/wash-hands</guid>
      <description>Must Wash Hands</description>
      <content:encoded><![CDATA[<div class="document">
<p>At most coffee shops and restaurants there is a sign in the restroom that says:</p>
<blockquote>
Employees must wash hands before returning to work.</blockquote>
<p>That's great. I'm glad that employees must do that.</p>
<p>I think we should aim higher though. I'd like to see a sign that says:</p>
<blockquote>
All human beings must wash their hands before leaving this room.</blockquote>
<p>To start, I'm going to post that sign in the bathroom at home. After all, there
are some human beings at home that could use that reminder.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>The Internet</title>
      <link>http://blog.dowski.com/2011/12/29/the-internet/</link>
      <pubDate>Thu, 29 Dec 2011 21:22:00 EST</pubDate>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/2011/12/29/the-internet/</guid>
      <description>The Internet</description>
      <content:encoded><![CDATA[<div class="document">
<p>There was some discussion amongst friends and family around the dinner table
tonight about the Internet. Someone quipped that our kids were going to grow up
in a world where the idea of no Internet is silly. It's just there.</p>
<p>The thought was disturbing to some, but to me, <em>I</em> am the one who grew up with
the Internet.  Let me explain.</p>
<p>Ever since I watched <a class="reference external" href="http://en.wikipedia.org/wiki/WarGames">WarGames</a> when I was a kid and saw that computers could
be used to connect to each other, I was hooked. I had to connect computers and
the people at either end.</p>
<p>When my family finally got a PC clone with a modem, I remember dialing up to a
friend's computer, just so we could type back and forth to each other. Of
course, only one of us could type at a time. But right there we had
independently invented the Internet, social networks, IM, etc.</p>
<p>Later I picked up some long-distance <a class="reference external" href="http://en.wikipedia.org/wiki/Bulletin_board_system">BBS</a> phone numbers from some pirated C64
games. Despite the penalty for unauthorized long-distance calls in the house, I
had to connect to these BBSes. It was amazing, and while connected, I found
phone numbers for local BBSes. I could connect without fear (but not without
the good chance of someone picking up the phone and ruining my connection!).</p>
<p>So it turned out that there were nerds like me out there who wanted to connect
their computers and their experiences with each other. There were message
boards, multiplayer BBS games and pirated software. There was Fidonet for
messages between BBSes, and lo-and-behold, one of the local BBSes offered a
real Internet email address and Usenet access for a one-time $10 fee.</p>
<p>Eventually I got a hold of a dial-in number to a Kent State University
mainframe. It had a <a class="reference external" href="http://en.wikipedia.org/wiki/Gopher_(protocol)">Gopher</a> client installed and I think it was <a class="reference external" href="http://en.wikipedia.org/wiki/CERN#Computer_science">CERN</a> that
offered a Gopher-to-WWW gateway or something. Anyhow, my first experience
browsing the web was using Lynx via Gopher over a 2400bps modem. I think I get
some nerd points for that.</p>
<p>By this point I was connecting to computers and people all over the world. It
was/is awesome. Since then I've learned to program thanks to countless
open-source devotees on the Internet, met some people who have become great
friends over the Internet and I do 99% of my work remotely over the Internet.</p>
<p>To bring this in for a landing, I think it's cool that at <a class="reference external" href="http://bu.mp/">Bump</a> (where I work)
my job is to write software that lets people use the Internet to connect in
new ways. The Internet is not this scary, far-away place. It's right there in
your hand, helping you connect with people just like it always has.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Blogofile!</title>
      <link>http://blog.dowski.com/2011/05/06/blogofile/</link>
      <pubDate>Fri, 06 May 2011 23:04:00 EDT</pubDate>
      <category><![CDATA[python]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/2011/05/06/blogofile/</guid>
      <description>Blogofile!</description>
      <content:encoded><![CDATA[<div class="document">
<p>Here's a test post now that I've moved my blog to <a class="reference external" href="http://www.blogofile.com/">Blogofile</a>. The blog
looks pretty shabby right now. I need to pull out some CSS voodoo and
ditch the boilerplate template.</p>
<p>I'm up and running though. Hopefully new posts will commence now that
I'm rid of Wordpress.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Dremel Hack: Laptop Stand</title>
      <link>http://blog.dowski.com/2010/12/09/dremel-hack-laptop-stand/</link>
      <pubDate>Thu, 09 Dec 2010 14:40:04 EST</pubDate>
      <category><![CDATA[photos]]></category>
      <category><![CDATA[computing]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/?p=398</guid>
      <description>Dremel Hack: Laptop Stand</description>
      <content:encoded><![CDATA[<div class="document">
<p>I have this laptop stand.  It puts my laptop at a nice height when I am using it at my desk.</p>
<p>I have this laptop. It has the headphone and microphone jacks at the front edge of the body.</p>
<p>I have these headphones.  They don't play nicely with the laptop when it is in the stand.</p>
<p>So I hacked the laptop stand with my Dremel.</p>
<p><strong>Before</strong> (cameo by my fingers, holding the front edge of the laptop up)</p>
<p><img alt="img_0" src="http://lh3.ggpht.com/_9gjL_waMKiA/TQEdLC2BQLI/AAAAAAAAM2E/1JKGqsp7lKA/s288/IMG_6140.JPG" /> From <a class="reference external" href="http://picasaweb.google.com/dowskifamily/20101209ByEyeFi?authkey=Gv1sRgCNK8uoyw76jJWA&amp;feat=embedwebsite">2010-12-09 (by Eye-Fi)</a></p>
<p><strong>The Problem</strong></p>
<p><img alt="img_1" src="http://lh5.ggpht.com/_9gjL_waMKiA/TQEdE4LYfFI/AAAAAAAAM14/dSdH_laj5ds/s288/IMG_6139.JPG" /> From <a class="reference external" href="http://picasaweb.google.com/dowskifamily/20101209ByEyeFi?authkey=Gv1sRgCNK8uoyw76jJWA&amp;feat=embedwebsite">2010-12-09 (by Eye-Fi)</a></p>
<p><strong>After</strong></p>
<p><img alt="img_2" src="http://lh3.ggpht.com/_9gjL_waMKiA/TQEhS_pCdLI/AAAAAAAAM3A/PQLXbtXnaPQ/s288/IMG_6143.JPG" /> From <a class="reference external" href="http://picasaweb.google.com/dowskifamily/20101209ByEyeFi?authkey=Gv1sRgCNK8uoyw76jJWA&amp;feat=embedwebsite">2010-12-09 (by Eye-Fi)</a></p>
<p>cw</p>
<p>PS - These macro shots reveal to the world that my desk needs to be dusted.  How embarrassing!</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>More On Organic Code</title>
      <link>http://blog.dowski.com/2010/11/29/more-on-organic-code/</link>
      <pubDate>Mon, 29 Nov 2010 14:07:08 EST</pubDate>
      <category><![CDATA[Software]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/?p=393</guid>
      <description>More On Organic Code</description>
      <content:encoded><![CDATA[<div class="document">
<p>I blogged a couple years ago about <a class="reference external" href="http://blog.dowski.com/2008/02/13/code-farming/">Code Farming</a> (tl;dr - the web is a more organic programming environment than packaged software).  That post was mostly a commentary on another post I had read.</p>
<p>This past weekend I read &quot;<a class="reference external" href="http://journal.stuffwithstuff.com/2010/11/26/the-biology-of-sloppy-code/">The Biology of Sloppy Code</a>&quot;. It touches on some of those same ideas that inspired me to post about Code Farming.</p>
<p>Despite the title, it's less about sloppy code than it is about attempting to categorize different types of software development according to more traditional sciences.</p>
<p>I don't have any specific comments on the article, other than suggesting you read it.  I will say that I particularly enjoyed the references to <a class="reference external" href="http://abstract.io/n">abstraction</a>, Play-Doh and a few zingers the author threw in (real programmers vs. sissy Nancy-boy bedwetters).</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>A JSON Parser Using SimpleParse</title>
      <link>http://blog.dowski.com/2010/07/21/a-json-parser-using-simpleparse/</link>
      <pubDate>Wed, 21 Jul 2010 14:31:32 EDT</pubDate>
      <category><![CDATA[Python]]></category>
      <category><![CDATA[Software]]></category>
      <category><![CDATA[computing]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/?p=387</guid>
      <description>A JSON Parser Using SimpleParse</description>
      <content:encoded><![CDATA[<div class="document">
<p>I've been reading <a class="reference external" href="http://jaredforsyth.com/blog/2010/jul/21/codetalker-doubles-in-speed/">the recent posts on CodeTalker</a> with interest.  I've written a handful of parsers using two different parser generators for Python: <a class="reference external" href="http://www.dabeaz.com/ply/">PLY</a> and <a class="reference external" href="http://simpleparse.sourceforge.net/">SimpleParse</a>.  My most recent work with parsing has had me gravitating toward SimpleParse so I thought I'd see how it stacks up against CodeTalker.</p>
<p>First I checked the web to see if someone had written a JSON parser using SimpleParse.  I found <a class="reference external" href="http://bitbucket.org/robla/jsonwidget-python/src/tip/jsonwidget/jsonorder.py">Rob Lanphier's JsonOrder</a>.  It at least had a grammar that I could yank as a jumping off point.</p>
<p>The result after about an hour of coding and benchmarking is <a class="reference external" href="http://bitbucket.org/dowski/etc/src/tip/parsing/spjson.py">spjson.py</a>.  At first I tried to adapt Rob's version but I switched back to SimpleParse's <a class="reference external" href="http://simpleparse.sourceforge.net/processing_result_trees.html">dispatch processor</a> model.  Pretty much the only thing that remains from JsonOrder is the tweaked grammar.</p>
<p>How does it measure up to CodeTalker's JSON parser?</p>
<p>It's a bit slower.  I added a simple timeit benchmark to the spjson.py file.  I used <a class="reference external" href="http://github.com/jabapyth/benchmarking-stuff/blob/master/json_/large_doc.json">the same JSON file</a> that Jared (the CodeTalker author) used in his benchmarks.  Here are the results of running it against <a class="reference external" href="http://github.com/jabapyth/codetalker/commit/67225442b2c8889d12fd795510cf24384ed815bb">the latest version of CodeTalker at the time</a>:</p>
<pre class="literal-block">
CodeTalker 0.0484498786926
SimpleParse 0.0623928356171
</pre>
<p>In terms of lines of code they are nearly identical.  I didn't do anything fancy to omit docstrings or comments (neither module has many of either).</p>
<pre class="literal-block">
$ # use 'head' to strip the 'if __name__ ...' section
$ head spjson.py -n 71 | grep -v '^\s*$' | wc -l
55
$ cat src/codetalker/codetalker/contrib/json.py | grep -v '^\s*$' | wc -l
55
</pre>
<p>The style is the biggest difference.  SimpleParse uses an EBNF defined in a string to create the parser.  CodeTalker uses an EBNF defined using Python code.</p>
<p>Both libraries let you write specialized processors for the grammar.  This is one thing that I really value in SimpleParse over PLY.  Your grammar and the code to act on the parse tree (or token stream) are neatly separated.</p>
<p>I'm still quite happy with SimpleParse.  I like having the grammar in a nice contained EBNF rather than defined with Python + syntactic sugar.  I'll probably give CodeTalker a look next time a new parsing task comes up though.  It's great to see how the options for parsing in Python are expanding.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Rebasing to a New Branch with Mercurial</title>
      <link>http://blog.dowski.com/2010/07/09/rebasing-to-a-new-branch-with-mercurial/</link>
      <pubDate>Fri, 09 Jul 2010 08:53:56 EDT</pubDate>
      <category><![CDATA[Python]]></category>
      <category><![CDATA[Software]]></category>
      <category><![CDATA[work]]></category>
      <category><![CDATA[computing]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/?p=378</guid>
      <description>Rebasing to a New Branch with Mercurial</description>
      <content:encoded><![CDATA[<div class="document">
<p>I had a situation at work the other day where I had made a number of local commits to the <tt class="docutils literal">default</tt> branch of my repo.  I wanted to push them upstream to our central server but the feature was incomplete and I didn't want to break anything in case someone needed to make a tweak to the current code in the <tt class="docutils literal">default</tt> branch.</p>
<p>I had the idea to use the <tt class="docutils literal">`hg rebase <span class="pre">&lt;http://mercurial.selenic.com/wiki/RebaseProject&gt;`_</span></tt> command to move all my local commits to a new branch before pushing.  It worked, and here's how I did it.</p>
<ol class="arabic simple">
<li><tt class="docutils literal">hg clone localrepo <span class="pre">temp-localrepo</span></tt>. I always try crazy ideas in another local clone in case I trash the repo.</li>
<li><tt class="docutils literal">hg up</tt> to the revision before my local commits that I want to put in a branch.</li>
<li><tt class="docutils literal">hg branch newbranchname &amp;&amp; hg ci <span class="pre">-m</span> &quot;Branching for reason foo.&quot;</tt> This creates a new branch and head that can be used as a rebase destination.</li>
<li>Now for the rebase. I needed to rebase the first changeset in my series of local changes onto the <tt class="docutils literal">newbranchname</tt> changeset.  Something like <tt class="docutils literal">hg rebase <span class="pre">--source</span> 94 <span class="pre">--dest</span> 105</tt>.</li>
</ol>
<p>That's about it.  After verifying that it did what I wanted all that was left was to repeat the steps in my main local repo and push to the central server.*</p>
<p>cw</p>
<p>* <em>Of course what I actually did was push these changes to my main local repo and then to the central repo.  Woops.  That left me with the changes both in ``default`` and in ``newbranchname``.</em></p>
<p><em>Don't do that.  Repeat the steps after you've tried them in another local clone.  I leave recovering from such a situation with ```hg strip &lt;http://mercurial.selenic.com/wiki/Strip&gt;`_`` as an exercise for the reader.</em></p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Getting Version Information from Mercurial</title>
      <link>http://blog.dowski.com/2010/05/13/getting-version-information-from-mercurial/</link>
      <pubDate>Thu, 13 May 2010 16:52:49 EDT</pubDate>
      <category><![CDATA[Python]]></category>
      <category><![CDATA[work]]></category>
      <category><![CDATA[computing]]></category>
      <category><![CDATA[Software]]></category>
      <guid>http://blog.dowski.com/?p=373</guid>
      <description>Getting Version Information from Mercurial</description>
      <content:encoded><![CDATA[<div class="document">
<p>In an application I'm working on <a class="reference external" href="http://www.polimetrix.com">at work</a> I want to be able to display various bits of version information in the UI.  This goes for both production deployments from Python EGG files and in development running straight out of the repository.</p>
<p>We use <a class="reference external" href="http://mercurial.selenic.com/">Mercurial</a> for revision control so it is a logical choice for a version information source.  The result of some hacking is my first Mercurial extension and commit hook.</p>
<p><a class="reference external" href="http://bitbucket.org/dowski/mercurial-version-info-plugin/src">Mercurial Version Info Plugin</a>.</p>
<p>See the README file rendered at that link for the details.  <a class="reference external" href="http://bitbucket.org/dowski/mercurial-version-info-plugin/downloads">Click here to download version 1.0</a>.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>My Take on Multiple Constructors</title>
      <link>http://blog.dowski.com/2010/03/17/my-take-on-multiple-constructors/</link>
      <pubDate>Wed, 17 Mar 2010 17:38:25 EDT</pubDate>
      <category><![CDATA[Python]]></category>
      <category><![CDATA[Software]]></category>
      <category><![CDATA[computing]]></category>
      <category><![CDATA[General]]></category>
      <guid>http://blog.dowski.com/?p=365</guid>
      <description>My Take on Multiple Constructors</description>
      <content:encoded><![CDATA[<div class="document">
<p>I noticed the same <a class="reference external" href="http://pythonconquerstheuniverse.wordpress.com/2010/03/17/multiple-constructors-in-a-python-class/">question on c.l.p that Steve Ferg responded to on his blog</a>.  I was feeling too lazy to respond to the thread earlier but I thought I'd throw my idea up on the ol' blog before wrapping up for the day.</p>
<p>I think this is a classic use-case for class methods. Here is my implementation.</p>
<pre class="literal-block">
class Vector(object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    &#64;classmethod
    def from_sequence(cls, sequence):
        return cls(*sequence)

    &#64;classmethod
    def from_vector(cls, vec):
        return cls(vec.x, vec.y, vec.z)

    def __repr__(self):
        return &quot;Vector(%s, %s, %s)&quot; % (self.x, self.y, self.z)

if __name__ == '__main__':
    print Vector(1,2,3)
    print Vector.from_sequence([4,5,6])
    print Vector.from_sequence((7,8,9))
    v = Vector(10, 11, 12)
    print Vector.from_vector(v);
</pre>
<p>Here is the output from running the script:</p>
<pre class="literal-block">
Vector(1, 2, 3)
Vector(4, 5, 6)
Vector(7, 8, 9)
Vector(10, 11, 12)
</pre>
<p>I like the classmethod route because it is obvious what the code is doing, it makes it easy to add new <tt class="docutils literal">from_\*</tt> methods and keeps the general <tt class="docutils literal">__init__</tt> method clean.</p>
<p>cw</p>
</div>
]]></content:encoded>
    </item>
  </channel>
</rss>
