Skip to content

Instantly share code, notes, and snippets.

@acurtis517
acurtis517 / submit.md
Created June 8, 2025 13:05 — forked from tanaikech/submit.md
Benchmark: Loop for Array Processing using Google Apps Script without V8

Benchmark: Loop for Array Processing using Google Apps Script without V8

April 16, 2018 Published.

July 26, 2018 Updated. Result of reduce was added.

@acurtis517
acurtis517 / submit.md
Created May 26, 2025 15:56 — forked from tanaikech/submit.md
Uploading File to Google Drive using HTML and Google Apps Script

Uploading File to Google Drive using HTML and Google Apps Script

This is a simple sample script for uploading a file using the file input tag of HTML. As the important point, the file is sent as the byte array for using Google Apps Script. By this, at Google Apps Script side, the byte array can be converted to a blob using a simple script.

HTML & Javascript

<input id="file" type="file" onchange="saveFile(this)" />
<script>
 function saveFile(f) {
@acurtis517
acurtis517 / script.gs
Created May 26, 2025 15:37 — forked from Richienb/script.gs
Load external JavaScript libraries in Google Script
// Load JS from HTML file
eval(HtmlService.createTemplateFromFile("<SCRIPT>").getRawContent())
// Load JS from URL
eval(UrlFetchApp.fetch("<SCRIPT>").getContentText())
// Load JS from Google Drive
eval(DriveApp.getFileById("<SCRIPT>").getBlob().getDataAsString())
// Load JS from URL into global namespace
@acurtis517
acurtis517 / removeDuplicateFiles.gs
Created May 26, 2025 15:22 — forked from burak-kara/removeDuplicateFiles.gs
Google Drive - Remove duplicate files (files with the same name) from a folder and its subfolders. Keeps only one copy. Also, deletes a folder if it becomes empty
// Put the ID of the folder you want to process
// https://drive.google.com/drive/folders/abcdefgh
const id = "abcdefgh";
// we will store file names in this dictionary.
// using Set could be more efficient to check if it contains file (time complexity: O(1))
// App Script does not support Set
const allFiles = [];
// Keep deleted file URLs and report in the end
@acurtis517
acurtis517 / submit.md
Created May 25, 2025 16:36 — forked from tanaikech/submit.md
Report: Documentation Comments including JsDoc for Functions of Google Apps Script

Report: Documentation Comments including JsDoc for Functions of Google Apps Script

This is a report for the documentation comments for the functions of Google Apps Script.

When the documentation comments for functions of Google Apps Script are considered, you will think JsDoc. At Google Apps Script, a part of JsDoc can be used. But, in this report, I would like to introduce the documentation comments including JsDoc.

Sample situations

Sample 1

@acurtis517
acurtis517 / md5.gs
Created May 23, 2025 03:56 — forked from KEINOS/md5.gs
GAS(Google Apps Script) user function to get MD5 hash or 4digit shortened hash for Multibyte(UTF-8, 2bytes character) environment.
/**
* ------------------------------------------
* MD5 function for GAS(GoogleAppsScript)
*
* You can get a MD5 hash value and even a 4digit short Hash value of a string.
* ------------------------------------------
* Usage1:
* `=MD5("YourStringToHash")`
* or
* `=MD5( A1 )`
@acurtis517
acurtis517 / UrlFetchAppWithRetries.gs
Created May 21, 2025 13:36 — forked from mayrsascha/UrlFetchAppWithRetries.gs
Retriable requests batch for Google Apps Scripts. Originally seen on https://medium.com/@sidehacker/nice-did-you-consider-making-this-a-gas-library-dee19ce3db4a. Install it by adding the library script ID "16rm4lelUzHsrF_vLJOwYFh6HvnZHM5LhT8zOn45YvdeQdsZVZmlIOhDP".
/**
* --- UrlFetchApp WITH retries ---
*
* Don't let your script fail easily because of bad API uptime.
*
* Calls provided HTTP requests batch and retries in case of errors. This function has the same
* params and return value as URLFetchApp.fetchAll().
* https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl-params
*
* @param {Array<object>} requests - Array of request param objects
@acurtis517
acurtis517 / submit.md
Created May 18, 2025 23:24 — forked from tanaikech/submit.md
Creating Shortcut on Google Drive using Google Apps Script

Creating Shortcut on Google Drive using Google Apps Script

This is a sample script for creating a shortcut on Google Drive using Google Apps Script.

Sample script

Before you run the script, please enable Drive API at Advanced Google services.

function createShortcut(targetId, name, folderId) {
@acurtis517
acurtis517 / submit.md
Created May 18, 2025 11:55 — forked from tanaikech/submit.md
Streamlining Gmail Processing Including Attachment Files Using Gemini with Google Apps Script

Streamlining Gmail Processing Including Attachment Files Using Gemini with Google Apps Script

Abstract

A new library, MimeTypeApp, simplifies using Gmail messages and attachments with the Gemini API for tasks like text analysis. It converts unsupported formats for seamless integration with Google Apps Script and Gemini.

Introduction

@acurtis517
acurtis517 / submit.md
Created May 18, 2025 11:54 — forked from tanaikech/submit.md
Workaround: Smart Chips with Google Apps Script

Workaround: Smart Chips with Google Apps Script

Description

Now, Google Docs and Google Sheets can insert smart chips. Smart chips are very useful for easily inserting information like users, maps, files, and so on. However, unfortunately, at the current stage, smart chips cannot be directly managed using Google Apps Script. Specifically, the information within smart chips cannot be directly retrieved by Google Apps Script. Although I believe this will be resolved in a future update, there might be cases where you want to retrieve information from smart chips using Google Apps Script. This report introduces a workaround for achieving this.

Workaround

The flow of workaround in this report is as follows.