Wednesday, March 26, 2014

Mike the Pythoneer...

A few weeks back my old Mac Mini got to the point where it was giving me the "gray screen of death" every 18 to 36 hours [1].  Replacing the RAM -- failing RAM being the most frequent cause of kernel panics -- didn't fix the problem.  I decided that six-and-a-half years was a good run, that I had outgrown the RAM size limit, that having a graphics chip too dumb to support acceleration for OpenGL wasn't good, and that having no OS upgrade path for the old machine was a bad thing.  So I got a new Mini.  It has not been an entirely painless process, largely because there have been a bunch of changes in the Apple development tools.

I have a couple of pieces of software that I use regularly that I wrote in Perl.  I'm entirely dependent on one of them, a note-taking application that also acts as the front-end for (sort of) organizing a whole collection of files of various types -- PDFs, images, old source code -- that is pretty static these days [2].  Another one, that is part of a package for drawing cartograms, is under off-and-on development.  Both were broken under the default Perl/Tcl/Tk that comes as a standard part of the new OS X, and required some effort to get running again.  To get the note-taking app running I ended up downloading and using ActiveState's Perl instead of the Apple default.  At one point in the past I had toyed with the idea rewriting the note-taker in Python (for other reasons) and had some code that tested all of the necessary GUI functionality; that old Python code ran on the new Mini with no problems using the Apple default installation.

Reading a variety of Internet things led me to (perhaps erroneously) conclude that: Apple is moving away from Perl and towards Python for scripting; Tkinter is a required part of the Python core, but Perl has no required GUI module; so Apple is more likely to keep the chain of Python/Tcl/Tk working in the future.  Suddenly, switching to Python seemed much more compelling than before.  I also came across Eric Raymond's old "Why Python?" article from the Linux Journal.  His experience seemed to match my own recollections of writing that little Python program related to the note-taker: I got over the "eeewww" thing about the use of white space to identify block structure fairly quickly, and I seemed to be writing useful non-toy code fairly quickly.

One of my favorite (and I use that word with some ambiguity) time-wasters on my computer is FreeCell.  Since Windows 95, Microsoft has always provided a simple version of the game as part of the standard distribution.  When I switched to a Mac at home several years ago, the lack of a simple free reasonably-attractive version of the game grated on me [3].  I ended up using a Javascript version in my browser, but recently that one began to act flaky, putting up placeholders instead of images for some of the cards.  "Two birds with one stone," I thought.  "Practice Python and get a version of FreeCell that looks and behaves like I want."

The good news is that with a couple of manuals open in browser tabs, writing the game went quickly.  Call it 15 hours total over three days to go from nothing to something that my fingers are almost comfortable with up and running.  And by nothing, I mean just that: no cardface images, no thoughts on data structure.  A blank slate.  Some of that time was doing small sorts of rewriting, when I would find an example that showed a better Python idiom.  The bad news comes in several parts:
  • There's a version of FreeCell that my fingers know just sitting there on the desktop now, begging to be "tested".
  • Feature creep is going to be an issue.  It should have undo.  It should have the ability remember the current layout and return to that.  It should have a built-in solver that works from any position.
  • It should run on my old Linux laptop.  It should run on my Android tablet.  It should run on my wife's iPhone (well, maybe that's a stretch).
So I guess I'm going to be a Pythoneer (I actually think "Pythonista" sounds better, but that's been preempted as the name of a commercial application).  Expect an occasional update on how things are going...


[1]  In the event of certain kernel panics, Mac OS X puts up a translucent overlay to block the display, along with a dialog box that says "You have to restart your machine" in several languages.  Until recently, I had no idea that such a thing even existed.  For the record, since it no longer has to support nearly as many processes, the old Mini has been up without a problem for more than three weeks.

[2]  At last count, a few hundred pages of notes and more than 100M of images, PDFs, etc.  As to why write my own when there are dozens of note-taking applications out there, let's just say that I'm an old geek and paranoid and don't like to have critical data stored in a proprietary file format.

