Gists
This is a sample script for modifying the searched text to the small capital letters using Google Apps Script. Unfortunately, in the current stage, there are no methods for modifying the part of texts to the small capital letters in Document Service, yet. But when Google Docs API is used, this can be achieved.
When you use this script, please enable Google Docs API at Advanced Google Services and API console. You can see how to enable them at here
Overview
This is a GAS library for notifying the change of number of comments, stars and forks of own Gists as an email using Google Apps Script.
Description
Recently, I noticed that when a comment was posted to own Gists, and the numbers of stars and forks of own Gists were changed, the notification mail is not sent. Also I knew that in the current stage, there are no official methods for notifying them, yet. For this situation, I thought an application for notifying them as an email can be created using Google Apps Script, and when such application can be easily to be used, it may be useful for other users. So I created this as a GAS library.
Gists
ggsrun is also a CLI application for using Google Drive.
Here, I would like to introduce a sample command. This is a sample command for uploading a file to a shared folder using ggsrun.
This situation supposes that the shared folder is https://drive.google.com/drive/folders/abcdefg?usp=sharing and the folder has the edit permission.
Sample command:
$ ggsrun u -f "sample.txt" -p "abcdefg" --serviceaccount "###JSON file of Service Account###"
- If you have already used OAuth2, you can upload the file by
ggsrun u -f "sample.txt" -p "###folderId###".
Gists
Consumer (personal) version of Google+ is closed on April 2, 2019. By this, Apps Script community of Google+ is also closed. This is one of important communities for discussing. So in this post, I would like to introduce the other communities related to Google Apps Script.
-
As the next community of Apps Script community of Google+, Google Apps Script Community was launched.
-
Stackoverflow: https://stackoverflow.com/questions/tagged/google-apps-script
Gists
This is a sample script for parsing query parameters from an URL using Google Apps Script. Also this can be used at Javascript. The process cost becomes a bit lower than that of the script using the regular expression.
Sample script
function parseQuery(url) {
var query = url.split("?")[1];
if (query) {
return query.split("&")
.reduce(function(o, e) {
var temp = e.split("=");
var key = temp[0].trim();
var value = temp[1].trim();
value = isNaN(value) ? value : Number(value);
if (o[key]) {
o[key].push(value);
} else {
o[key] = [value];
}
return o;
}, {});
}
return null;
}
// Please run this function when you test this script.
function main() {
var url = "https://sampleUrl.com/sample?key1=value1&key2=value2&key1=value3&key3=value4&key2=value5";
var res = parseQuery(url);
Logger.log(res);
}
Result
{
"key1": [
"value1",
"value3"
],
"key2": [
"value2",
"value5"
],
"key3": [
"value4"
]
}
Gists
March 25, 2019
Published.
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.
Gists
This is a script for modifying the shading color of paragraph on Google Document using Google Apps Script.
Recently, by releasing Google Docs API, the shading color got to be able to be modified using the script. Here, I would like to introduce a sample script for modifying the shading color of the paragraph on Google Document. At the current Document Service, the shading color cannot be modified yet. I think that this will be achieved in the future update. At that time, I think that a new property might be added to Enum Attribute.
Gists
When a chart is created by using EmbeddedChartBuilder of Spreadsheet service, the title of vAxis which is put by setOption("vAxis", {title: "y axis"}) doesn’t work. It is considered that this is a bug. Because I have confirmed that this had worked fine. Ref But this specification had been changed. So I would like to introduce the method for adding the title of vAxis when a chart is created using Google Apps Script.
Overview
This is a script for extracting files from a tar file using Google Apps Script. This script was created by native Google Apps Script.
The following 3 situations gave me the motivarion for creating this script.
- Although I had been looking for the script for extracting files from a tar file from before, I have still not been able to find it.
- Unfortunately, there are no methods for extracting the files from the tar file in Google Apps Script. But fortunately, from wiki of tar, I could retrieve the structure information of the tar data. And I can also study by creating this script.
- I found this thread at Stackoverflow. By this, I could understand that other users also want the script for extracting files from the tar file.
So I created this.
Gists
This is a sample script for executing with the synchronous process using Node.js.
Sample script
function work(e) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(e);
resolve("ok" + e);
}, 1000);
});
}
async function main() {
var ar = [1, 2, 3, 4, 5];
for (var i = 0; i < ar.length; i++) {
console.log('start' + ar[i]);
await work(ar[i]).then((res) => console.log(res));
console.log('end' + ar[i]);
}
}
main(); // Run main().
Result
start1
1
ok1
end1
start2
2
ok2
end2
start3
3
ok3
end3
start4
4
ok4
end4
start5
5
ok5
end5