the further adventures of

Mike Pirnat

a leaf on the wind

« Previous Page Next Page »

Introducing "How Old is My Kid?"

Between books, magazines, websites, and your friendly neighborhood pediatrician, there are tons of resources to help guide new parents through the development of their new bundles of joy. You can track your kiddo's progress toward various typical milestones and even predict periods of increased fussiness and sleep regression, as long as you know how many days, weeks, or months old your little darling is. But with a new kid in the house, you're sleep deprived out of your mind and barely know which way is up, and it's not like any of us are really used to measuring age at that level of granularity.

Once upon a time I came up with a solution that worked for me--I wrote a little program that would drop an RSS feed every day with my daughter's age in it. I got a couple of suggestions that it would make a useful web service, and though I agreed, it took me a long time to finally get around to it.

Lucky for you, the wait is over! is live and ready to help you keep track of exactly how long your munchkin has been around. Just plug in your kid's name and birthdate, hit the button, and optionally subscribe to the RSS feed so that you'll get daily updates--and then it's a quick trip to being Parent of the Year.

I hope you enjoy it--please let me know what you think!

(Aside: I'm very happily posting this live from the stage at PyCon--it's been a great conference and I can't recommend it enough!)

Read and Post Comments

Building Pycrypto on Snow Leopard and Non-Apple Python

I wanted to use PyCrypto on a personal project, which means that even though I will eventually deploy to Linux (where PyCrypto is super-easy to come by), I first needed to get it set up on my development machines, which are all currently Macs running Snow Leopard. This takes a bit of finagling--including some steps that I didn't see listed in (m)any other guides--so I figured it would be worth sharing (or at least memorializing here so I can find it again).

You may be tempted to just easy_install PyCrypto, or manually grab the source and try building from that. That's likely to get you a giant wall of compiler output that includes this lovely gem:

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
Please check your Xcode installation

But I already installed Xcode! you cry. What gives?!

Here's Trick Number One: install Mac OS X 10.4 support when installing Xcode. I hadn't, so I got to reinstall Xcode. Naturally, Apple knows better than you do, and won't let you install without the "Essentials" package, so go find something else to do while 8+ GB of stuff you already installed gets done all over again.

Okay, you think, now I'm set. This is going to be great! You pop back into the terminal and retry the build:

$ python build
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash.MD2' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/MD2.c -o build/temp.macosx-10.3-fat-2.6/src/MD2.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from src/MD2.c:31:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from src/MD2.c:31:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/FI/FIs1Mi6LFUeDQ-LNLRg+JE+++TI/-Tmp-//ccVhrG5I.out
error: command 'gcc' failed with exit status 1

Now you're confused. None of the existing "how to install PyCrypto" cheat sheets that you found had anything to say about this flavor of failure.

Upon reflection--and much Googling--you realize that this is your punishment for thinking you know better than Apple. You thought you were so clever when you installed a more current Python than what Apple ships, and you thought you were doing the right thing by going to to get the latest, greatest stuff. (Well, for some value of "latest, greatest", because like me you probably did this ages ago and never changed it once it was working.)

The problem is that Snow Leopard wants to use gcc-4.2 by default, but your Python wants gcc-4.0 instead.

Trick Number Two is that you need to tell it to do the right damn thing:

export CC=/usr/bin/gcc-4.0 
export CXX=/usr/bin/g++-4.0 

You can then python build and python install to your heart's content.

This second trick may be moot if your Mac Python binary is new enough--it looks like it got addressed in late 2009. Laziness, however, is one of the Three Virtues, and I find myself possessed of an abundance of it, so I have pretty much forgotten about keeping my Python current once I had something 2.6ish that was "good enough for now."

Now you know. And knowing is half the battle.

Read and Post Comments

Speaking at PyCon 2011

PyCon 2011, Atlanta, March 9-17

My PyCon talk--Exhibition of Atrocity1--was accepted and will be part of the "Extreme PyCon" track! This is great news for my ego, but lousy news for my sleep schedule as it's one more sharp object to juggle. In the end, I hope that it's great news for you--if it's even half the talk I want it to be, it should be a lot of fun and valuable too.

I'm going to be spending the coming month tracking down examples of my sins against Python from the past eleven years. The vast majority of these will be from my day job, and will have to be vetted and possibly altered to make sure I don't give away any "secret sauce" of our IP. Variable names may be changed to protect the innocent.

As a safeguard against being too-redacted by TPTB, I'd like to invite you to suggest things you've seen in the open source world that are particularly gnarly or horrific that would be worth highlighting. Maybe a standard library module that reminded you too much of looking C'thulu in the face, or that brilliantly evil hack in your favorite project that's both epic and blood-curdling. I don't get to peer into the deep innards of much of the community's code very often, so I'd greatly appreciate a little extra perspective. Note that I'm not looking to slam any projects or developers--this is a safe place where I'd like to be able to say "OMGWTF!" about code with a healthy smile and without any ego getting in the way.

Most importantly, though, my plea to you is this: if, in any way, I have ever wronged you with code, let me know! I've worked up the nerve to suggest this talk, so you won't hurt my feelings. Let me have it with both barrels; we will all be better for it.

I'm excited to be part of what is shaping up to be the most epic PyCon in recent memory. There are so many great-looking talks that I'm scared of actually seeing the schedule and trying to sort out what I'm going to be attending. Normally the hardest part of PyCon is that there's just too much awesome stuff to see or do it all, but this year really takes the cake--even choosing tutorial sessions was agony!

Anyway, I look forward to seeing you (and spending half an hour embarassing myself) at PyCon 2011.

  1. With apologies to Gary Numan and Joy Division.  

Read and Post Comments

Reflections on CodeMash 2011

I spent most of last week at CodeMash in Sandusky, Ohio. I felt a little foolhardy setting out on the drive during the worst part of a snowstorm, but there was no way I wanted to be late and miss out on anything.

Now in its fifth year, CodeMash is a language-agnostic, polyglot-friendly software development conference that aims to expand participants' minds by opening them to new platforms and technologies that they hadn't been exposed to. There's a lot of .NET and Java, a fair amount of Ruby, a mix of web and desktop and mobile (iOS, Android, and even Windows Phone 7 were well-represented), and if you look hard enough there are even some Python talks. There seemed to be a lot of interest in Scala as well. All are welcome--the official anti-discrimination statement even covers your choice OS and text editor!

CodeMash features a "Precompiler" day much like the PyCon tutorial days, with four-hour sessions that allow deep dives and intense focus.

In the morning, I attended the introductory iOS development session, a fast-paced "type-along" that walks through the creation of a simple iPhone app and some basic tricks. I've been a Mac user for years, but since I'm mostly focused on Python and the web, I've never even cracked open Xcode, nor really spent more than a few moments glancing at Objective C code, so this was a pretty rewarding experience for me. I will say, however, that spending four hours in Objective C makes me really appreciate exactly how much Python has spoiled me--Python is so clean and readable, and Objective C is a twisted nightmare by comparison. (You have to wrap square brackets around method calls? Seriously??) But the session was fun, so I had a great time and learned a lot.

I spent the afternoon in Jim Weirich's excellent "Git Immersion" session. The first hour was a Powerpoint-driven thought experiment that began with the question, "How would you build a version control system?" Starting with the idea of taking a snapshot/backup of the codebase, Jim carefully layered on one concept after another, gradually and organically building up the pieces until we had arrived at a beautiful, powerful, and elegant system, and suddenly we understood git, in a natural, logical, "of course that's how it should be" way. Really a profound moment. Even rebase made sense! The next portion of the class was a self-paced series of exercises that I enjoyed working through, occasionally sharing my lightbulb moments with my neighbors. Lots of "aha!" and "oh, that's cool" murmurs. The session wrapped up with a quick discussion of some of the more advanced features like bisect and reflog, and I walked out feeling great, really turned on and excited to use this powerful tool.

The next couple of days were, quite honestly, a little bit of a letdown after the engrossing Precompiler activities. I got the feeling that there was the same content-to-talk ratio regardless of the length of the talk. Then again, it's possible that I just picked a bunch of losers, which seems consistent with my experiences picking checkout lines. The keynotes were kind of lackluster as well, though apparently I missed the good one while escaping the long lunch line for other arrangements.

The stand-out talks that I attended were Jon Stahl's "Agile From the Top Down" (about how your senior management should be doing Agile too), Joe Nuxoll's "Rules for Good UX Design" (which ought to be required if you're building, well, anything), Richard Harding's "Celery: Harnessing the Power of RabbitMQ" (a welcome burst of manic energy and humor at the end of a draining three days of learning), and Gary Bernhardt's "A Modern Open Source Development Environment" (Gary's talks are always a treat).

The "Mobile Smackdown" session was a fun idea as well; three devs--representing iPhone, Windows Phone 7, and Android--gave competetive walkthroughs of building a basic Twitter client in 15 minutes. While the iPhone's Objective C code was clearly the ugliest looking code, I noted with some interest that it looked like the Windows Phone 7 dev hardcoded some things that the iPhone didn't, and that the Android guy didn't quite get done in time. (In fairness to the iPhone, The giant pile of Windows Phone 7 XML also made me want to puke pretty badly.) Plans are already afoot for holding a three-way simultaneous coding duel in the plenary space next year.

CodeMash also seems to be a pretty swell place for social interaction--open spaces were buzzing, folks were meeting, and (I hear) that parties were pretty crazy. I had great fun playing mini-golf and Guitar Hero with coworkers. I mostly stayed away from the late-night party scene, opting on Tuesday night to write show notes for From Python Import Podcast and on Wednesday and Thursday to take in the band and awesome jam session. We were graced by the awesome presence of The Womack Family Band, who did a phenomenal job of not only kicking ass, but incorporating musically-oriented conferencegoers into the act--witness Matt "Snowdog" Gibberman playing drums on "Back in the USSR"! I was pretty happy to pick up their CD and get autographs.

Overall, CodeMash was great, well worth the treacherous, snowy drive, and though I wish I could have done even more Precompiler sessions, I'm already looking forward to next year.

Read and Post Comments

Validate (or Exterminate) My PyCon Talk

Let me tell you a secret: I'm terrified that my PyCon talk proposal hasn't been rejected yet.

It's not the idea of public speaking--I've spoken twice before at PyCon (more if you count lightning talks and the testing BoF), as well as presenting fairly regularly for our local user group and actually quite often on the job. Sure, I get butterflies before I go on, but I've gotten so used to them that if we aren't friends by now, we're at least colleagues.

I think what I'm most worried about is having the time and focus to put the talk together at all. Or at least in a way that doesn't suck. Between now and PyCon, I'll be juggling work, attending CodeMash, family, helping run our annual Hack Day event, work, my wife's travel schedule, work, trying to revive From Python Import Podcast, and more work... And I'm trying to fix my goofy sleep schedule. And I need to get back on an exercise plan. And I really only proposed the talk at all because of Jesse Noller's tweeted laments about the low numbers of talk submissions (and now there are too many). And probably a million other excuses...

I want to make sure I can do justice to the idea--an exhibition of sinfully bad code (my own, as well as any volunteered samples) to serve as a negative example. But if I'm not careful it could turn into 45 minutes of saying "Go read Clean Code". And I'd be a hypocrite if it did, since I'm only halfway through the book myself. I want this talk to be valuable.

And I really don't want to take away someone else's opportunity to shine. I'd rather have someone give their first PyCon talk than have a third turn myself. I'd rather go to someone else's kick-ass presentation than waste my audience's time.

So, if there's anybody out there, talk me down from the ledge. Convince me to either hit this out of the park or gracefully bow out and let somebody else have a shot.

Read and Post Comments

How I Deploy My Blogofile Blog on Webfaction

This is partly to help anyone else, but mostly so I don't forget...

Installing Git

Before you do anything, you'll need some git binaries, since they aren't yet installed by default on Webfaction. See Webfaction's git setup docs for how to do this.

Make a Webapp

Use Webfaction's panel to create a new static html web app (assume we'll call it "my_blog").