[3]  I'm sure that all of the authors of the solitaire packages out there think their games are laid out attractively.  I just happen to disagree.

Tuesday, March 18, 2014

3D Printing

Seth Stevenson at Slate has a column about his disastrous attempts to run a 3D printer.  The picture to the left is one of his attempts.  His experience seems educational, given that the price of printers continues to fall.  Slate apparently gives Seth a bigger hobby budget than my wife gives me, since they bought him a printer.

The Solidoodle 4 looks like a really nice little hobby machine.  Steel frame and covers, compact footprint, relatively large working volume ( a cube eight inches on a side -- you can build relatively large things), ability to use either ABS or PLA plastic.  Billed as being driven over a USB connection by any of Windows, Linux, or a Mac.  With a retail price tag of $999, fully assembled (many low-cost 3D printers come as kits, with some degree of assembly required).

Seth's experience, though, demonstrates that's there more to 3D printing than just taking the gadget out of the packaging and firing it up.  Calibration, cleaning, temperature selection, little details like sometimes spraying the bed on which the object is printed with hair spray so the plastic adheres properly, putting up with the noise and stinks.  If the experiment had been more successful, there would have been the longer-term problems of maintaining an inventory of materials (ie, do you have enough red plastic on hand to make that spiffy Christmas tree ornament?).  The list of problems reminds me of homemade printed circuit boards.

You can make a printed circuit board at home in your garage or basement [1] in a matter of hours.  The results look like homemade PCBs.  OTOH, if you need to make PCBs infrequently, you can upload the computer files to a service bureau who will, at a cost of a couple dollars per square inch, make the board for you and mail it to your home.  You get a much higher quality result, at the cost of time (a couple of weeks is typical) and a bit more expense.  When I built the World's Most Sophisticated Whole-House Fan Controller™™ a few years ago, I had a service bureau make my boards, and was very happy with the entire experience [2].

There are a rapidly growing number of 3D printing service companies.  Generally speaking, they're going to have better printers than I could possibly afford -- unless I become a service company myself -- because they keep them busy; they already know things like the proper temperature setting for all of the materials they use; they have experience with the idiosyncrasies of their equipment; and they keep suitable stocks of material on hand.  I would be very interested in reading a column where Seth tries that route, as well.  Certainly for time being, any 3D printing experiments I conduct will be done through a service bureau.


[1] Given the nature of the chemicals and the stains they can make, don't try this in your kitchen.  Trust me on this.

[2] Some of that might be that I ordered two copies but they sent me four for the agreed-upon price.  Since I eventually used three of the boards (due to operator error and a voltage surge), that turned out very well.

Monday, March 10, 2014

TABOR Lawsuit to Procede?

You know you're a policy wonk of some sort when you find the following of great interest: last Friday the 10th Circuit US Court of Appeals ruled [PDF] that the Colorado TABOR lawsuit could go forward.  No word yet on whether the defendants in the case will appeal to the SCOTUS or not.  For those to whom this might have passing interest...

TABOR, the Taxpayers Bill of Rights, is an amendment to the Colorado state constitution passed in 1992 which imposed two main restrictions on state and local governments across the state.  First, it restricted the rate at which government spending could increase year-over-year to the sum of population growth plus inflation, unless increases beyond that were approved by a vote of the people in the jurisdiction.  Excess revenue beyond what could be spent had to be refunded.  Second, it required that new taxes, or increases to existing tax rates, must also be approved by a vote of the people.  The effect was to impose direct-democracy restrictions on the ability of elected government officials to set tax rates and spending levels.

