tanaike

The Thinker

Go Library - getcode

Overview This is a Golang library to automatically get an authorization code for retrieving access token using OAuth2. Description When it retrieves an access token and refresh token using OAuth2, the code for retrieving them has to be got by authorization on own browser. In order to retrieve the code, in generally, users have to click the authorization button and copy the code on the browser. This library can be automatically got the code by launching HTML server as a redirected server.

Retrieving Access Token for Google APIs

Gists This sample is for retrieving access token for Google APIs. I created this for studying newStateToken(). Preparation In order to use this sample, please do as follows. Deploy and launch Web Apps for retrieving redirect uri On the Script Editor File -> Manage Versions -> Save New Version Publish -> Deploy as Web App -> At Execute the app as, select “your account” -> At Who has access to the app, select “Only myself” -> Click “Deploy” -> Click “latest code” (By this click, it launches the authorization process.

Updated: GAS Library - SOUWA

SOUWA means summing in Japanese. SOUWA can sum string elements in an array at the high speed. The speed of SOUWA with the pyramid algorithm is about 380 times faster than that of the standard method. New algorithm for summing array elements was developed for SOUWA. You can see the detailed report of this library at here. If you are interested in this, I’m glad. It was updated to v1.0.2. Please check it out.

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.