Updated: CLI Tool - gislack
gislack is a CLI tool to submit files to both Gist and Slack.
- v1.0.1 (June 30, 2017)
- Some modifications related to error handling.
Please check it out. https://github.com/tanaikech/gislack
gislack is a CLI tool to submit files to both Gist and Slack.
Please check it out. https://github.com/tanaikech/gislack
ImgApp was updated to v1.1.0. New method was added.
This method is for resizing images.
Unfortunately, there are no methods to resize images at Google Apps Script. As a workaround, there is a method that it imports the image in Google Document and resizes the image using setWidth() and setHeight(). But in this method, the resized blob cannot be retrieved. So although I had thought of other workaround, I had not been able to find it. Recently, I accidentally discovered the other workaround doResize(). Since it was found that this workaround can be surely used, I added this to ImgApp.
This method is for retrieving the width and height of image as the unit of pixel.
Unfortunately, there are no methods to directly retrieve the image size at Google Apps Script. As a workaround, there is a method that it imports the image in Google Document and retrieves the size using getWidth() and getHeight(). But in this method, it uses much time and resources on Google. So I thought of retrieving the information of image at the binary level, and created this. By this, the low process cost could be achieved.
This is a plugin of Sublime Text 3 for submitting files to both Gist and Slack.
I like to use Sublime Text for developing scripts. And when I discuss about developing scripts, I often use Slack. When I submitted a script to Slack, I had saved the script to Gist as a backup. I had done manually this on my browser. Namely, I wanted to be saving the revision of script while I’m discussing about the script at Slack. One day, I wished this process had been able to be automatically run. So I created this plugin and gislack of a CLI tool.
This is a CLI tool to submit files to both Gist and Slack.
When I discuss about developing scripts, I often use Slack. When I submitted a script to Slack, I had saved the script to Gist as a backup. I had done manually this on my browser. Namely, I wanted to be saving the revision of script while I’m discussing about the script at Slack. Recently, I wished this process had been able to be automatically run. So I created this tool.
This is a Golang library to automatically get an authorization code for retrieving access token using OAuth2.
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. At first, I have used this for retrieving the code from Google. But recently I noticed that this can be used for other sites. They are Google, GitHub, Slack and so on. This library can be used for creating such applications.
This sample is for retrieving access token for Google APIs. I created this for studying newStateToken().
In order to use this sample, please do as follows.
https://script.google.com/macros/s/#####/usercallback.Here, you have client ID, client Secret and redirect URI to retrieving refresh token and access token. These can be used for following sample script.
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. https://github.com/tanaikech/SOUWA_GAS
This sample script is for retrieving values from a deep nested JSON. There are 2 patterns. So for these, the benchmark were measured.
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"].(map[string]interface{})["B_key1"]
a3 := p["A_key1"].(map[string]interface{})["B_key1"].(map[string]interface{})["C_key"]
_ = a1 // --> map[B_key1:map[C_key:value]]
_ = a2 // --> map[C_key:value]
_ = a3 // --> value
}
}
func BenchmarkB2(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
var p map[string]interface{}
json.Unmarshal([]byte(data), &p)
b1 := p["A_key1"]
temp, _ := json.Marshal(b1)
json.Unmarshal(temp, &p)
b2 := p["B_key1"]
temp, _ = json.Marshal(b2)
json.Unmarshal(temp, &p)
b3 := p["C_key"]
_ = b1 // --> map[B_key1:map[C_key:value]]
_ = b2 // --> map[C_key:value]
_ = b3 // --> value
}
}
$ go test -bench .
BenchmarkB1-4 300000 4177 ns/op
BenchmarkB2-4 100000 13619 ns/op
PASS
It was found that the process cost of json.Unmarshal() was high. json.Unmarshal() for test 2 is 3 times larger than that for test 1.
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