the further adventures of

Mike Pirnat

a leaf on the wind

Next Page »

Text Me Maybe: Smarter Real-World Integrations with Python

Gosh, it's been a year since I last posted! Let me try to make it up to you...

I took some existing talks on the road last year (to CodeMash, PyCon, and OSCON!) but I've once again put together something new for PyOhio.

So my family likes to know when I'm on the way home from work, but I'm lousy at remembering to text or call before I leave. Some basic "out of the box" geofencing solutions are available, but none of them are smart enough to understand situations like going to lunch where sending a "coming home" message wouldn't be appropriate. Luckily, we can assemble our own solution pretty quickly and cheaply with Python at the core, and we don't even have to run our own servers to do it!

In this talk I showed how I created a cloud-hosted, location-triggered SMS notification service with some decision-making smarts by combining IFTTT (If This Then That), AWS Lambda, Twilio, and just the right amount of Python.

The talk seemed to go really well, and I have been flattered and humbled by the volume of positive feedback I got about it. I hope it will inspire you to go have some fun making your smart things a little smarter.

Here are the slides:

Unfortunately there's no video due to a variety of AV issues, so you'll either need to use your imagination or convince the PyCon program committee to accept it for 2017. ;-)

And who knows, maybe I'll start posting more often (hahahaahhahaahahahahahahaha *wipes away tears* whoooo wow, who am I kidding?).

Read and Post Comments

Using Python to Get Out the Vote

After taking a year off from PyOhio due to a scheduling snafu (off-by-one errors apparently aren't just for software), I was delighted to be back this year, and with a fresh talk to boot.

This spring, I helped my wife with the data munging aspect of a school levy get-out-the-vote campaign. We mashed up school directory data with Ohio voter registration records to produce targeted contact lists for phone calls, mailings, and door-to-door visits, reducing redundant contacts and eliminating wasted contacts.

The technology involved is pretty straightforward, involving a little bit of Python and some pretty basic SQLAlchemy and Alembic (in fact, it was my first serious dive into both SQLAlchemy and Alembic).

The talk seemed to go pretty well, and I had some great conversations about it afterwards. Hopefully it will be inspiring or at least of some value to folks looking to do some useful things with Python.

Here are the slides:

And you can watch the video too.

Read and Post Comments

PyCon 2016 Dates

I blanked on the dates for PyCon 2016 the other day, and Google was strangely silent on the subject, so here, for your reference (and my SEO benefit), are the dates for PyCon 2016:

  • Tutorials: May 28–29, 2016
  • Conference: May 30–June 1, 2016
  • Sprints: Starting June 2, 2016

This means the tutorials will be over a weekend, and the conference will be during the week instead of the other way around, and it'll be a holiday weekend. I'm looking forward to finding out what this does to the dynamic of the conference.

Hopefully I'll see you there--if I can remember the dates, that is.

Read and Post Comments

Announcing Procatindex


If you're even a little bit like me, you think Procatinator is one of the Internet's greatest achievements. (If you don't know Procatinator, pop on over there for a minute or two and you'll know whether the rest of this post is for you or not.)

If, like me, you have favorite cat GIF/music mashups but can't recall their exact URLs when you're trying to wow your friends, then my latest silly website project is for you.

Behold: the Procatindex!! keeps a list of all the Procatinator cats, with titles pulled from the music videos used. The list is automatically refreshed when there's a new cat, and you can subscribe to the RSS feed to make sure you never miss the latest additions.

The site and the script that refreshes it were built in a couple of hours with Requests and Flask, which made short work of the task. (If you aren't familiar with these, you should check them out. Though I have mixed feelings about Flask, it's a wonderful go-to for quick web apps like this. And Requests has become something I can no longer live without.)

Hopefully this improves the effectiveness of your procatination. Enjoy!

Read and Post Comments

Shiny, Let's Be Bad Guys

A couple of weeks ago at the amazing-beyond-belief PyCon 2013, David Stanek and I presented a half-day tutorial. We used a deliberately-vulnerable web application to walk our students through the OWASP Top 10, giving them hands-on experience exploiting these problems and offering advice on how to mitigate them.

While we had concerns about the amount of material and the time available, not to mention the size of the class--we had about 80 people show up!--it seemed to go well, and we got a lot of positive feedback both during the tutorial itself and throughout the rest of the conference. One attendee even told us that thanks to our class, he'd fixed a security problem over lunch immediately after the tutorial! It was immensely satisfying to hear that we'd been able to catalyze some actual improvement in the world.

If the official feedback is good enough, we may look to run this again in the future, whether at smaller venues like PyOhio or next spring at PyCon 2014.

You can clone down the tutorial app if you'd like to follow along with the slides.

Read and Post Comments

Web Development with Python and Django

I had the honor of working with Mike Crute and David Stanek to produce and deliver an all-day tutorial session at CodeMash 2013, where we got folks up to speed on Python and then ran them through a series of iterative exercises as we built a small Django site together.

We promised slides, and though we took a bit of a break to celebrate and then enjoy the conference, I wanted to make sure we didn't wait too long before making them available. Hopefully they will be a useful reference in spite of their lack of the interactivity inherent in a live tutorial session.

You can clone down the sample code repository if you'd like to play along at home.

I think it's safe to say we had a great time presenting at and attending CodeMash and are looking forward to continuing to make sure Python is represented there.

Read and Post Comments

210/365: PyOhio

210/365: PyOhio

Five years after creating a logo for it, I finally managed to attend PyOhio, an awesome and free community conference in Columbus, Ohio. It was a treat to catch up with friends from PyCon as well as meet lots of new people, and I'm really excited to see how PyOhio has grown over the years--it's now almost as big as PyCon was when I first started attending it. From great talks to a fun hallway track, sprinting, and socializing, it's clear that there's something great going on here, and I'm really excited to return.

Read and Post Comments

A 365 Project for Code?


While Twittering in jest over the frequency of Requests' releases, Jeff Forcier inspired me to wonder if you could do the software equivalent of the photography 365 projects that seem to be all the rage this year. I started probing around at the edges of the idea, and it seemed like it could actually be an interesting challenge.

The closest thing I could find (which Jeff pointed me to) is Calendar About Nothing, which tracks your public GitHub commits and gives you a lovely red X for each day you push up something that's available to the public. That's really cool, but it's also pretty easy to just be a weasel and rack up an epic streak by twiddling one's dotfiles back and forth every day. You could script it.

So what would a "code 365" look like? Extrapolating from photography, I would say that it's basically:

  1. Write something unique every day -- as humble or as wild and involved as you like, but something new every day. You wouldn't just publish small tweaks to a photo to get extra days of a photography 365, so once your daily code is released, it's done. And while you might be inspired to emulate great photographers or programmers who came before you--and that's okay--it's not okay to just grab somebody else's FOSS and claim it as your own. The challenge is for you to produce something new. (I'm willing to make an exception for "Hello World" entries, especially if they're on day 1, because it's the sort of thing I would do.)

  2. Any language you want -- just as a photographic 365 invites you to try different tools, techniques, and subjects, if you're brave enough to do a code 365, why not experiment with different languages, programming paradigms, and platforms? We often talk a good, smug game about the value of polyglot programmers, but why not prove it to yourself?

  3. Release it -- push it up to GitHub or whatever your preferred platform is; get it out there where we can see it and admire your foolhardy audacity.

