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.

Google Maps Mashups 23

Seattle Food Inspection Map


The Seattle Food Inspection Map lets you examine the food inspection ratings for Seattle restaurants.

The map includes a nice slider function that allows you to search for restaurants in Seattle based on the inspection score. For example, you can set the slider to show only restaurants that have a score between 0-45 (a score of over 45 indicating a poor inspection).

Alternatively you could search for restaurants that you might want to avoid by setting the slider to only show restaurants with a score over 45.

NYC BigMaps


NYC BigMaps have used the Your Mapper map creation tool to map restaurant inspections and 311 service calls in New York City.

The restaurant inspections map displays New York City Department of Health inspections across 5 boroughs since Jan 2008 (22,440 restaurants). You can search the map by category, date range, keyword, and location. The map then displays restaurants on the map at the location you searched.

Track Maps using Google Analytics


Ubilabs has written up a very cool explanation of how you can track users’ interactions with Google Maps using Google Analytics.

The trick involves using Google Analytics event tracking on your map. For example you can add a tracking event to map markers to see how many times users click on different markers.

Ubilabs say that they regularly use Google Analytics on their created maps to track map types used (‘map’, ‘satellite’, ‘hybrid’ etc), location search (geocoding requests) and map marker and drag events.

Web 2 Map


The Web 2 Map is a metaphor of the internet, as seen by the organisers of the Web 2.0 Summit. The map assigns territories or ‘countries’ to different sectors of the internet, for example ‘social networks’, ‘search’ ‘e-commerce’ etc.

This year the map also includes a data layer. The data layer adds what might be seen as capital cities to the map. The buildings or skyscrapers in the city act as a metaphor for the different data segments within the dominant player in that sector.

For example, the Union of Social Networks includes a Facebook capital city. The Facebook city is dominated by a ‘social’ skyscraper but also includes a smaller ‘location’ building to reflect that Facebook also now includes check-ins etc.

findmark.org


Mark Bosworth, a GIS Analyst at Metro in Portland, has been missing since Friday September 16, 2011.

Mark is a cycle Oregon volunteer and was last seen walking to his tent in Riddle, Oregon. Mark’s family think that he may have had a recurrence of cancer that has caused him to become confused and possibly lose his memory.

There have been several sightings of someone fitting Mark’s description hitch-hiking near I-5. Therefore Mark’s family and friends have been distributing flyers up and down the I-5 corridor. This Google Map is being used to help plan where the flyers have been and need to be distributed.

If you are able to help with distributing flyers you can print them out from the website launched by Mark’s family – findmark.org. You can then use the map to see the areas where flyers still need to be distributed.

The Bambuser


One of my favourite smartphone apps is live broadcasting application Bambuser. The application lets you broadcast live video straight from you mobile phone or a webcam.

The only bugbear that I used to have with Bambuser is that it didn’t have a map of broadcasts happening right now, so that users could select from the currently live broadcasts geographically. Well, now it does!

The live Bambuser Google Map shows the location of live broadcasts, those recorded in the last 24 hours and even older recorded broadcasts. You can even watch the live streams directly from the map.

The Corruption Tracker Google Map


Having come across the concept of baksheesh more than a few times in my travels around the world I know how frustrating it can be to have to pay bribes to officials just to get them to do their jobs properly. It often seems that the practice is officially encouraged and that there is no point in reporting the incident.

In these situations it would be at least satisfying to be able to warn the rest of the world about the corruption.

The Corruption Tracker uses Ushahidi’s map reporting system to allow users to report and map any corruption that they witness or are subject to.

Users can report corruption by sending an email, by sending a tweet with the hashtags ‘#corruption’, ‘#bribe’, ‘#anti-corruption’ or ‘#theft’, or by filling out a short form. Submitted reports of corruption then appear on the Corruption Tracker Google Map.

London Bus Waiting


Transport for London recently started beta testing a new Countdown API to provide real-time departure information for all buses at every bus stop throughout London.

Next Bus London has quickly released a Google Map that shows the location of London bus stops and informs you how long you will have to wait to catch a bus.

To find out exactly how long you will have to wait you simply need to click on a map marker and an information window opens displaying the bus number, destinations and waiting times for the next few scheduled buses at that stop.

The University of Montana


I came across this beta campus map of The University of Montana today. The map includes a couple of nice features to help students and visitors find their way around the campus.

The Google Map includes a transparent overlay that adds interactivity to the buildings on the map. Users can click on individual buildings and get links to the building’s page on the university website and to printouts of floor plans of the building.

The map also includes a nice directions feature that allows users to quickly select and find walking, driving and bus directions between different locations at the university.

Other layers allow users to view photos, art exhibitions, bus-stops, parking spots, places to eat and wi-fi locations.

timespentalone.com


Where Do You Want To Go? is a great idea to get people to share the places they want to go and why they want to go there.

To submit a desired location users simply need to enter a destination and some brief thoughts about why they want to visit. Whenever a user submits a destination, the destination is Tweeted by timespentalone with a link to the user’s Google Map.

The best submissions are added to the Where Do You Want To Go? main map. The main map rotates through the submissions to the site, showing a Google Map satellite view of the location and the submitter’s thoughts.

My only complaint with the application is that the map is a little slow. I’d like the application to move onto the next submission after about ten seconds or maybe add a button so users can manually move to the next map.


