tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

URL Encode with Shift-JIS using Google Apps Script

Gists

This is a sample script for achieving the URL encode with Shift-JIS using Google Apps Script.

Unfortunately, there are no methods for directly achieving above in the methods of Google Apps Script. So it is required to prepare it as the script. In order to use Shift-JIS of the character set at Google Apps Script, it is required to use it as the binary data. Because, when the value of Shift-JIS is retrieved as the string by Google Apps Script, the character set is automatically changed to UTF-8. Please be careful this.

Libraries of gdoctableapp for golang, Node.js and python were updated to v110

Libraries of gdoctableapp for golang, Node.js and python were updated to v1.1.0

Libraries of gdoctableapp for golang, Node.js and python were updated to v105

Libraries of gdoctableapp for golang, Node.js and python were updated to v1.0.5

Update History

  • v1.0.5 (January 21, 2020)

    • When the inline objects and tables are put in the table. An error occurred. This bug was removed by this update.
  • I got the pull request at here.

Deleting Last Empty Page of Google Document using Google Apps Script

Gists

Overview

This is a sample script for deleting the last empty page which has only one paragraph including no values which is "" in the Google Document using Google Apps Script.

Description

As a sample situation, it supposes that there is the following Google Document.

In this sample, the last page of Google Document has only one paragraph including no values which is "". When I try to delete only last page without modifying the previous page, I noticed that this cannot be achieved with only Google Document service. For example, it try to delete the paragraph of the last page using the following scripts,

Trend of google-apps-script Tag on Stackoverflow 2020

Gists

Published: January 10, 2020

Kanshi Tanaike

Introduction

At Stackoverflow, a lot of people post the questions and answers to the questions every day. There are various tags in Stackoverflow. A lot of discussions are performed at each tag. Their discussions bring the important information and are much useful for a lot of people. As one of tags, there is “google-apps-script”. I sometimes discuss at the questions with that tag. When we see the discussions, we can notice that the discussions are changed and progressed by the time, because “Google Apps Script” which is the origin of the tag is updated. This report thinks this change as the trend of tag of “google-apps-script”. This trend includes the number of questions, questioners, answerers and tags adding to the tag of “google-apps-script”. The trend of tag of “google-apps-script” is deeply related to the progression of Google Apps Script and the various applications for Google Apps Script.

Retrieving Event ID from Event URL of Google Calendar using Google Apps Script

Gists

This is a sample script for retrieving the event ID from the event URL of Google Calendar using Google Apps Script.

The event URL is like https://www.google.com/calendar/event?###. At the event URL, ### of https://www.google.com/calendar/event?### is not the event ID. So it is required to convert it.

Sample script

var eventUrl = "https://www.google.com/calendar/event?###";
var eventId = Utilities.newBlob(Utilities.base64Decode(eventUrl.split("=")[1]))
  .getDataAsString()
  .split(" ")[0];
Logger.log(eventId);

Running Google Apps Script by Event Notification from Google Calendar

Gists

Overview

This is a simple method running Google Apps Script by the event notification from Google Calendar.

Description

There are several event triggers in Google Apps Script. Ref1, Ref2 There is an event trigger for Google Calendar. The official document says An installable calendar event trigger runs when a user's calendar events are updated—created, edited, or deleted.. Ref3 If I want to use the trigger when the event in the calendar is starts and finished, it is required to use Calendar API by preparing the URL for receiving from Google. Ref4, Ref5 Also, there is the method that the start time are retrieved from all event lists and run the script for each start time. But in this case, it is required to check new events and manage the time-driven triggers for running the script. I thought that those are the higher hurdle for me. So I thought a workaround.

Music Streaming Player for Discord with Google Drive using Node.js

Gists

Overview

This is a sample script for the music streaming player for Discord with Google Drive using Node.js.

Description

This sample script can achieve to play the music when uses the voice channel on Discord. The music files are put in the specific folder of Google Drive. This script downloads all music files and plays the music files at the voice channel with the stream.

Usage

1. Register BOT to Discord

At first, please register your BOT to Discord. And please retrieve the token.