Today’s blog post is by Josh, of Make It Dayton.
So, I get carried away sometimes. I’ll start out with a simple project and by the time I’m done, it barely resembles my original vision. But if I’m lucky, I’ve turned out something pretty cool. This project started over a year ago, when a group of my co-workers decided to go out for pizza, of which I am a fan. We decided that we needed a name that sounded official and had a good acronym (all engineering projects need a good acronym, after all). And so the Technical Pizza Interchange™ was born.
We had been going to have pizza regularly for about 3 months, when we started debating where the best place we had been was. Being engineers, we decided we needed numbers. And so, we decided what categories we wanted to judge, and I created a Google Form, letting us rate everything from Sauce Quality to Atmosphere
The plan was then to tally up the score and email everyone what that day’s restaurant had scored. The trouble (for me, at least), was that I didn’t want to have to remember to go in, work out that day’s score for each category and a final score manually and email everyone. Why, it could have taken upwards of 5 whole minutes! Clearly, that would not stand. I started looking into how to automate the process, when I discovered Google Scripts.
“But wait,” I thought to myself, “what would be really cool is if I could get it to draw a graph comparing the category results of the last 5 restaurants and embed it in the email” Luckily, there was a very good example on embedding images in generated emails, and it only took a little adapting to embed the graph from my Google Sheet to the email. THe difficult part was getting the bar graph to update properly, but I did get there in the end.
At this point, I thought I was done. But then I realized, I didn’t need the code to check the scoring every day. I only needed it to check it on days when we actually went out to eat. Generally, we would do every other Friday, but sometimes meetings or vacations would get in the way, and the date would shift. But it turns out, so long as I had this tied to like half of the Google services I used, I might as well throw in Calendar. So, every day at 3PM the code checks to see if I have a meeting scheduled that day containing the word ‘Pizza’. If I do, math occurs. If not, nothing happens. Perfect!
Well, I was still going in and changing things pretty regularly. It was simple, and minor, but I like to have the email subject as TPI Newsletter:, followed by a snarky comment, and I was going into the code to put the comment in every time we’d go out. So, I made up another spreadsheet and filled it with snark (with an emergency default comment, just in case the snark reserves ran low). Then, I updated the code to grab the first available phrase, put it as the subject, and then move it over to the ‘used headlines’ page. Finally, the Technical Pizza Interchange only required me to add some snark once in a while and schedule it on my calendar. Mission accomplished!
For me, this project was kind of exciting. This, for all that the reason seems a little silly, was the first time I’d ever written code for myself. There wasn’t an assignment due, nobody was going to be mad about me missing a deadline. I just wanted to make the search for the best pizza in Dayton a little bit easier. It was really exciting to write code that just did something I wanted it to do. Is the code perfect? It does what I want, so in that sense, yes. Is it neat and professional?
Sorry. Fell out of my chair laughing.
For those that are wondering, the current Official TPI Blue Ribbon Winner is South Park Tavern. Great pizza and the bubble hockey machine really kicked up that atmosphere score.