Into the Darkness

When I have clarified and exhausted a subject, then I turn away from it, in order to go into darkness again.

Carl Friedrich Gauss

Projects

Blog

Athletics

/src

@detweiler

About Brian Detweiler

Chili Time

Adds an event to my calendar when there's chili at Union Pacific's cafeteria

Introduction

One day, I was sitting at my desk eating a bowl of chili from Union Pacific's cafeteria, run by Gukenheimer. I thought about how I never knew when they would have it, and I would see it by dumb luck and get excited, since chili is probably one of my favorite foods.

Gukenheimer has a website, and they publush a weekly menu. But I forget to look, and honestly, it just seems like too much work to have to pull up a food menu every day. I thought this was a great candidate for automation.

The Idea

Web scraping is kind of a thing of mine. I've made a good portion of my career out of it, with the credo, "If I can HTTP it, I can do anything with it." So that was the plan here. Their menu is published weekly as a Lotus Notes formatted document here: http://dining.guckenheimer.com/clients/unionpacific/fss/fss.nsf. Furthermore, it is frames-based, but each day has its own URL.

The Implementation

Using Python, it was easy enough to get "today" then count back to Monday. From there, we can grab all days, Mon-Fri. Ater that, my logic is incredibly basic. I just look for the word "Chili" but rejecting the words "Chili Mac", "Chili Sauce", and "Chicken Chili", (because their Chicken Chili is in this weird white sauce, and can't really be counted as a chili). From there, I write out an iCal file to this website, and do a git commit/push.

Then I just had to add the iCal file in Google Calendar, and schedule the whole process as a cron job to run every Monday at 8 AM.

Probably the most difficult thing about all this was figuring out how to store git credentials so I could automate this. I found this StackOverflow article to be very helpful.

The Results

Assuming I set up my crontab right, I think it's going to work. This week already put an entry on my calendar for Friday. I'll have to keep my eye out for bugs though. And there's the 2 Soups issue: The website only lists two of the three soups they are serving for that day. So, at this point, it's only a 66.6% solution. That's as good as it's going to get. I'm ok with those odds.