Skip to content

Instantly share code, notes, and snippets.

View Blueprinter's full-sized avatar

Alan Wells Blueprinter

View GitHub Profile
@thexs-dev
thexs-dev / PayPal IPN Server.gs
Created March 24, 2018 19:48
Google Apps Script web app listening to PayPal IPN messages for subscriptions management
function doPost(e) {
try {
var sprops = backoff(function(){
return PropertiesService.getScriptProperties().getProperties();
});
var base = FirebaseApp.getDatabaseByUrl(sprops.firebaseUrl, sprops.firebaseSecret);
var glog = new cLog("IpnPaypal", sprops.RECEIVER_EMAIL); // just for logging errors
var isProduction = sprops.Production == "true";
@tivnet
tivnet / ACE Editor: submit, beautify and minify.html
Last active January 24, 2023 20:17
ACE Editor: submit, beautify and minify
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ACE Editor: submit, beautify and minify</title>
<style type="text/css" media="screen">
#ace_js, #ace_css {
width: 95%;
height: 15em;
border: 1px solid silver;
@brainysmurf
brainysmurf / concurrency.gs
Last active May 24, 2024 18:31
Concurrent processing in App Scripts
/**
* Pretends to take a long time to return two rows of data
*
* @param {string} endpoint
* @return {ResponseObject}
*/
function doSomething (endpoint) {
Utilities.sleep(5 * 1000); // sleep for 5 seconds
return {
numberOfRows: 2,
function onInstall(e) {
onOpen(e);
}
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Add Rules', 'showSidebar')
.addToUi();
currentSet("Default");
@rudimusmaximus
rudimusmaximus / bookendWithToast.gs
Last active April 7, 2018 18:28
In Google Apps script (for a sheet), use "bookend toast" messages to cleanly communicate with user when script has executed first and last line
/**
* Example use of a single pair of toast messages
*/
function doSomethingExample() {
//toast(msg, title, timeoutSeconds)
SpreadsheetApp.getActive().toast("Working...", "Doing x", 30);//message 1 longer than you need
Utilities.sleep(8000); //8 seconds simulating work
SpreadsheetApp.getActive().toast("Finished!","OK", 2);//message 2 interrupts message 1
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active July 3, 2024 08:29
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@erickoledadevrel
erickoledadevrel / FormSubmitFallback.gs
Last active April 9, 2022 18:56
Demonstrate how to create a form submit processing script that can handle missing or duplicate trigger firings.
// Change this values based on your spreadsheet.
var SHEET_NAME = 'Form Responses 1';
var STATUS_COLUMN_NUMBER = 4;
var PROCESSED_STATUS = 'Processed';
var LAST_ROW_KEY = 'lastRow';
var LOCK_TIMEOUT_MS = 60000; // 1 minute
var MAX_RUNTIME_MS = 240000; // 4 minutes
/**
@erickoledadevrel
erickoledadevrel / SendDocument.js
Last active November 30, 2022 12:57
Send a Google Doc in an email using Apps Script
/**
* Sends an email using the contents of a Google Document as the body.
*/
function sendDocument(documentId, recipient, subject) {
var html = convertToHtml(documentId);
html = inlineCss(html);
GmailApp.sendEmail(recipient, subject, null, {
htmlBody: html
});
}