Skip to content

Instantly share code, notes, and snippets.

View mogsdad's full-sized avatar

David Bingham mogsdad

View GitHub Profile
@mogsdad
mogsdad / httpGetTemplate.gs
Created September 9, 2015 02:39
Google Apps Script template functions for external host communication with UrlFetchApp. See https://mogsdad.wordpress.com.
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* httpGetTemplate.gs
*
* A pair of template functions for external host communication with
* UrlFetchApp, including parameter encoding and error handling.
*
* From: gist.github.com/mogsdad/a76c32231a2b91ff8b59
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@mogsdad
mogsdad / SO-Autocomments.md
Last active December 20, 2017 18:02
My personal autocomments for use with Stack Overflow add-on: https://github.com/Benjol/SE-AutoReviewComments. Free use is hereby granted.

###[Q] Minimal Complete Verifiable Example Please [edit] your question to include a [mcve]. This will help the $SITENAME$ community by clarifying the problem.

###[Q] Homework Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it. ([help/on-topic])

###[Q] Give teh codez Open-ended "How to" questions are difficult to answer, and tend to generate follow-up discussions. To improve your chances of getting a helpful answer, [edit] your question to provide greater focus on the specific problem you're facing. See [ask].

###[Q] Offsite resource

@mogsdad
mogsdad / Logger-Sidebar.html
Last active February 12, 2018 22:39
Example showing use of Logger passthrough in client-side JavaScript. See https://mogsdad.wordpress.com/?p=193.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
/**
* On document load, assign click handlers to button(s), add
* elements that should start hidden (avoids "flashing"), and
* start polling for document selections.
*/
$(function() {
// assign click handler(s)
$('#submit-button').click(function() {
@mogsdad
mogsdad / Logger-AddonUtilities.gs
Last active September 5, 2021 15:51
Google Apps Script utility functions for persistent logging. See https://mogsdad.wordpress.com/?p=193.
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* AddonUtilities.gs
*
* A collection of general Google-Apps-Script utilities that are useful for
* development of Add-ons.
*
* From: gist.github.com/mogsdad/39db2995989110537868
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@mogsdad
mogsdad / Logger-HtmlUtilities.html
Last active February 12, 2018 22:40
Client JavaScript utilities for persistent server-side logging. See https://mogsdad.wordpress.com/?p=193.
<!--* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* HtmlUtilities.html
*
* A collection of general client-side javascript utilities that are
* useful for development of Add-ons.
*
* From: gist.github.com/mogsdad/d6cd7f095355b7f0ef48
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-->
<script>
<!-- This CSS package applies Google styling; it should always be included. -->
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css">
<style>
.result-display {
margin-left: 15px;
font-size: 125%;
}
.error {
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
// Load the Visualization API and desired package(s).
google.load('visualization', '1.0', {'packages':['controls']});
/**
* Run initializations on dialog load.
*/
<!-- Use a templated HTML printing scriptlet to import common stylesheet. -->
<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>
<html>
<body>
<h1 id="main-heading">Loading...</h1>
<div id="dashboard-div">
<div id="control-div">
<div id="slider-div">
</div>
<div id="selector-div">
/**
* Serves HTML of the application for HTTP GET requests.
* From gist.github.com/mogsdad/24518dff348ad14d3929
*
* @param {Object} e event parameter that can contain information
* about any URL parameters provided.
*/
function doGet(e) {
var template = HtmlService.createTemplateFromFile('Index');
@mogsdad
mogsdad / drivingDistance.gs
Last active December 29, 2021 20:52
drivingDistance() is a Google Sheets custom function that calculates the driving distance along a possibly multi-point route.
/**
* Calculate the driving distance (in meters) along a route.
*
* @param {"london","manchester","liverpool"} route
* Comma separated ordered list of two or more map
* waypoints to include in route. First point
* is 'origin', last is 'destination'.
*
* @customfunction
*/