Move over TextMate. MacVim is the new kid in town!

For years I've been rather proud of the fact that I'm a total polyglot when it
comes to editors. I'm comfortable on both sides of the fence, using Emacs, Vi,
TextMate, EditPlus, or even the venerable /bin/ed whenever that makes sense.

But for the first time in a long time, my current (awesome! :)) job at Blue State Digital has given me the opportunity to
branch out and do quite a bit of real software development.
I first encountered TextMate shortly after I came to OSX. It's a great editor,
and I have a tremendous amount of respect for Alan Odegard of Macromates
software. He has just about single handedly created not only an amazing
editor, but a vibrant and loyal community around his program, and he's to be
commended for that.
I would have remained happy in TextMate land, but for the fact that my most
recent job has me going back to where it all started for me - server side UNIX,
Linux to be exact.
So, I editing files on my Mac using Expandrive to remotely mount them, but
quite frankly that's a pain in the neck I just don't need to deal with.
With Vim, I can memorize one set of keystrokes for everywhere I might need to
be.
And with MacVim, I get a nicely streamlined, beautifully Aqua-fied interface,
with all the creature comforts TextMate provides and more.
What's more, there are a number of folks making the same transition, so there
are some excellent articles and websites out there to ease the transition like
the excellent VimCasts series of Vim tutorial screen
casts. They cover everything from the basics to some fairly advanced tips and
tricks on more complex Vim modes and integrations, and is written by a TextMate
to Vim switcher.
Right now I'm writing this post on the excellent
VimRePress plugin for
Vim that allows you to author and manage your Wordpress blog right from within
the editor! Very sweet :)
So, it's a brave new world, and I'm excited by the opportunity to get
really good at Vim so I can push my editing productivity through the roof
:)

Why Apple's Mac App Store will be good for the Mac

When Apple said they were introducing an "App Store" to OSX a-la the iPhone, iPad, etc. there was much ranting and foaming at the mouth...Many geeks proclaimed the death of Mac OS X as we know it. "Apple is iPhone-izing the Mac!" they cried.

They're largely wrong, at least in all the important ways.

Here are the salient points:

  • Discovery - people are *far* more likely to purchase things that are available from a single, readily accessible source. Having a veritable floatilla of awesome software that's discoverable right from the Apple menu of every Mac means that if you're a publisher, people are FAR more likely to try your software. I myself found a free copy of Autodesk Sketchpad in the app store that I am very much enjoying. I might end up buying the commercial product as a result - possibly through the app store! (See caveats below for why I might choose the shrink wrapped version.)

  • Ease of installation - just like on the iPhone and iPad, you click "Buy" or "Install" and *BOOM* it's on your machine, happily bouncing in your dock. For non technical people, this is a godsend. They do not want to know about .dmg files, dragging apps to the Applications folder, or the like. Yes, I know, this is VASTLY easier than the folks in the Windows world have it with their highly complex installers, but even still.

  • One Stop Shopping for updates - Sure, lots of devs these days are bundling some kind of update mechanism into their apps, but this is once again - seamless and easy to use for non technical people.

Of course, every silver lining has a cloud attached, so there are a few down sides:

  • Inflexible upgrade path - Apple has imposed rules around publishers app store offerings, I don't know all the details, but I do know that publishers are not happy. They want total control of how they monetize the sale of upgrades for their customers, and to a certain extent I can't blame them. Over all I think the net winner here is the consumer, so we'll see how many publishers sign up and grudgingly cope with the new rules.

  • Restrictive rules about permitted content - Nothing sexy, nothing violent, no Java or Rosetta, just like the IOS app store.

From my perspective, people who object to the app store on OSX are on shaky ground, because unlike the IOS world where the app store is the ONLY way to get apps, the app store on OSX isn't. You can still install apps the old fashioned way, and Apple has given no indocation that they intend to do this now or at any time in the future. I don't think it's in their best interest to do this, and I think people who are predicting imminent doom really need to get their collective head checked.

Then again, geeks do have a propensity for hysterics.

To sum up, I think everyone (publishers, consumers, and the wider Mac community) has everything to gain and nothing to lose from the app store, and I for one welcome the addition.

Don't buy early access (MEAP) books from Manning Press.

I hate to write a negative blog post about a tech publisher's ebooks program, but I'm afraid they've driven me to it...