I guess the next question is... Who would be crazy enough to do one of these? People like Corey Haines or Gary Bernhardt come to mind. I bet Kenneth Reitz could do it, but then we'd miss out on updates to the ten million other things of his that are increasingly hard to do without.

I'd be tempted to do it--what's good for the goose is good for the gander, right?--but I'm definitely not willing to consider in 2012. I think one 365 project is more than enough!

What do you think? Is this silly? Or could this Be A Thing?

Read and Post Comments

A Few of My Favorite (Python) Things

I promised I'd post the slides from my CodeMash talk, "A Few of My Favorite (Python) Things", and lo and behold, I have!

I seem to like a lot of dead things--web frameworks like Pylons and apparently the entire genre of Python podcasts (only one of the cited ones is apparently still alive... I should do something about that).

Anyway. CodeMash. Done. Whee! Time to relax.

Read and Post Comments


On Friday I ran across this modest proposal to make the output of Python's unittest2 more closely resemble the emotional state of the tester when there are a lot of failing unit tests. Once my coworkers were done asking if I was all right, or if they should be worried about the cackling and giggles coming from my cube, I resolved to make this dream a reality.

My workplace has settled on the nose testing framework. Like other frameworks, nose offers a plugin architecture to allow all kinds of additional customization and tweaks, and since I had never written one before, it seemed like this might be a good opportunity to give it a try. I found the plugin development docs to be a little too terse and not terribly n00b-friendly, but over the course of a couple of hours I was able to cobble something together. (I mostly ended up cheating off of Kumar McMillan's nose-nicedots, which got me over the hurdle of realizing I needed my own flavor of TestResult to make sure I got the usual stack trace output while still emitting the F's and U's correctly.)

It basically goes like this:

$ nosetests --with-f7u12

FAIL: test_f7u12.TestGeneratesLotsOfFailures.test_generates_failures(7,)
Traceback (most recent call last):
line 197, in runTest
line 15, in _make_a_test
    assert False

< lots more test failure output; use your imagination... >

Ran 50 tests in 0.021s

FAILED (errors=30)

After some wrangling with PyPI (which could also be a lot friendlier to a packaging n00b--big thanks to Michael Foord for helping set me straight), it should be easy_install-able, or you can grab the source from Github (patches welcome!). And if you prefer pytest over nose, it looks like they've got a plugin too.

It's a tremendously silly thing, but it brought me some joy; I hope it can brighten your day too, or at least bring some comfort and commiseration to your test failure rage.

Read and Post Comments

Next Page »