Whether by design or coincidence, the most serious consequences of the TABOR restrictions come into play during recessions.  Following the recession of 2001, the Colorado state budget was in sufficiently dire straits that the legislature put Referendum C on the ballot in 2005.  Ref C provided a five-year time-out on TABOR refunds, and set a new floor from which future spending increases would be measured.  Ref C was supported by then-governor Bill Owens; many people believe that support cost Mr. Owens a bright future on the Republican national stage.  The recession of 2007-09 also put large pressures on the state budget.  In response to the pressures brought on by recessions, the Colorado legislature has resorted to a certain amount of accounting trickery: the Colorado Opportunity Fund shields a considerable part of state higher education funding from TABOR, as did a rewrite of the unemployment insurance statutes to replace the word "tax" with "premium" wherever it appeared.

In 2011, a group of current and former members of the state General Assembly filed suit in federal court challenging TABOR on the grounds that by removing control of taxes and spending levels from the legislature, Coloradans were denied the "Republican Form of Government" guaranteed by the US Constitution.  To this point, the argument has been whether the plaintiffs have standing to sue, and whether the entire matter is non-justiciable due to the political question doctrine.  In 2012, the District Court ruled that (a) plaintiffs had standing and (b) this case is sufficiently different from others settled in the past that the political-question doctrine did not apply.  Last Friday, the Appeals Court agreed, and remanded the case to the District Court for further proceedings.

Opinions. Bear in mind that IANAL (although I had to pretend to be one at time while I was working for the state legislature), nor without bias in this matter:
  • To this point, the defense has been remarkably lazy.  Their argument consists basically of "state legislators don't get standing just because they lose a vote" and "the SCOTUS says Guarantee Clause matters are non-justiciable."  In fact, the SCOTUS decisions are much more nuanced than that.  Where the defense has ignored the details entirely, plaintiffs appear to have done their homework on those nuances, building arguments that all of the SCOTUS conditions for standing and justiciability are satisfied.  Thus far, the District and Appeals Courts have concurred.
  • In light of this, I expect the defendants to appeal to the SCOTUS.  I say that because I expect that the defense has been just as lazy in preparing arguments in the event that the case goes forward.  Better odds for success at this point for getting a conservative SCOTUS -- and politically, TABOR is a darling of small-government conservatives -- to say the Appeals Court misinterpreted things and toss the whole case.
  • Should the case go forward, the defense argument will largely be "the legislature gets to split the pie up however they want, subject to other restrictions that aren't being challenged in this suit -- they just don't get to set the size of the pie."  And that such a restriction doesn't impose an undue burden, since they can always ask the voters to make the pie bigger (although in Colorado, making such a request requires a two-thirds super-majority in each chamber).
  • Should the case go forward, and the defendants make that argument, they will lose -- setting the size of the pie will be defined to be a core legislative function.  And lose again on appeal.  And then win in the SCOTUS, assuming the current make-up.

Saturday, March 1, 2014

A Handset? Really?

News stories today reported that President Obama spent 90 minutes on the phone with Russian President Putin, warning him about the consequences of taking military action in Ukraine.  This is the picture that accompanied one such story.  Seriously, dude, do you want me to believe that you're dumb enough to spend 90 minutes on a important diplomatic call holding a handset?

Over the course of my professional career(s), I spent a lot of time on long-duration phone calls.  I will guarantee that if you do so, at some point in the call there comes a moment when you need both hands free.  Maybe you have to type something into the computer.  Maybe you need to pin the piece of paper down while you jot a note.  Maybe you just need both hands free because you can't say "Vladimir, you have no idea who you are f*cking with!" without appropriate hand waving [1].  The moment comes, and you can't do the proper thing if one hand is busy holding a handset up to your ear.

Before making/taking a call that was supposed to last that long, I had my headset on.  I still wear a headset even if I'm just calling my Mom, let alone making a business call.  And the headset is no doubt behind the times.  If I had the NSA at my beck and call, you can d*mned well be sure that I would have the world's absolute best echo cancelers in place, and I'm talking in the open air, hands waving the whole time, without benefit of a headset.

Let's get with the times.  A handset on a coiled cord is not the impression we're trying to make.


[1] Just so you remember why I couldn't get elected dog catcher, let alone something that requires even more diplomacy :^)

Photo credit: Official White House photo by Pete Souza