[May 2011 Update: Manning has changed things and you can now download any books you've ever bought from them anytime. Yay! My other criticisms still stand, but this is an improvement!]

Firstly, easily half of the MEAP titles I've purchased never make it to publication, after languishing for months and months while I get E-mails about the authors being hard at work on the book.

Not that I don't sympathize, writing a book is from what I understand Really Hard, but as a consumer if I've signed up to buy something, I expect a completed product to come out the other end. To be fair, Manning does offer either a refund or an exchange plus a bonus free e-book, but most of the truly hot topics that I found interesting were MEAP books again, so the cycle repeats.

Secondly, Manning uses the Yahoo Store for their ebook delivery. Wow, what a nightmare. You get n days to download your book once they send you the email, and then POOOF your purchase goes off into the ether. Compare and contrast with O'Reilly and Associates and the Pragmatic Programmers (two publishing houses I can't recommend enthusiastically enough.) where you can re-download your purchases anytime, for *life*.

If you buy early access titles from either of these publishers, you are not chained to your email for fear that the ticking time bomb of your download notice will expire when you're not looking.

In general, I think Manning really needs to take a long, hard look at its store front user experience. I'm not saying I'll never buy a title from them again, but I am saying it's a HECK of a lot less likely that I will, and I'll always choose pragprog or O'Reilly if I have a choice..

Why Many Hard Core Science Fiction / Fantasy Fans Hate Harry Potter

So, I finally did it. After a nearly non stop marathon reading of the last three books in the series (I wanted to read all the books before I saw the movies, and I'm very glad I did this. As always, the books have way more depth.), I've come to the following conclusions...


Many hard core science fiction and fantasy fans dislike the series, quite simply, because it's not written for us.

I happen to quite like the series, but in order to enjoy it as I have I found it necessary to keep my fanboy hat firmly in its place the entire time.

I could poke a thousand holes in the series, but what it all comes down to is this - it's a totally whimsical universe, devoid of the kind of carefully construed logical frameworks that hard core fantasy and scifi fans clamor for.

Let's take a look at magic just as a for instance. In the Potter-verse, spells are formulaic incantations that produce ambiguous results. Compare and contrast this with something like Jim Butcher's Dresden files, where things like the laws of physics come heavily into play.

In the end, the Harry Potter series isn't primarily about magic, although wizards and witches fill the pages of the book, it's about good (Harry) in the never ending struggle against evil, and the terrible price that those who stand up against evil must pay.

In my humble opinion though, it's a heck of a ride. Very entertaining from start to finish, and in the end analysis couldn't all of us do with a bit of an escape into whimsy once in a while anyway?

While at first blush the series appears to be young adult reading, good only for kids too young to be exposed to the evils of the world, and the first books are indeed very light hearted and very much fairy tale like in nature, but as the series progresses it becomes much, MUCH darker. Evil and its outcome is depicted in much sharper contrast, and death looms around every corner.

I would encourage any hard core fantasy fan who read the first book, said "meh" and walked away to give it another try. Look at it from a different perspective, and just try to enjoy the story for what it is. In the end I predict you will not be disappointed.

Managing crontabs with Git

April 2012 Update: Nowadays we useCheffrom Opscode solutions to manage our crontabs, and just about everything else in our enterprise infrastructure. It rocks :)

Time and time again over the years I've dealt with the same problem - who took a random pot shot at some critical user's crontab file and deleted things without asking?


All of a sudden, someone realizes that some function that's supposed to run every so often has stopped, and in fact hasn't run in weeks. You sniff around - nope, no errors in the logs, in fact no logs at all!

Then you look at the crontab for the user in question and realize that the lines invoking the script that used to be there have either been deleted or commented out. What the? Who did this, and why?

Git to the rescue! With the help of a simple Bourne Shell script, you can keep your crontab managed so you'll not just be able to see who changed what and when, but if you have the Git hook installed to send mail on commits, you can be notified of those changes in real time. Pretty cool eh? :)

Since crontab has no built in security precautions other than requiring you to BE the user whose crontab you're submitting, we can't lock people not using this script out, but if you tell everyone that changes they make outside of the script may be summarily ignored and overwritten (and put something to that effect in the comment block at the top of your crontab) you should be in good shape. The script will compare what's in Git with what's currently installed in cron, and if there are discrepancies it will give you a chance to cleanly exit and resolve them, or allow you to ignore them and roll forward with editing and submitting what's in Git.

Here's the script. It assumes you're running as your regular user and have sudo privs to the user whose crontab you wish to edit. It also assumes you've created a Git repository called system_cron.git

To set it up, just edit reponame and gitrepo to appropriate values for your site and copy the script to somewhere folks can access it in their PATH.

To use it, just invoke it with the user whose crontab you want to edit - for example:edit_crontab.sh build

#!/bin/sh

export tmpdir="/tmp/crontab_$$"

