Monday, October 09, 2017

Pick 3 - Android Tasker Based Meal Inspiration

One of the advantages of working from home is the fully stocked kitchen at the ready (not to mention that there's nobody to complain when you microwave some wacky food concoction). While having the kitchen is great, I often draw a blank as to what I should make. Yesterday, as we were shopping for the week, yet another approach to solving this problem hit me: why not write some code to make random suggestions?

First, recorded a bunch of ingredients we had in the house in a Google Keep list. I then used Tasker and AutoCommand to write some code to grab three random entries from this list and presents them to me. Voila! Lunch is served.

Here's the code in action:

That shows me looking at the list of all food items, launching the Android Share function, clicking on the Pick 3 icon and then getting food recommendations. The particular 'meal' isn't very strong: Pickles, Cheese, Bananas, but that's a minor detail.

This Tasker recipe will pick 3 random lines out of any block of text. While I'm using this for food, it could easily be used for generating movie or restaurant recommendations, or really any time you want to narrow down a big list to 3 random items.

Implementing this in Tasker was straightforward. It consists of a Profile that's powered by AutoCommand, a Task that does the heavy lifting and a very simple Scene to display the output.

The Task works by splitting the text passed to it on newlines, calling the Array Process: shuffle action and then outputting the first three values in the newly shuffled array:

As it stands, the recommendations I'm getting are shall we say creative. I could improve them by having separate lists for the different classes of of ingredients. But what fun would that be? Pardon me, while I step away and have a delicious ... Lettuce, Taco Seasoning and Chocolate Milk sandwich.

No comments:

Post a Comment