The application reminds me a little of ZeFrank’s A Childhood Walk

For his project Ze asked people to recreate a childhood walk in Google Maps Street View. He then put together a collection of the responses superimposed on top of the appropriate Street View image.

Google Maps based photo album


Codrops has created a very nice template and tutorial for a Google Maps based photo album.

This multi-level map and image gallery displays images related to their location. The first level of the map shows the location of places that have a set of images. If you click on a marker on the first level the map will zoom in and also display thumbnails of the photos at this location.

Clicking on a marker in the second level will result in the photo being displayed next to the map. The images can also be viewed in a lightbox and the map can be viewed in full-screen.

The Robot’s chaosinyourtown.com


Robots from the year 2029 have been sent back in time to destroy you and your home!

Yes – the robots are here to get YOU!

Chaos in Your Town lets you create a blockbuster robot film featuring your very own street and house. Using Google Maps Street View as the background to the scenes Chaos in Your Town creates an incredible Flash based movie that shows robots walking down your street, targeting your house and blowing it to kingdom come.

This is the best thing you will see this week. Don’t believe me? Then just have a look at the screenshots below – and then go and create your own movie.

A heat map of Somalia


Voice of America has used a series of Google Maps and over 10,000 separate data points on rainfall, food prices and refugee movement to explain How Somalia Descended into Famine.

The visualisation explains over a series of Google Maps how the non-occurence of last year’s rain season in Somalia has led to crop failure, this year’s spike in food prices and then widespread famine.

The rainfall map lets the user view rainfall levels throughout Somalia. If you click on one of the rainfall markers you can view a graph of rainfall at that location comparing 2010’s rainfall with rainfall in 2009.

The food prices map allows the user to select different towns in Somalia and view graphs showing the sharp rise in price of a number of different crops and other essential commodities.

Finally the famine map provides a heat map of Somalia showing the scale of the famine at different locations in the country.

Driving Directions


Google Maps has added the option to preview driving directions in 3D using the Google Earth plugin.

Now when you use Google Maps for driving directions you will see a 3D button next to your directions.


When you click on the 3D button the map will switch to the Google Earth view. An animated fly-through of your route will then be shown.

You can pause the flight at any time by clicking anywhere in the 3D view or on the pause button. It is also possible to jump to different stages in your directions by clicking on a step in the left hand panel.

Try a Flight

The GitHub – Masked Polygons


Swiss Trains have open-sourced the code for a very cool masking effect on Google Maps.

The effect transforms a KML polygon into a mask that effectively highlights the polygon on the map by shading the rest of the world. You can see a demo of the effect on this Swiss Administrative Boundaries Map.

When you select a region on the Administrative Boundaries Map the chosen area is highlighted and the rest of the map shaded out.

The mask is a very effective tool. If you want to use the effect in your own Google Maps then grab the code from GitHub – Masked Polygons.

Via Googlemapsmania

Google Maps 5.3 for Android: See your location history dashboard and more

We’re happy to announce Google Maps 5.3 for Android, which lets you see your Google Location History dashboard, check in at “home,” and add your own aspects for places when rating them.

Location History dashboard

If you’ve enabled Location History for Google Latitude, you’ve been able to visualize interesting trends in your location history with a personal dashboard at google.com/latitude on your computer. Now, you can also see your dashboard on your phone by tapping View location history from your Latitude profile. You’ll be able to see right on your phone how far you’ve travelled as well as an estimate of how much time you’ve spent at home, at work, or out.

If you haven’t yet, you can enable Location History from your computer or from Latitude’s Settings menu on your phone. Location History is 100% opt-in and is private to you and nobody else. You can always delete any of your location history from the Manage History tab or correct the estimated work and home locations from the dashboard on your computer.

View your location history dashboard from your Latitude profile on your phone and see estimates of where you’ve spent your time.

Check in at home

Now that you can see how much time you spend at “home”, you might want to let friends know when you’re there. Checking in at places using Latitude is another way to keep a history of places you’ve been and also lets you share when you’re there. I love letting friends and family know when I’m at a cafe or park, but sometimes I want them to know that I’m relaxing at home or made it back safely from a road trip. So now, I can start checking in at “home” in Latitude:

  1. Check in from Latitude and tap “Home – Tap to set your location” at the bottom of the nearby places list if you don’t have one yet.
  2. Use the estimated current address or enter in your home address yourself.
  3. Once you’ve checked in at home once, “Home” will appear at the top of the list when you’re checking in near there.

Like Latitude and other check-ins, checking in at home is entirely opt-in. Your set “home” location is not searchable and only you can check in there. Just like any other check-in, you can choose with whom to share your home check-ins (along with your name and address info).

Add your own aspects for places

When you’re rating places on the go in Maps using Google Places with Hotpot, you could always quickly leave feedback on a specific aspect or characteristic of a place, such as the food or ambiance. Before, we’d automatically include aspects about places that were commonly mentioned in reviews. Now, you can add your own aspects for each place. So if you think a place has a beautiful view or great music, you can add it yourself and quickly share it with the world.

When rating places, you can add your own aspects like “music” for places and leave quick feedback.

To get started, update Google Maps from Android Market on devices with Android OS 1.6+ anywhere Google Maps and Latitude are already available.