Profile

Cover photo
Eric Koleda
Works at Google
Attended Colgate University
Lived in Brooklyn, NY
4,597 followers|1,609,613 views
AboutPostsCollectionsPhotosYouTube

Stream

Eric Koleda

Shared publicly  - 
 
Just in time for the Super Bowl!
It’s that time of year again- time for the office Super Bowl Box Pool. You know, the one where you put names in a 10x10 square grid and use the last digit
5
2
Alexander Ivanov's profile photoRory O Connor (rocits)'s profile photo
Add a comment...

Eric Koleda
moderator

Tips & Tricks  - 
 
Without the availability of client-side events, the only way to build add-ons that respond to a user's cursor is to regularly poll the Apps Script backend to see if it's moved. This can result in very chatty add-ons however, especially if a user leaves the add-on open for long periods of time.

One way to reduce the number of polling requests is to use the Page Visibility API (https://goo.gl/2DZdPN) to detect if the add-on is visible before making the request. This API is supported by most browsers, and in the attached Gist I show an example of how to do this using the Visibility.js wrapper library (https://github.com/ai/visibilityjs).
Polling in a sidebar only when the page is visible
17
3
Eric Koleda's profile photoAlexander Ivanov's profile photoMartin Hawksey's profile photoRory O Connor (rocits)'s profile photo
4 comments
 
That's certainly the best solution +Mikael Thuneberg, but no immediate plans.
Add a comment...

Eric Koleda
moderator

Discussion  - 
 
In this video, Google Developer Advocate +wesley chun provides a nice overview and tutorial on Drive v3.
5
1
Cesar Anton's profile photo
Add a comment...

Eric Koleda

Shared publicly  - 
 
Easily handle range input in custom functions

Yesterday I pushed out an update to the Date Add and Subtract sample add-on that added support for operating on ranges of values instead of just single values. We mention this as a best practice in our documentation (https://goo.gl/iRhI2m) and even include a simple pattern you can use to quickly add support to your custom functions:

function DOUBLE(input) {
  if (input.map) { // Test whether input is an array.
    return input.map(DOUBLE); // Recurse over array.
  } else {
    return input * 2;
  }
}

This works great for custom function that take a single parameter, but can't easily be applied to functions that take multiple parameters. And what if some parameters are ranges and others aren't?

Enter multimap

multimap is a utility function I created that takes all the hard work out of working with ranges, allowing you to just function on your core logic. For example, here's a custom function called REPEAT that repeats an input string some number of times, before adding multimap support:

function REPEAT(str, times) {
  var result = '';
  for (var i = 0; i < times; i++) {
    result += str;
  }
  return result;
}

And here's what it looks like after adding multimap:

function REPEAT(str, times) {
  return multimap([str, times], function(str, times) {
    var result = '';
    for (var i = 0; i < times; i++) {
      result += str;
    }
    return result;
  });
}

The logic inside your callback is identical to when it was just operating on single values, and multimap takes care of the rest.

I've put together a demo spreadsheet that illustrates some of the cool things you can do with a custom function that uses multimap:

https://docs.google.com/spreadsheets/d/1hwa_JATdvfSkB189jOrULrQ8DROFgYYPYx5t33omMxI/edit#gid=0

You can check out the source code of the multimap function on GitHub:

https://github.com/google/google-apps-script-samples/blob/master/date_add_and_subtract/Code.gs#L129
9
7
Alexander Ivanov's profile photoСтанислав Носырев's profile photoRory O Connor (rocits)'s profile photoJan Almeroth (Privat)'s profile photo
5 comments
 
+Steve Webster, news to me. No clear repro on the issue so far, so if you have one please add it.
Add a comment...

Eric Koleda

Shared publicly  - 
 
I know Apps Script inside and out, but I so rarely get to solve real problems with it. I love hearing stories like this, where some simple code and SQL queries can dramatically transform how people work.
 
The New Visions systems and data teams have hitched up core NYC data systems to a data warehouse, and to Apps Script and Drive in some very powerful ways that now reach over 200 high needs schools in NYC. Thrilled to see this excellent reporting by +Patrick Wall capture the essence of this simple but powerful innovation.  Super proud of the team!
The city is hoping that an easy-to-use tool built with Google Drive will enable struggling schools to make new use […]
1 comment on original post
11
1
Ian Weatherhogg's profile photo
Add a comment...

Eric Koleda

Shared publicly  - 
 
 
Wear Companion Library (WCL)

WCL is a small library to help Android Wear developers with a number of common tasks.

Some of the features that are currently supported:
- Handling Google API Client setup and lifecycle
- Providing a simple API to launch the app on any connected node
- Providing real-time data on the connected nodes and their capabilities
- Providing a long list of callbacks for clients to be notified of the changes on the Wear network
- Sending files from a node to any other node with a simple API
- Streaming data from one node to another
- Providing a simple API and Activity for recording voice to a file and playing it back
- Providing a simple API to stream microphone output to any node
- Providing a simple API to show a nicely formatted WearableListView activity
- Providing a simple API to make an HTTP call

The WCL project on GitHub also includes its documentation (in PDF): 
https://github.com/googlesamples/android-WearCompanionLibrary

A simple demo app has also been created to show how this library can be used in a real project: https://github.com/googlesamples/android-WclDemoSample
5 comments on original post
4
Add a comment...
Have him in circles
4,597 people
Janine Sarto's profile photo
Grahame Falvey's profile photo
Jorge Faria (Professor HULK)'s profile photo
Stone z's profile photo
Seamus Lavery's profile photo
Roman Minkin's profile photo
Adam Aris's profile photo
Tim Shiple's profile photo
Michel Isamuna's profile photo

Eric Koleda
moderator

Tips & tricks  - 
 
A good tutorial on how to use the (relatively) new PositionedImage type in Apps Script.
 
Issue 1529, programmatic support of “Fixed Images”, has been fixed. As of December 2015, Google Apps Script can manipulate PositionedImage objects in Google Docs. Previously, we only had control over InlineImages via our scripts, so this is good news.…
View original post
8
1
Alexander Ivanov's profile photo
Add a comment...

Eric Koleda
moderator

Announcements  - 
 
Take a look at v3 of the Drive API. It's a leaner, faster-by-default implementation, but completely optional for those of you already using v2.
 
A leaner and faster Google Drive API

Today, version 3 (v3) of the Google Drive API is available, providing developers with a leaner, faster by default, and more consistent interface to Google Drive. This latest update is designed to be easier for developers who are integrating with Drive for the first time.

Learn more: http://goo.gl/cR151b
8 comments on original post
10
3
István Maczkó's profile photoCesar Anton's profile photo
Add a comment...

Eric Koleda
moderator

Tips & tricks  - 
 
Add more power and flexibility to your custom functions with multimap.
 
Easily handle range input in custom functions

Yesterday I pushed out an update to the Date Add and Subtract sample add-on that added support for operating on ranges of values instead of just single values. We mention this as a best practice in our documentation (https://goo.gl/iRhI2m) and even include a simple pattern you can use to quickly add support to your custom functions:

function DOUBLE(input) {
  if (input.map) { // Test whether input is an array.
    return input.map(DOUBLE); // Recurse over array.
  } else {
    return input * 2;
  }
}

This works great for custom function that take a single parameter, but can't easily be applied to functions that take multiple parameters. And what if some parameters are ranges and others aren't?

Enter multimap

multimap is a utility function I created that takes all the hard work out of working with ranges, allowing you to just function on your core logic. For example, here's a custom function called REPEAT that repeats an input string some number of times, before adding multimap support:

function REPEAT(str, times) {
  var result = '';
  for (var i = 0; i < times; i++) {
    result += str;
  }
  return result;
}

And here's what it looks like after adding multimap:

function REPEAT(str, times) {
  return multimap([str, times], function(str, times) {
    var result = '';
    for (var i = 0; i < times; i++) {
      result += str;
    }
    return result;
  });
}

The logic inside your callback is identical to when it was just operating on single values, and multimap takes care of the rest.

I've put together a demo spreadsheet that illustrates some of the cool things you can do with a custom function that uses multimap:

https://docs.google.com/spreadsheets/d/1hwa_JATdvfSkB189jOrULrQ8DROFgYYPYx5t33omMxI/edit#gid=0

You can check out the source code of the multimap function on GitHub:

https://github.com/google/google-apps-script-samples/blob/master/date_add_and_subtract/Code.gs#L129
5 comments on original post
10
2
Marcos Gomes's profile photoRory O Connor (rocits)'s profile photo
Add a comment...

Eric Koleda

Shared publicly  - 
 
My talented colleague +Jeffrey Posnick just gave a great talk at the #ChromeDevSummit  on how to effectively use service workers to create web apps that load seemingly instantly.
 
Hey, my Chrome Dev Summit talk is up already!

It covers the performance benefits of the App Shell + service worker model, and two libraries that can simplify your service worker implementation, sw-precache and sw-toolbox. 
1 comment on original post
9
Jeffrey Posnick's profile photo
 
Thanks for the kind words! 
Add a comment...

Eric Koleda
moderator

Tips & tricks  - 
 
Auto-complete and forEach
I'm a big fan of the standard JavaScript array methods forEach(), map(), and reduce(), but unfortunately using them in Apps Script breaks the auto-complete provided by the editor. However, there is a neat little hack you can do to work around that:

var calendars = CalendarApp.getAllCalendars();
calendars.forEach(function(calendar) {
  // calendar = calendars[];
  Logger.log(calendar.getName());
});

The comment I included tricks the code editor into thinking I plucked a value out of "calendars" and put it into the "calendar" variable. The code is never actually run, so it doesn't matter that you don't specify an index. Enjoy!
15
Riël Notermans's profile photoStephen Gale's profile photoBruce Mcpherson's profile photoAndrew Roberts's profile photo
4 comments
 
A kind of opposite effect: I've learnt to avoid putting full stops (periods) at the ends of comments as this confuses the auto-complete.
Add a comment...

Eric Koleda
moderator

News  - 
 
Updated Dialog2Sidebar Sample
This sample shows how you can have a dialog and sidebar in your add-on communicate with each other, for example when you want your sidebar to open a popup to collect additional information. It's been updated to use IFRAME sandboxing and take advantage of the intercom.js library for client-side, cross-page communication. This same model can be used when dealing with an OAuth flow, and needing to know when the user has approved the authorizations.
Contribute to apps-script-dialog2sidebar development by creating an account on GitHub.
14
6
James Swansburg's profile photoAndrea Leardini's profile photoOtari Arutiunian's profile photowritten tinxe's profile photo
3 comments
 
+Eric Koleda It's surprising that it would be a major change to implement a google.script.host.hide() method for an open modal dialog.  

This method could add "display:none" to the style attribute for the <div class="modal-dialog script-app-dialog"></div> element.  It could also add a "modal-dialog-bg-hidden" class to the <div class="modal-dialog-bg"></div> element, with the following css rule:

div.modal-dialog-bg.modal-dialog-bg-hidden {
    z-index: 0;
    display: none;
}

This would hide the modal and the overlay, allowing the user to interact with the document, menu or sidebar.  I could then use intercom.js to populate the dialog client-side from the sidebar when needed, and I could call a google.script.host.show() client side method which undoes the hide() method changes.  This would allow me to then have the quiescent dialog available for when user interaction is needed, and populate it with html on demand, etc., from the sidebar without need for a server round trip.  

It also would have the benefit of reducing server load from apps scripts, by allowing developers to handle such interactions 100% client side, instead of having to burden the server with requests best handled client side.

It would be a huge benefit to developers like me if this functionality existed.

Thanks for listening.  I have been very impressed by the power of the GAS add-on environment, and I would love to see it improved in this fashion.
Add a comment...
Eric's Collections
People
Have him in circles
4,597 people
Janine Sarto's profile photo
Grahame Falvey's profile photo
Jorge Faria (Professor HULK)'s profile photo
Stone z's profile photo
Seamus Lavery's profile photo
Roman Minkin's profile photo
Adam Aris's profile photo
Tim Shiple's profile photo
Michel Isamuna's profile photo
Work
Occupation
Developer Programs Engineer
Employment
  • Google
    Developer Programs Engineer, 2009 - present
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Previously
Brooklyn, NY
Story
Tagline
Member of the Developer Relations team at Google.
Introduction

I am a Developer Programs Engineer working primarily on Google Apps Script.

Collections Eric is following
Education
  • Colgate University
    Computer Science, 2001 - 2005
Basic Information
Gender
Male