Making Directories

A little directory setup will be nice:

mkdir $HOME/src
mkdir $HOME/src/my_blog.git
mkdir $HOME/tmp
mkdir $HOME/tmp/my_blog

Getting & Installing Blogofile

I'm a nerd/Blogofile contributor, so I like to roll with the head of the repo.

In my case, I'm getting my own personal fork:

git clone $HOME/src/blogofile
cd $HOME/src/blogofile
python2.6 develop

You'll want to do this on Webfaction and on your local machine (so that you can do offline builds to test).

Initializing the Repo

cd $HOME/src/my_blog.git
git init --bare

Clone it Down

On your local machine:

git clone ssh://username@yourdomain/~/src/my_blog.git

On Webfaction:

git clone ~/src/my_blog.git ~/tmp/my_blog

(After all, we need somewhere to automatically freshen and build from!)

Init the Blog


cd my_blog
blogofile init simple_blog
git add _controllers _filters index.html.mako _posts _templates
git commit -m "Initial checkin of new blog"

First Push

Git really wants a branch to push into, and we don't have one of those yet. Just doing git push will cause git to shit its pants. So instead we have to do the oh-so-obvious:

git push origin master

Did that work?

Create Post-Receive Hook

On Webfaction:

cd $HOME/src/my_blog.git/hooks
vim post-receive

