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.

 

My spirit animal

 

 

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

 

Mmmmm….overanalysis

 

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.

 

Oh, Google. Is there anything you can’t do?

 

 

Essentially, Google Scripts is built into Google Docs, so I could tie the code directly to the spreadsheet where the form data was captured. From what I can tell, it’s pretty similar to JavaScript, so between the tutorials and some searching on JavaScript, I managed to get the code to do what I wanted. It would now check the entry dates, gather a day’s responses, and calculate the scores. There was even a trigger function, so that I could tell it to check regularly at 3PM. Plus, it could assemble the email and send it from my gmail account out to everyone, so they could see today’s score, without me having to take the time to do it. All in all, it only took me about 19 hours to save that 5 minutes! Time well spent on a job well done.

 

credit: https://xkcd.com/1319/

 

“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.

 

You can tell it’s science, because there’s a graph

 

 

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!

 

Except…

 

You had to know this was coming

 

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!

 

Credit: New York Times

For real this time

 

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.

4 Comments

  • TPI member says:

    Nice write-up, but what about a score that includes price/cost/value in the tanning?

  • TPI member says:

    In the scoring* (autocorrect strikes again)

    • jcory says:

      Price was eliminated as a scoring category at the 3rd Official Technical Pizza Interchange, by unanimous vote of all attending members. Mostly because none of us could be bothered to keep the receipts.

  • […] The thing is, when it comes to coding, I’m entirely self taught. Best practices, comments and efficient code are things that happen to other people. My code isn’t necessarily “good”, but it does what I want it to do. And I think that’s really what I want everyone to take away from this. Your code doesn’t need to be perfect, it just needs to exist. Coding is one of those skills that can be really handy outside of your hobby projects, from automating tasks at work to determining the best pizza place in the region. […]

Leave a Reply

Your email address will not be published. Required fields are marked *