Skip to content

Instantly share code, notes, and snippets.

Avatar
😋

Max Makhrov Max-Makhrov

😋
View GitHub Profile
@tanaikech
tanaikech / submit.md
Created Oct 8, 2021
Compiling Continuous Numbers using Google Apps Script
View submit.md

Compiling Continuous Numbers using Google Apps Script

This is a sample script for compiling the continuous numbers using Google Apps Script. For example, the values of [4, 5, 9, 3, 10, 5, 11, 7, 7, 13, 1] are converted to ["1","3-5","7","9-11","13"].

Sample script

const compilingNumbers = (ar) => {
  const { values } = [...new Set(ar.sort((a, b) => a - b))].reduce(
    (o, e, i, a) => {
@tanaikech
tanaikech / submit.md
Created Sep 27, 2021
Directly Submitting Answers to Google Form using Google Apps Script
View submit.md

Directly Submitting Answers to Google Form using Google Apps Script

This is a sample script for directly submitting answers to Google Form using Google Apps Script.

The sample Google Form is as follows.

For this Google Form, this sample script submits the values of sample text, option2 and option1, option2, sample option to Google Form.

@tanaikech
tanaikech / submit.md
Last active Jun 2, 2021
Retrieving Hidden Rows and Showing Rows by Filter View on Google Spreadsheet using Google Apps Script
View submit.md

Retrieving Hidden Rows and Showing Rows by Filter View on Google Spreadsheet using Google Apps Script

This is a sample script for retrieving the hidden rows and showing rows by the filter view on Google Spreadsheet using Google Apps Script. In the current stage, there are no methods for directly retrieving the hidden rows and showing rows by the filter view in Spreadsheet service (SpreadsheetApp). And, isRowHiddenByFilter of Class Sheet cannot be used for the filter view. But, fortunately, when Sheets API is used, the filter view can be retrieved and created. In this report, the hidden rows and showing rows by the filter view are retrieved using Sheets API.

The flow of this script is as follows.

  1. Retrieve the settings of the filter view (filterViews) you want to use.
    • In this case, the method of "spreadsheets.get" can be used.
  2. Create new basic filter to the sheet you want to use using the retrieved settings of the filter view.
    • In this case, the method of "spreadsheets.batchUpdate" can
@tanaikech
tanaikech / submit.md
Last active May 19, 2021
Benchmark: Process Costs for Retrieving 1st Empty Cell and 1st Non Empty Cell of Specific Column in Google Spreadsheet using Google Apps Script
View submit.md

Benchmark: Process Costs for Retrieving 1st Empty Cell and 1st Non Empty Cell of Specific Column in Google Spreadsheet using Google Apps Script

Introduction

Here, I would like to report the process costs for retrieving the 1st empty cell or 1st non empty cell of the specific column of Google Spreadsheet using Google Apps Script (GAS). For this situations, the following 2 patterns can be considered.

  1. Retrieving 1st empty cell of specific column by searching from TOP of sheet

  2. Retrieving 1st NON empty cell of specific column by searching from BOTTOM of sheet

@pfelipm
pfelipm / generated.photos.gs
Last active Apr 28, 2021
Get faces generated from scratch by AI using generated.photos API
View generated.photos.gs
/**
* generated.photos API demo >> Faces generated from scratch by AI
*
* 1. Get API key at https://generated.photos/api
* 2. Make a copy of https://docs.google.com/spreadsheets/d/1RkLy6e0h1QURtsOj1gsAfWGzvAUua0yIky_THy8ut1Q
* 3. Write your API key inside cell C3 (don't share!)
*
* Please, note:
* - Just 50 API calls/month! (API free plan)
* - Some trait combinations apparently fail to return results :-?
@tanaikech
tanaikech / submit.md
Created Apr 27, 2021
Specification of Search Query for File List Method in Drive API
View submit.md

Specification of Search Query for File List Method in Drive API

In this report, I would like to report about the current specification of the search query for the file list method in Drive API.

Recently, I noticed that the specification of the search query for the file list method in Drive API might have been changed. I thought that to know the change of specification of the search query is important for creating the application using Drive API. In this report, I would like to introduce the current specification of the search query.

Experiments

I have done the following 5 experiments.

@tanaikech
tanaikech / submit.md
Created Apr 19, 2021
Creating Colorful Buttons on Google Spreadsheet using Google Apps Script
View submit.md

Creating Colorful Buttons on Google Spreadsheet using Google Apps Script

This is a sample script for creating the colorful buttons on Google Spreadsheet on Google Apps Script.

In order to achieve this, I have been looking for the method for creating the PNG image with the alpha channel using Google Apps Script. Recently, finally, I could find it. By this, the goal of this report got to be able to be achieved by the report of "Creating PNG Image with Alpha Channel using Google Apps Script".

Demo

@pfelipm
pfelipm / Text2GzipBlob.gs
Last active May 10, 2021
From UNICODE text to gzipped blob encoded as text and back using Apps Script
View Text2GzipBlob.gs
/**
* These two functions:
* 1. Transform a UNICODE string to blob, compress and encode it as text using two different methods (base64 or JSON.stringify)
* 2. Reverse de process
*/
function testTextoGzipBlob() {
// Method 1: base64Encode (better compression):
// Text >> Blob >> gzip >> getBytes Byte[] >> *base64Encode* text >> [cache key/value] >> *base64Decode* Byte[] >> Blob >> ungzip >> Text 😅
@tanaikech
tanaikech / submit.md
Created Jan 13, 2021
Creating Custom Grid View of Google Slides as Image and Spreadsheet using Google Apps Script
View submit.md

Creating Custom Grid View of Google Slides as Image and Spreadsheet using Google Apps Script

This is a sample script for creating the custom grid view of Google Slides as an image using Google Apps Script.

Demo

Usage

@tanaikech
tanaikech / submit.md
Last active Nov 20, 2020
Converting Texts to Bold, Italic and Bold-Italic Types of Unicode using Google Apps Script
View submit.md

Converting Texts to Bold, Italic and Bold-Italic Types of Unicode using Google Apps Script

This is a sample script for converting the texts to the bold, italic, bold-italic types, underline and strike through of the unicode using Google Apps Script. In the current stage, at Google Docs (Spreadsheet, Document, Slides and so on), the rich texts cannot be directly managed for all places using Google Apps Script. But there are the places which can use the bold, italic and bold-italic fonts with the unicode. This sample script uses this. When this sample script is used, for example, the bold, italic and bold-italic texts can be put using SpreadsheetApp.getUi().alert(convertedText).

Sample script

const conv = {