Skip to content

Instantly share code, notes, and snippets.

View TechandEco's full-sized avatar

Sustainability and Tech TechandEco

View GitHub Profile
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// Column names in sheet.
const EMAIL = 'Email';
const GOOGLE_GROUP = 'Google Group';
const ALLOWED = 'Allowed';
const EMAIL_TEMPLATE_DOC_URL = 'Email template doc URL';
const EMAIL_SUBJECT = 'Email subject';
const EMAIL_STATE = 'Email state';
// These represent whether an email was sent or not for a given row.
const EMAIL_STATE_VALUE = {
// Row indices.
const CUSTOMER_ID = 0;
const DATE = 1;
const AMOUNT = 2;
const MILLISECONDS_IN_MONTH = 1000 * 60 * 60 * 24 * 30;
/**
* Groups customers by their ID calculates
* customer lifetime value for each.
/**
* Calculates the total annual amount of an expense
* by multplying its amount by it's frequency.
*
* @param {number} amount - dollar cost of an expense.
* @param {number} frequency - annual, monthly, or weekly.
*
* @returns {number} - annual cost
*/
function ANNUAL_COST(amount, frequency) {
@TechandEco
TechandEco / Page.html
Created January 7, 2020 18:21
GSuite-samples/twilio-sheet/webapp/Page.html
<!DOCTYPE html>
<html>
<h1>Let's send you a text</h1>
<p>Please enter your phone number without any special characters or spaces.</p>
<label>Phone number: </label><input type="text" id="phoneInput" placeholder="ex: 9990001234">
<button id="submitButton">Submit</button>
<script>
document.getElementById('submitButton').addEventListener('click', function() {
// Get the value from the `phoneInput` text box.
@TechandEco
TechandEco / Code.gs in script editor
Last active January 7, 2020 18:23
GSuite-samples/twilio-sheet/webapp/Code.js
var SHEET_URL = 'ENTER_SPREADSHEET_URL_HERE';
/**
* Loads main web app page.
* Learm more about web apps:
* https://developers.google.com/apps-script/guides/web
*
* @param {Object} e - HTTP GET event.
*/
function doGet(e) {
@TechandEco
TechandEco / Code.gs in script editor
Last active February 14, 2022 15:43
GSuite-samples/twilio-sheet/send-sms/Code.js
// Spreadsheet column names mapped to 0-based index numbers.
var TIME_ENTERED = 0;
var PHONE_NUMBER = 1;
var MESSAGE = 2;
var STATUS = 3;
// Enter your Twilio account information here.
var TWILIO_ACCOUNT_SID = 'PASTE_TWILIO_ACCOUNT_ID_HERE_EX: ACa0072e7863c5d13b703e1e18f7cab1ee';
var TWILIO_SMS_NUMBER = 'PASTE_TWILIO_SMS_NUMBER_HERE_EX: 14155925860';
var TWILIO_AUTH_TOKEN = 'PASTE_TWILIO_AUTH_TOKEN_HERE_EX: AC4z072e7863c5d13b703e1e18f7cab1ee:046077789202b8d7166de7a0d3383d9f';
@TechandEco
TechandEco / Code.gs in script editor
Last active January 7, 2020 18:22
GSuite-samples/room_capacity/Code.js
/**
* Assigns a type of room needed for a session based on its number of
* registered participants.
*
* @param {number} numParticipants - number of participants.
*
* @returns {string} - size of room.
*/
function ROOM_TYPE(numParticipants) {
if (numParticipants <= 25) {
@TechandEco
TechandEco / appsscript.json
Created January 7, 2020 17:20
GSuite-samples/macro-analytics/appsscript.json
{
"timeZone": "America/Los_Angeles",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"sheets": {
"macros": [{
"menuName": "createChartsFromAnalytics",
"functionName": "createChartsFromAnalytics"
}]