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

The Thinker

Benchmark: Retrieving Values from Deep Nested JSON at Golang

This sample script is for retrieving values from a deep nested JSON. There are 2 patterns. So for these, the benchmark were measured. Script : package main import ( "encoding/json" "testing" ) const ( data = `{ "A_key1": { "B_key1": { "C_key": "value" } } }` ) func BenchmarkB1(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { var p map[string]interface{} json.Unmarshal([]byte(data), &p) a1 := p["A_key1"] a2 := p["A_key1"].

Reopening Current File as a File with New Name at Sublime

This is for Sublime Text. This sample is for reopening current file as a file with new file name. The current file is closed when reopening a new file. newfilename = "new file name" contents = self.view.substr(sublime.Region(0, self.view.size())) window = self.view.window() window.run_command('close_file') view = window.new_file() view.set_name(newfilename) view.settings().set("auto_indent", False) view.run_command("insert", {"characters": contents}) view.set_scratch(True) view.run_command("prompt_save_as") Flow of this sample Copy all text on current file to memory (contents). Close current file. Create new file with new file name.

Search Route and Embedding Map using Custom Function on Spreadsheet

This sample script is for searching route between place A and B and embedding a map by custom function on Spreadsheet. I think that this method is one of various ideas. Problem When the map is embedded to a cell on spreadsheet as an image, the function =IMAGE() is suitable for this situation. However, Class Maps, setFormula() for importing =IMAGE() and DriveApp.createFile() for creating images from maps also cannot be used for custom functions.

Updated: CLI Tool - goris

goris is a CLI tool to search for images with Google Reverse Image Search. Today, it was updated to v1.1.0. Please check it out. https://github.com/tanaikech/goris When images are matched to a searched image, web pages with matching images are retrieved. These are web pages displayed on Google top page. When this is not used, images are retrieved. This was added as a boolean option. (This was added by a request.)

Giving and Retrieving Parameters for Chart at GAS

This sample script is for retrieving parameters from a chart. The chart created by both Google Apps Script and manually operation can be used. Creates Chart When a chart is created, it supposes following parameters. var parameters = { "title": "x axis", "fontName": "Arial", "minValue": 0, "maxValue": 100, "titleTextStyle": { "color": "#c0c0c0", "fontSize": 10, "fontName": "Roboto", "italic": true, "bold": false } }; .