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
@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 April 29, 2025 08:20
Туториал по HTML препроцессору Pug (Jade)
@brainysmurf
brainysmurf / concurrency.gs
Last active February 9, 2025 15: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.
@mhawksey
mhawksey / appsscriptzoneids.csv
Last active August 11, 2024 12:46
ZoneIds used in Google Apps Script
value text
Pacific/Midway (GMT-11:00) Midway
Pacific/Niue (GMT-11:00) Niue
Pacific/Pago_Pago (GMT-11:00) Pago Pago
Pacific/Honolulu (GMT-10:00) Hawaii Time
Pacific/Johnston (GMT-10:00) Johnston
Pacific/Rarotonga (GMT-10:00) Rarotonga
Pacific/Tahiti (GMT-10:00) Tahiti
Pacific/Marquesas (GMT-09:30) Marquesas
America/Anchorage (GMT-09:00) Alaska Time
@jalcantarab
jalcantarab / _jsonPuller.md
Last active March 11, 2025 23:14 — forked from crstamps2/jsonPuller
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

@ttrahan
ttrahan / block_personal_appts
Last active May 6, 2025 17:17
Google Apps Script to automatically create, edit and delete events on work calendar for personal calendar events. Instructions on how to set up can be found at https://medium.com/@willroman/auto-block-time-on-your-work-google-calendar-for-your-personal-events-2a752ae91dab
function sync() {
var id="XXXXXXXXXX"; // CHANGE - id of the secondary calendar to pull events from
var today=new Date();
var enddate=new Date();
enddate.setDate(today.getDate()+7); // how many days in advance to monitor and block off time
var secondaryCal=CalendarApp.getCalendarById(id);
var secondaryEvents=secondaryCal.getEvents(today,enddate);