Skip to content

Instantly share code, notes, and snippets.

@tanaikech
tanaikech / submit.md
Created October 15, 2021 00:39
Large Decimal Numbers and Exponential Notation for Google Spreadsheet

Large Decimal Numbers and Exponential Notation for Google Spreadsheet

In this report, it has investigated the large decimal numbers and the exponential notation for Google Spreadsheet. When the large decimal numbers are put to the Spreadsheet, the Spreadsheet automatically sets the display value using the exponential notation. In this report, the result when the values are retrieved by Spreadsheet service and Sheets API is shown.

Sample script

At first, please create new Spreadsheet and open the script editor. And please copy and paste the following script. And, please enable Sheets API at Advanced Google services.

function myFunction() {
@tanaikech
tanaikech / submit.md
Created September 22, 2021 07:04
Executing Function with Minutes timer in Specific Times using Google Apps Script

Executing Function with Minutes timer in Specific Times using Google Apps Script

This is a sample script for executing a function with the minutes timer in the specific times using Google Apps Script. For example, when this sample script is used, the following situation can be achieved.

  • Execute a function every 10 minutes only in 09:00 - 12:00 and 15:00 - 18:00 for the weekday.

When the above situation is shown as an image, it becomes as follows.

@tanaikech
tanaikech / submit.md
Last active December 23, 2022 07:29
Using Google API Client Library (gapi) for JavaScript with Service Account

Using Google API Client Library (gapi) for JavaScript with Service Account

This is a sample script for using Google API Client Library (gapi) for JavaScript with the service account. Unfortunately, in the current stage, gapi cannot directly use the service account. So, in this case, it is required to implement the script for retrieving the access token from the service account. In this report, I would like to introduce the method for using gapi with the service account using a Javascript library.

Sample script

In this sample script, GetAccessTokenFromServiceAccount_js of Javascript library is used. Before you use this script, please set your private_key, client_email and scopes to the variable of object.

<input type="button" value="Run" onClick="run()" />
@tanaikech
tanaikech / submit.md
Last active November 8, 2021 08:25
XPath Tester using Web Apps Created by Google Apps Script

XPath Tester using Web Apps Created by Google Apps Script

In this post, I would like to introduce the xpath tester using Web Apps created by Google Apps Script.

Demo

Usage

@Max-Makhrov
Max-Makhrov / email_to_me.gs
Created December 3, 2020 08:23
Write emails to myself from Google Script functions
function someImportantFunction() {
// [ 1 ]. do some stuff
//
//
//
Logger.log('Success!');
// [ 2 ]. Report the execution
var recipient = 'makhrov.max@gmail.com'; // change!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
@tanaikech
tanaikech / submit.md
Last active May 31, 2022 01:44
Request of multipart/form-data with Simple Request Body using Google Apps Script

Request of multipart/form-data with Simple Request Body using Google Apps Script

This is a sample script of the request of multipart/form-data with a simple request body using Google Apps Script. I hope that the users will easy to use Class UrlFetchApp by this report.

This report is the updated post of "Multipart-POST Request Using Google Apps Script".

Description

I had already reported about this at this report. In that case, it was required to create a bit complicated request body to request multipart/form-data. Today, by a comment, I could notice the sample script of Class UrlFetchApp in the official document had been updated. By this, I thought that multipart/form-data

@tanaikech
tanaikech / submit.md
Last active March 1, 2024 12:17
Logs in Web Apps for Google Apps Script

Logs in Web Apps for Google Apps Script

This is a report for retrieving the logs in Web Apps for Google Apps Script, when it requests to the Web Apps.

Experimental condition

1. Sample script for Web Apps

const doGet = (e) =&gt; {
@tanaikech
tanaikech / submit.md
Last active March 15, 2024 19:31
Sample Scripts for Requesting to Web Apps by Various Languages
@Max-Makhrov
Max-Makhrov / gist:5a36610a2dd1eaff3d3252d74e34d557
Last active April 23, 2024 22:02 — forked from peterherrmann/gist:2700284
GASRetry - Exponential backoff JavaScript implementation for Google Apps Script (Library project key: "MGJu3PS2ZYnANtJ9kyn2vnlLDhaBgl_dE")
/**
* Invokes a function, performing up to 5 retries with exponential backoff.
* Retries with delays of approximately 1, 2, 4, 8 then 16 seconds for a total of
* about 32 seconds before it gives up and rethrows the last error.
* See: https://developers.google.com/google-apps/documents-list/#implementing_exponential_backoff
* <br>Author: peter.herrmann@gmail.com (Peter Herrmann)
<h3>Examples:</h3>
<pre>//Calls an anonymous function that concatenates a greeting with the current Apps user's email
var example1 = GASRetry.call(function(){return "Hello, " + Session.getActiveUser().getEmail();});
</pre><pre>//Calls an existing function
@tigt
tigt / git-branch-to-favicon.js
Created March 18, 2020 21:10
Creates an SVG string that can be used as a favicon across different Git branches. Actually getting this into the browser is sadly project-specific.
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
const hash = createHash('sha256')
hash.update(branchName)
const color = '#' + hash.digest().toString('hex').substring(0, 6)
const invertedColor = invertColor(color, true)