My (very basic!) post-receive hook looks like this:



unset GIT_DIR cd $BUILD_DIR git pull blogofile build -v && rsync -a --delete-after $SITE_DIR $DEPLOY_DIR

This makes sure that:

  1. We get a fresh copy of the blog source
  2. We don't build inside our live site (in case anything goes wrong!)
  3. We don't rsync if the build died
  4. We sync all our changes into place and remove anything that we shouldn't have any more

TODO: I really, really, really need to rearrange this so that we don't do the build at all if the build area's checkout (in ~/tmp/my_blog) was up to date/didn't get any changes. Maybe not a big deal for everybody, but I've got like 1400 blog entries and it takes a while to regenerate all that HTML. I mostly dislike shell scripting, so I will probably write a small amount of Python here at some point.

Also it would probably be good to check any new/changed _posts items to see if they are drafts, because again it sucks to do a bunch of work that we don't have to. Hmm...

Compose a New Post


cd my_blog
vim _posts/hello-world.markdown

Push It!


git add _posts/hello-world.markdown
git commit -m "First post, woot"
git push

And hopefully it all Just Works!

  1. git pushes to remote repo
  2. post-receive hook fires
  3. tmp checkout is freshened
  4. blog is rebuilt
  5. blog is rsynced into place

Write Compelling Content

