This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function start() { | |
const REGION = "us-central1"; | |
const GCP_PROJECT_ID = "gcp-kutil"; | |
const task = ` | |
- Create a new label 'DEMO' in Gmail | |
- create only if it did not exist. | |
- Load last 10 emails with subject 'Security alert'. | |
- SET this new label 'DEMO' to found emails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Agent() { | |
const ticks = "```"; | |
this.person = ` | |
Person | |
- You are Google Apps Script expert developer, who is able to generate valid code for V8 runtime | |
- Your goal is to create code for defined task | |
- Return only code in markdown between ${ticks}javascript and ${ticks} | |
- Return all code in one big function named main(). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"timeZone": "Europe/Prague", | |
"exceptionLogging": "STACKDRIVER", | |
"runtimeVersion": "V8", | |
"oauthScopes": [ | |
"https://www.googleapis.com/auth/cloud-platform", | |
"https://www.googleapis.com/auth/script.external_request", | |
"https://mail.google.com/", | |
"https://www.googleapis.com/auth/drive", | |
"https://www.googleapis.com/auth/spreadsheets", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Get filtered rows from Google Sheets | |
@author Ivan Kutil | |
Preparation: add Advanced service "Sheets" into Google Apps Script project | |
*/ | |
function getFilteredRows() { | |
console.time("filtered-rows") | |
let spreadsheetId = SpreadsheetApp.getActive().getId(); | |
let sheetName = "MySheetName" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Apps Script code snippet based on GCPping.com | |
@author Ivan Kutil | |
*/ | |
var URLS = { | |
"asia-east1": "http://104.155.201.52/ping", | |
"asia-east2": "http://35.220.162.209/ping", | |
"asia-northeast1": "http://104.198.86.148/ping", | |
"asia-south1": "http://35.200.186.152/ping", | |
"asia-southeast1": "http://35.185.179.198/ping", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
return HtmlService.createTemplateFromFile("view").evaluate(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SPREADSHEET_ID = "xxxxx"; // <-- Google Spreadsheet ID | |
var settings = { | |
nomadland : "xxxxxx" // <--- subtitles fileId | |
} | |
function RUN() { | |
var movie = "nomadland" | |
var fileId = settings[movie]; | |
var output = subitlesParser(fileId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get sentiment from Google Cloud Natural Language API | |
*/ | |
var getSentiment = function(text) { | |
var apiKey = PropertiesService.getScriptProperties().getProperty("apiKey") | |
var url = "https://language.googleapis.com/v1/documents:analyzeSentiment?key=%KEY".replace("%KEY", apiKey) | |
var data = { | |
document: { | |
language: "en-us", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var subitlesParser = function(fileId) { | |
var agregated = false; | |
var CHARS = "-->"; | |
var BATCH_SIZE = 2; // time-window (e.g. 2minutes) | |
var epoch = 0; | |
var text = []; | |
var output = []; | |
var content = DriveApp.getFileById(fileId).getBlob().getDataAsString(); | |
var rows = content.split("\n"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function START() { | |
var url = "https://hooks.slack.com/services/xxxxxx/xxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
var payload = { | |
"channel" : "#test", // <-- optional parameter, use if you want to override default channel | |
"username" : "robot", // <-- optional parameter, use if you want to override default "robot" name | |
"text" : "It's working", // <-- required parameter | |
"icon_emoji": ":robot_face:", // <-- optional parameter, use if you want to override default icon, | |
//"icon_url" : "http://image" // <-- optional parameter, use if you want to override default icon |