Google Apps Script And Calorie Counting

It’s in the news lately that by 2030, 50% of the population will be obese. Well, I’m a bit (ok, maybe more than a bit) overweight now and was looking to do something about it. So for my diet, I’ve started counting calories. I’ve tried a number of other diets with mixed results, but calorie counting for me always works. However, counting calories can be a bit of a pain. There are a number of ways to figure out how many calories are in things, such as the container the item comes from, websites like http://caloriecount.about.com/, http://fatsecret.com/ or search on your favorite search engine. Finding out the calorie content of a food isn’t really so much of a problem in and of itself because after awhile you just know how many calories are in the usual things you eat. But where is the best place to keep track the current running total for the day? It has to be easily accessible to me or I don’t do it. I don’t always have paper, nor am I in places where I have connectivity. Android, Gmail and of course, Google Apps Script to the rescue!

Counting Calories using Apps Script


The process is simple. I send an email to myself with the subject “@FOOD” where the body contains the number of calories in the food and the name of the food, one per line. I wrote a script which, every 15 minutes, scans my email and computes the total of calories I’ve consumed in the last 24 hours and updates a spreadsheet with the total.

Why do it this way? Using Gmail for the recording makes it so if I’m offline on my phone, the gmail app will send it when I’m online. Putting it in a Google spreadsheet means I can make a shortcut for it in chrome, and a desktop web shortcut icon on my Android phone for easy access. Additionally, using a spreadsheet allows me to perform other calculations, make charts, etc.

How do you set it up?

First create a new spreadsheet, and click on Tools > Script Editor. Click on File > New > From Script Template. Search for “Calorie Counting” and you will be able to locate the script. Then, click Install and you are all set. Save the script, run it, at which point you’ll get two authorization dialogs, click ok through them. Run it again to make sure it populates the sheet properly. Then, in the script editor, click Triggers>Current script’s triggers and add a new trigger:

And you’re all set! Your spreadsheet, after the script runs will look like this:

From here the possibilities are endless. I’m thinking I could make a UiApp script which uses the new Charts bean to draw a graph. Perhaps make a service to view/change calories because I mess things up every once in awhile. You could also add code for “@WEIGH” messages to track weight and could graph that too. Your imagination is the limit! And if you have an even better idea for how to use Apps Script to improve Gmail and Spreadsheets, you can post it to our Gallery (Script Editor > Share > Publish Project) to share with the world.

Map Maker: from Afghanistan to Antarctica

Google Map Maker enables local experts to create maps and share their local knowledge with the world. These citizen cartographers help keep maps of their areas accurate and up to date. They add missing roads and new businesses—and even map areas that have little to no data yet on Google Maps.

Today, our latest crop of countries, territories and an entire continent are graduating from Map Maker—meaning the user-generated maps of these countries will now appear on Google Maps: Afghanistan, Antarctica, Ecuador, Georgia, Guatemala, Heard Island and McDonald Islands, Honduras, Iraq, Norfolk Island, Saint Pierre & Miquelon and Saudi Arabia.

Here are some before and after pictures that highlight how much detail Map Maker users have added to Google Maps for these regions (as well as some time-lapse videos):

Baghdad, Iraq

Kabul, Afghanistan

Tbilisi, Georgia

Each region has an impressive mapping story—from the Georgian Government’s initiative to improve their country’s map, to the group led by six students in Herat, Afghanistan who mapped their entire city in a matter of weeks.

Thank you to the Google Map Maker contributors who create better maps for these regions and others; their ongoing efforts can be seen at Map Maker Pulse. We encourage all local mappers to continue improving the maps of these areas and the more than 180 other regions of the world on Google Map Maker.