Now it's time to crank out that undying prose that will forever change the world... get to it!

Read and Post Comments

Why I Switched to Blogofile

Looking back at my blogging history over the past couple of years, I'm almost embarassed by how sporadic my writing has been. It started to taper out as my daughter, then just a newborn, absorbed most of my free time; then it was largely annihilated by "Links for XYZ Date" delicious auto-posts and, to an even larger degree, a plague of "Yesterday's Tweets". I remember tweeting at one point that

the problem with microblogging is that after a while you only have micro-thoughts

and it's really true; as my own worst critic, I get angry at myself for not having anything worth saying. Then my frustration with the Wordpress upgrade cycle really kept me from wanting to write--I kept spending all my time managing updates, and that's too much like my day job...

Meanwhile, the cool kids latched onto Jekyll and static site generators, and I thought to myself Maybe that's the ticket, just pure writing that's easily transformed into something that won't have critical security flaws discovered every couple of weeks. But I wanted a tool that I could be relatively happy working with and extending as needed, and really don't care for the look or feel of Ruby--nor did I like the sound of Gary Bernhardt's reports of Jekyll's silent failures and poor error messaging)--so I stalled for months and eventually decided that I might as well just write my own in Python. But just in case, I thought, I'd better take one last quick look around to see if anyone else is thinking the same thing.

And that's when I found Blogofile--a static site generator that's more or less exactly what I wanted.

I also discovered that converting your blog to a whole different paradigm is another great way to put off writing. There's all the fun of experimentation, data export, cleanup, styling, contributing fixes back upstream... Who needs to write when you can fill your time making a perfect shell for all those words to live in?

But, at long last, I've ripped off the band-aid and forced myself to switch over. I've got a lot of cleanup yet to do--I need to migrate the old static content (various downloads, presentation slides, and so forth) as well as audit my logs for 404s to rewrite into 301s--but I'm pretty pleased so far.

Reasons I like Blogofile so far:

  • Pure text files; just me and vim and source control
  • An excuse to try out git
  • No Wordpress upgrade cycle
  • No plugins clamoring for updates
  • A receptive project owner; Ryan is great to chat with and is quite hospitable to patches and suggestions
  • A friendly (albeit relatively small and quiet) community--the mailing list is pretty low on traffic (also low on noise), and the #blogofile IRC channel on freenode is a nice place to have useful discussions
  • Supports multiple markup styles--most of my exported data is html, while my recent posts are written in markdown; restructured text is available too, and it's pretty straightforward to plug in other parsers if you want
  • Syntax highlighting with Pygments
  • A simpler site means a reduced attack surface
  • Managing everything with a DVCS means I can work offline as much as I need
  • DVCS also means I can shift easily between computers and not lose any work

Potential drawbacks to be aware of:

  • It feels a little inefficient to regenerate the entire site when a single entry is changed (it's not too bad until you have 8 years of blog posts)
  • More disk space than I'm used to using (though still modest compared to what my hosting plan allows)
  • No on-the-fly on-site searching or slicing of data (speaking of which, I should add a search box...)
  • Managing everything with DVCS means whatever you're writing with has to be able to do git, have a filesystem, etc.--so no easy route to blogging from an iPhone or iPad, post-by-email, or that sort of thing (one could presumably craft a solution for this, but it's a lot more DIY effort than I want right now)
  • Publishing is a bit DIY as well--if you're used to just clicking the "publish" button in Wordpress, you might chafe a bit at the idea of setting up remote git post-receive hooks or assembling fabric scripts to make your life easier
  • Still evolving--you definitely want to use the master branch from github rather than the 0.6 release; it's ready for an 0.7 release IMO