if [ $# -lt 1 ]; then
    echo "Usage: $0 "
    exit 1;
fi

if [ -z "$EDITOR" ]; then
    echo "No editor found.  Using vim."
    export EDITOR="/usr/bin/vim"
fi

crontab_user=$1

crontab_file="`uname -n`-$crontab_user.crontab"
echo "crontab_file=$crontab_file"

git clone /home/git/system_cron.git $tmpdir
cd $tmpdir

sudo -u $crontab_user crontab -l > currcrontab_$$

if [ $? -ne 0 ]; then
    echo "sudo to user $crontab_user failed! Do you have sudo privs?"
    exit 1;
fi

diff=`diff currcrontab_$$ $crontab_file`

if [ $? -ne 0 ]; then
    echo "Currently running crontab for $crontab_user differs from Git!"
    echo "Here are the differences:"
    echo $diff
    echo
    echo -n "Continue editing / submitting what's in Git? (Y/n): "
    read yesorno
    if [ "$yesorno" != "Y" ]; then
        echo "Very good.  Exiting."
        exit 1;
    fi
fi

$EDITOR $crontab_file

echo "Here are your changes:"
git diff --exit-code $crontab_file
if [ $? -eq 0 ]; then
    echo "No changes made.  Not submitting anything."
    exit 1;
fi

echo -n "Submit these changes to Git and crontab? (Y/n): "
read yesorno
if [ "$yesorno" != "Y" ]; then
    echo "Your changes are in $tmpdir/system_cron/$crontab_file."
    echo "Please clean up this directory when you're done with it."
    exit 1;
else
    git commit $crontab_file
    if [ $? -ne 0 ]; then
        echo "There was a problem committing your crontab to git!"
        exit 1;
    fi
    git push origin master
    if [ $? -ne 0 ]; then
        echo "There was a problem pushing your crontab to git!"
        exit 1;
    fi

    # if we made it this far. We're all good.  Install that puppy!

    echo "Installing your crontab."
    sudo -u $crontab_user crontab $crontab_file
    if [ $? -ne 0 ]; then
        echo "ERROR! Your changes were NOT installed! Something went wrong."
        exit 1;
    fi
fi

echo "Cleaning up tmp directory..."
#rm -rf $tmpdir

Face, meet Mr. Concrete wall.

As I mentioned here previously, my last big job search after I got laid off from MIT was decidedly Not Fun...


I ended up taking a job I would normally never take, because I felt utterly backed up against a wall by the economy, increasing competition in the tech sector, and the big skeleton rattling around in my closet - the lack of a degree.

I got turned down by 2 or 3 prospective employers because of this, which is something that hasn't happened to me for a very long time.

So, when I took said job, I steeled myself for the worst and called my old school, Worcester State College.

The result was not at all what I was expecting. I still only need two courses to get my bachelors degree!

I got all the paperwork filled out, jumped through all the necessary hoops and found out that I (still) need a science, and a science with a lab in order to graduate.

That information in hand, I went casting around for a science course I could take. Not easy, many of them required calculus, and those that didn't hab lab periods smack dab in the middle of my work day.

I found one course, Astronomy, that only claimed to require College Algebra and was taught Tuesday and Thursday evenings. So, I leapt.

BIG mistake.

The course started a week and a half ago. Since that time, I have poured ~30 hours and a number of sleepless nights into it, and unfortunately I have to admit that there is eactly zero chance of my passing this course. No amount of effort, lack of sleep, or heroics short of quitting my job (Freaking unlikely since I'm INCREDIBLY happy where I am now. I escaped from Windows enterprise hell and am working for an amazing company, Blue State Digital.) will save me.

I had been expecting the math to kick my ass, but in the end analyais, I could handle that just fine! There wasn't a single bit of algebraic manipulation I couldn't get past with a little work and some Google thrown in for good measure.

It was the formulas! Crazy, INSANE formulas crawling across the page and eating my poor addled brain like some kind of scene out of Dawn of the Dead.

Fev / Fem = ( G Mv Me / Rev2 ) / ( G Mm Me / Rem2)

I have to withdraw from the battlefiend this time - I've lost the skirmish, but I am bound and determined to win the war!

I'll take some time to recover, take a fresh look at the problem, and talk to my academic advisor to see if I can apply some 'life credit' or something, or at the very least not bludgeon myself senseless over my lack of higher math, so I can finish up the silly degree and get on with my life!

Dear Amazon and Penguin - Why Can't You Kids Play Nice?

I received a piece of E-mail from Amazon a few days back apologizing about the fact that my pre-order of the latest Jim Butcher Dresden Files novel had been canceled, offering me a really cheap price on the print edition.

A couple of days and a great deal of "WTF?" later (That's What The French, this being a family friendly blog and all :) I trotted on over to Jim's website and found an explanation.

Essentially, Amazon and Penguin are bickering over the sale price of the book.

I would *happily* pay full hard cover list for the Kindle edition of the newest Dresden novel.  Jim Butcher is my favorite urban fantasy author, and when these books come out I get them the very first *instant* I can and then become some sort of literary crack fiend, obsessively trying to find excuses to crawl off into a corner and page flip.

So I guess I'll run down to Porter Square Books and buy the dead tree edition, but this is what I bought my Kindle for!

On the up side, I've been feeling guilty about not supporting my local independent book seller of late, I guess this is an opportunity to put my money where my mouth is and pony up!

Windows Scripting - a VBScript Survival Guide

1. Introduction

If you're new to the world of Windows scripting as I am, the array of acronyms, technologies and access methodologies that you need to traverse in order to get anything done can range from bewildering on a good day to utterly derangement inducing on a bad one.


I've been doing installer and deployment development at a Windows enterprise software company for the last year or so, and after decades spent comfortably swaddled in the familiarity of the UNIX and Java world, I definitely found myself feeling shell shocked, disoriented, and frustrated at the lack of any sort of cohesive resources to aid me in my quest.

Microsoft has been doing its best to pretend VBScript doesn't exist - touting Windows PowerShell as the way and the light.  PowerShell is indeed an awesome tool, and I for one would happily consign VBScript to the briny deeps never to be thought of again were it not for one little problem - the vast majority of Windows systems running in the wild don't have PowerShell installed.   Until a new day dawns and PowerShell is on *every single* Windows box our company wants to install its software on, VBScript remains the lowest common denominator for system scripting and thus the only real game in town for install time scripting.

The goal of this article is not to teach you VBScript, sadly, there are essentially no books and precious few online resources dedicated to this topic online.  I will offer pointers to those that I have found most useful, and some collected wisdom on how to best make use of them, as well as some pitfalls I encountered which with any luck I can help you avoid.

That said, let's get started.

2. Learning VBScript

This will mostly be a collection of pointers to resources with a smidgen of commentary on each to get you moving in the right direction.

A. Books

  • Windows XP Annoyances - This book should really be titled "Windows For Geeks" :) it is the single most useful book I have ever encountered for someone trying to make the transition from another environment and isn't content to just grit their teeth and groan at all the annoying defaults Windows ships with.  In addition to an incredible amount of depth around the Windows registry and how you can wield it to suit your needs, this book also has one of the best simple introductions to system scripting with VBScript I've seen.  Two thumbs up. Note that this is the 1997 edition, and this book now comes in Windows Vista and Windows 7 flavors which I haven't read, but can only assume are equally awesome.

  • visualbasicscript.com - This is far and away the single best VBScript resources on the intertubes.  The folks in these forums are experts, and will help you solve your problem virtually every time.  I can't say enough about the incredible community here.  Nine out of ten times, if I go looking somewhere else first I end up coming back here and wishing I hadn't wasted my time elsewhere first :)

  • Microsoft Script Center / The Scripting Guys - The second most useful scripting site on the web.  The Scripts Repository and "Scripting Guys" MSDN blog are an incredible resource for system scripters.  While the emphasis has definitely shifted towards PowerShell these days (and rightfully so) most of the techniques discussed can be leveraged in VBScript once you get cozy with the syntactic differences between the two (very different) languages.

  • MSDN Windows Scripting Technologies - This page covers things like the Windows Scripting Host, the core technology that actually allows you to perform useful work in VBScript.  While somewhat more complete than the VBScript reference itself, it's no great shakes.  You'll find yourself learning much more from examples published elsewhere, but for the occasional API lookup or clarification it can be useful.

  • MSDN VBscript Reference - You'll note this site's position well down the list.  It's there for a reason.  The documentation provided here is very sketchy and frankly incredibly misleading in places.  The authors seem to have weaseled out of writing a more complete documentation set by making a vacuous assertion along the lines of "Well, it's just like regular Visual Basic, with a few minor differences".  This leaves people like myself who have never had the need to touch a fully fledged VB implementation out in the cold, feeling like second class citizens.  While these pages can be useful for occasional clarification on some obscure language feature, those seeking to understand how the language works in the large should definitely look elsewhere.

  • Windows Script Debugging Microsoft KB Article - This article will get you started interactively debugging your scripts using Visual Studio.  Don't bother with the Windows Script Debugger, Visual Studio Express is free and much better :)

  • W3Schools VBScript Tutorial/Reference - This page is definitely rather Web-centric, focusing on VBScript in classic ASP programming, however, the core language and some of the techniques are the same.  In many cases this is a better reference than the MSDN one, and the tutorial lets you work through the examples online in a web browser which is cool.

3. Debugging

Who turned the lights out?

If you find that some script you've inherited is not working, but you get exactly zero output or errors, look for the telltale On Error Goto 0 or On Error Resume Next statements. These basically disable VBScript's inherent error handling functionality and cause your script to silently ignore errors. Helpful, eh?

Never run while blind folded.

Know how you're invoking your VBScript. If you're calling your script from an installer or some such executable, you're likely using Microsoft's cscript tool. which doesn't do a very good job of always displaying handy things like syntax or run time errors. Try running your script with wscript instead for debugging purposes. Heretofore mysterious behavior may become clear :)

That's all!

Hopefully this post will prove useful to some poor soul, manacled in place, suffering through their own personal Windows induced hell. Even if it isn't, these tidbits have been rattling around in my head since I escaped (I now work for Blue State Digital, we're a LAMPs shop (Linux, Apache, MySQL, PHP) and I hope to never be trapped in Windows enterprise limbo again!

Yay and Boo all in one breath: The Amazon Kindle Development Kit (KDK)

Amazon has finally come out with the details around their Kindle Development Kit (KDK) you can read the details here.


This is absolutely great news for the J2ME development community, this is a mainstream device from a big name manufacturer where they can ply their existing skill set or port their existing apps.

However, I'm a bit disappointed. I realize that the Kindle is meant as a light weight device, but I have always found J2ME's I/O model to be rather cripplingly baroque in so many ways.

Looking over Amazon's APIDoc however, it does seem like they've built their own infrastructure atop J2ME, so perhaps they've made it easier and more pleasant to code for.

I'm torn between wanting to get in on the ground floor and not wanting to invest the time and energy in learning a technology (J2ME) which I feel has gone way past its expiry date.

Anyway, we'll see but I'll definitely be keeping a close eye on this one.

3 Things Microsoft Should Do for Release Engineers

For the last year or so I've been working at a 100% Windows based enterprise development shop.   They ship a fairly large and complex application for health insurance providers, which draws on many of the core technologies in the Microsoft enterprise stable.


This post highlights a few things that make working in this environment a whole lot more onerous than it needs to be in my opinion, so let's get started.

1. Installers

The Windows installation landscape has been a bleak one indeed for a very long time.  Tools like Installshield with their own proprietary languages like InstallScript make installer development unnecessarily painful and baroque.  Is there really any reason I should be programming in a language with no real data structures to speak of in 2010?  Even flow of control is handled in a way I can only describe as baroque.  There are methods/functions, but the main body of your installer's code has to jump around everywhere using goto.  What a mess.

There is hope on this front, in the form of WiX, the Windows Installer XML toolkit, which allows developers to iteratively build and design their installer along with the regular development process.  Right now however the learning curve seems incredibly steep.  Perhaps Visual Studio could generate a template WiX project to get people started?

I'd also love to see some thought given to simplifying the deployment model for things like COM+ - which feels to me like a magic black box with myriad buttons and levers, all of which are a bear to get right at install time.

2. Builds/SCM

MSBuild needs to have dramatically better documentation, and to a lesser extent so does TFS  - they get the broad bits right - everything you could want to do through the UI is covered, but process automation using scripting / command line tools gets substantially murkier.

In the 'credit where credit is due' department, the TFS team has been incredibly responsive on their forums, and that's what's helped us get by so far, but there's no substitute for first rate docs.

3. Infrastructure Scripting

As of right now, there are a thousand different interfaces to accomplish the same thing, and for complex configuration tasks like configuring IIS at install time, the possibilities can be dizzying.  I would like to see Microsoft choose one mechanism for run-time system/software configuration and document the heck out of it.

Kudos to the PowerShell team and The Scripting Guys for making great strides in this area.  PowerShell is a really nice environment for all kinds of scripting, and I look forward to the day when we can eliminate VBScript from our installers entirely in its favor, but we're not there yet sadly.  The object pipeline is one of the more powerful concepts in the modern scripting milieu, and I think Apple and the UNIX world could take a page from PowerShell's book in this regard.

Being a release engineer in a Windows world presents some very interesting and different challenges for someone coming from a UNIX background like myself, and with a little bit of emphasis and effort on Microsoft's part, surmounting them could be a whole lot less painful.