Skip to content

Instantly share code, notes, and snippets.

View techstreams's full-sized avatar

Laura Taylor techstreams

View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active January 13, 2024 07:38
Disabling Buttons Put on Google Spreadsheet using Google Apps Script

Disabling Buttons Put on Google Spreadsheet using Google Apps Script

Description

This is a sample script for disabling the buttons put on Google Spreadsheet using Google Apps Script.

When a script is run by clicking a button on Google Spreadsheet, there is the case that you don't want to make users run the script in duplicate. This sample script achieves this situation.

Demo

@Oaphi
Oaphi / asyncGAPI.js
Last active February 24, 2021 15:27
Async-friendly google.script.run utility
/**
* Promise-friendly google.script.run call
* @param {String} funcName
* @param {...*} params
* @returns {Promise}
*/
const asyncGAPI = (funcName, ...params) => {
return new Promise((res, rej) => {
google.script.run
.withSuccessHandler(data => res(data))
@dsottimano
dsottimano / gist:e3e6294f80cb1cbb526d1defed322850
Last active January 5, 2024 20:01
Tech seo boost 2019 - Dave Sottimano - Apps script demo
//serpApiKey from serpapi.com
var GLOBAL_VARIABLES = {
serpApiKey : "add your api key"
}
/*
/***************************
/BEGIN PRESENTATION SCRIPTS
@tanaikech
tanaikech / submit.md
Created November 11, 2019 05:44
Figma to Google Slides using Google Apps Script

Figma to Google Slides using Google Apps Script

In this sample script, all pages in the Figma file are retrieved and the retrieved pages are put to new Google Slides as the image.

Usage

1. Retrieve access token

You can see the method for retrieving the access token at here. Although there is also OAuth2 for retrieving the access token, in your situation, I thought that the method for directly generating the access token on the site might be suitable. So in this answer, the generated access token on the site is used. Please retrieve the access token as follows.

/**
* Get a GCS Signed URL
*
* @param {object} JSON credential
* @param {string} the base URL to sign
* @param {string} optional; TTL in seconds, defaults to 60
* @param {string} optional; the httpVerb, eg. 'GET','POST'; defaults to 'GET' if not specified
* @param {string} optional; the content type, ie. one of the valid mime content types. Your HTMLService HTTP header must set have a matching content type
* @return {string} The complete URL.
* @private
@tanaikech
tanaikech / submit.md
Last active January 4, 2025 17:30
Multipart-POST Request Using Google Apps Script

Multipart-POST Request Using Google Apps Script

April 20, 2019: GAS library for this situation was published. Please check it at https://github.com/tanaikech/FetchApp.

These sample scripts are for requesting multipart post using Google Apps Script.

In most cases, the multipart request is used for uploading files. So I prepared 2 sample situations as follows. For each situation, the request parameters are different.

  1. Upload a file from Google Drive to Slack.
  2. Convert an excel file to Spreadsheet on Google Drive using Drive API v3.
@erickoledadevrel
erickoledadevrel / Timezones.gs
Last active July 8, 2020 11:42
Some examples showing how to work with timezones in Apps Script.
// Setup: Spreadsheet in Pacific time, Script in Eastern time, Calendar in Mountain time.
// Sample spreadsheet: https://docs.google.com/spreadsheets/d/1neePK1YPKMKnVwI8dld0HSJjI1kSFPpcY8g7kG8xG4U/edit#gid=0
// A2 = 3/1/2016 9:00 AM, B2 = 3/1/2016 10:00 AM
/**
* The dates and times in the spreadsheet refer to exact moments in time, and the clock
* on the wall may show a different time.
*/
function copyMoment() {
var ss = SpreadsheetApp.getActive();
@abhijeetchopra
abhijeetchopra / 0-README.md
Last active July 20, 2025 14:01
Creating automatic scheduled backup copies of your Google Sheets using Google Apps Script

How to "Schedule Automatic Backups" of your Google Sheets

This tutorial demonstrates how to use Google Apps Script to:

  • Create copies of the Google Sheet in the desired destination folder automatically at set intervals.

  • Append the time stamp with each backup file's name.

  • Adjust time trigger for backing up every day/hour/minute.

@erickoledadevrel
erickoledadevrel / Code.gs
Created February 19, 2016 14:38
Create a Google Calendar event with an attachment in Apps Script
function createEventWithAttachment() {
var driveFileId = '...';
var file = DriveApp.getFileById(driveFileId);
var event = {
summary: 'Test Event with Attachments',
description: 'Woot!',
attachments: [{
fileId: driveFileId,
fileUrl: file.getUrl(),
mimeType: file.getMimeType(),
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active July 8, 2025 10:31
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