This is my first real experience with git, and I'm not sure whether I want to call it a benefit or a pain--it seems like it's a bit of both.

On the whole, though, I'm really liking using and contributing to Blogofile, and I recommend checking it out if you're looking for a different way to approach blogging.

Read and Post Comments

One Honking Great Idea

I really enjoyed From Python Import Podcast's two-parter on the Zen of Python, but I've been thinking that they may have missed something really interesting in the last item in the Zen:

Namespaces are one honking great idea--let's do more of those!

For a long time, I had largely overlooked this one myself, because on its face it seems frivolous and perhaps too specific. Up to that point, the Zen is all broad strokes and elegant generalizations, and suddenly BAM! here comes this thing about namespaces that's full of colloquialisms and exclamation points, and it feels very tacked on and strange and arbitrary, like a sort of gangly teenager trying to fit into a more mature crowd.

Naturally, the conversation in the podcast went straight down the nerd rabbit hole to talk about the meaning of namespaces, and completely neglected the real meat here, which is a pity because this might actually be one of the most important aspects of the Zen.

This is an expression of the enthusiasm and joy that pervade the Python community.

This is Python's "Get Excited and Make Things." This is a formal declaration that it's all right to get excited about stuff that we make. This is a mission statement to go forth and create new delights, so that those who encounter them may be similarly inspired. That above all, this stuff should be fun.

Think about that the next time you're crafting some Python code and see if it doesn't change how you approach things.

Read and Post Comments

Freeform Night at Clepy and the Ghost of Gary Bernhardt

April's Clepy meeting saw a much smaller than usual crowd, and a much more casual program--everyone who'd been lined up to give talks had had to bail at the last minute. So instead of covering anything formally, we spent a relaxing two hours enjoying beer, pizza, and various freeform, impromptu lightning talks. You couldn't even really call them lightning talks since we had no time limit, just an unspoken gentlemen's agreement to yield the projector cable when the time was appropriate.

Steve Dee showed off his CWRU senior project, jsPrettify, a bit of Javascript tomfoolery to automatically turn ASCII sequences into appropriate (and arguably prettier) Unicode equivalents. We also had a nice chat about the Closure Javascript tools that Steve had been introduced to while interning at Google. (Some aspects, like the provide/require system, remind me a lot of Dojo, and while it seems intriguing, reading some other opinions has me back in the skeptical category.)

Mike Crute showed us his not-yet-ready-to-release tool for automating provisioning and deployment of VPS nodes and the apps they serve, which seems like a really slick way to react to traffic needs (consolidate apps onto fewer boxes during low traffic periods, rearrange on the fly if someone's site is spiking). He also showed off something else that I mostly missed, so the Python code we glimpsed (featuring a lone "Oh, my..." comment to apologize for the 100-line method that was about to commence) didn't really mean a lot to me.

We had a brief glimpse of Mike's desktop wallpaper (a demotivational poster featuring a stern-looking John McCarthy) which inspired me to create this little gem (sorry in advance, Gary!):

image: Gary Bernhardt (as John McCarthy): 'Programming: You're Doing It Wrong'

Nick Barendt gave a quick introduction to Buildbot while I VPNed into work to prep my own demo of Das Blinkenlights, my little AIR app for monitoring the current build status of our various build slaves at work. The Python code to emit the JSON feed that Das Blinkenlights consumes hasn't yet been released to the public, but I have permission from the Powers That Be to do so, so I should get around to it before too long. (Beware my extremely unfinished and gross Javascript code in Blinkenlights--it's still in very rough shape at this point).

We had a new member tonight who was interested in applying Python for developing web apps, so we may try to pull together a "web framework shootout" for next month, which I envision as four or five different presenters simultaneously live coding the same basic web app (probably a wiki, blog, or to-do list) using different toolkits. We'll need to see about some cabling and KVMs, I think, so that we can rapidly switch back and forth between presenters. More details to follow, I'm sure...

If you're in Northeast Ohio and want to hang out with smart, friendly people who like Python, come on down! Meetings are held on the second Monday of the month aboard LeanDog's awesome boat, and we have an official pizza and beer fund going to supply us with tasty treats. It's a good time that I highly recommend.

Read and Post Comments

« Previous Page Next Page »