Skip to content

Instantly share code, notes, and snippets.

View oshliaer's full-sized avatar
😼
Cat face with wry smile

Alex Ivanov oshliaer

😼
Cat face with wry smile
View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active June 8, 2025 13:05
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.

@tanaikech
tanaikech / submit.md
Last active June 28, 2023 06:59
Benchmark: Event Objects for Google Apps Script

Benchmark: Event Objects for Google Apps Script

Introduction

There are event objects at Google Apps Script. Typically, users which use Spreadsheet often use onEdit(event). Here, I would like to introduce the process costs for the event objects using this onEdit(event).

When onEdit(event) is used for the spreadsheet, event of onEdit(event) has the following structure.

{
 "authMode": {},
@MSerj
MSerj / formatnumber.js
Created April 13, 2018 07:41
format number with spaces
function numberWithSpaces(nr) {
return nr.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
@brainysmurf
brainysmurf / testForSync.gs
Last active April 4, 2018 23:48
UrlFetchApp.fetchAll is definitely async.
/* The following code produces the following output in stackdriver log (newer logs higher):
Time for concurrent: 5.848 seconds.
Time for sleeping 10: 5.003 seconds.
Time for sleeping 2: 5.002 seconds.
Time for sleeping 9: 5.004 seconds.
Time for sleeping 8: 5.002 seconds.
Time for sleeping 5: 5.003 seconds.
Time for sleeping 3: 5.003 seconds.
Time for sleeping 1: 5.003 seconds.
Time for sleeping 7: 5.003 seconds.
(function(global,name,Package,helpers){var ref=function wrapper(args){var wrapped=function(){return Package.apply(global.Import&&Import.module?Import._import(name):global[name],[global].concat(Array.prototype.slice.call(arguments)))};for(i in args){wrapped[i]=args[i]}return wrapped}(helpers);if(global.Import&&Import.module){Import.register(name,ref)}else{Object.defineProperty(global,name,{value:ref});global.Import=global.Import||function(lib){return global[lib]};Import.module=false}})(this,
"Requests",
function RequestsPackage_ (global, config) {
var self = this, discovery, discoverUrl;
discovery = function (name, version) {
return self().get('https://www.googleapis.com/discovery/v1/apis/' + name + '/' + version + '/rest');
};
@tanaikech
tanaikech / submit.md
Last active April 11, 2025 11:43
Append Values by Inserting Rows using Google Sheets API

Append Values by Inserting Rows using Google Sheets API

In the case appending values to cell by inserting rows, when sheets.spreadsheets.values.append is used, the values are appended to the next empty row of the last row. If you want to append values to between cells with values by inserting row, you can achieve it using sheets.spreadsheets.batchUpdate.

When you use this, please use your access token.

Endpoint :

POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate
@neretin-trike
neretin-trike / pug.md
Last active July 11, 2026 02:01
Туториал по HTML препроцессору Pug (Jade)
@brainysmurf
brainysmurf / concurrency.gs
Last active June 4, 2026 19:51
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,
@tanaikech
tanaikech / submit.md
Created January 19, 2018 01:13
Batching Requests for Google Apps Script

Batching Requests for Google Apps Script

There is the bathing requests in the Google APIs. The bathing requests can use the several API calls as a single HTTP request. By using this, for example, users can modify filenames of a lot of files on Google Drive. But there are limitations for the number of API calls which can process in one batch request. For example, Drive API can be used the maximum of 100 calls in one batch request.

The following sample script modifies the filenames of 2 files on own Google Drive using Google Apps Script. Drive API for modifying filenames is used as "PATCH". The batch request including 2 API calls of Drive API is called using "multipart/mixed". If you want more APIs, please add the elements to the array of "body".

function main() {
  var body = [
    {
 method: "PATCH",
@tanaikech
tanaikech / submit.md
Last active July 26, 2023 16:07
Automatic Recalculation of Custom Function on Spreadsheet Part 1

Automatic Recalculation of Custom Function on Spreadsheet Part 1

In this report, I would like to introduce a workaround for automatically recalculating custom functions on Spreadsheet.

1. Situation

The sample situation is below. This is a sample situation for this document.

  • There are 3 sheets with "sheet1", "sheet2" and "sheet3" of sheet name in a Spreadsheet.
  • Calculate the summation of values of "A1" of each sheet using a custom function.
  • Sample script of the custom function is as follows.