tanaike

The Thinker

How to use "fields" of Drive APIs

There are a lot of APIs on Google. When we use Google Drive APIs, they usually have “fields” as a resource. The parameter “fields” gives various information which is selected to us. This is one of important parameters. And this can be used at Google Apps Script (GAS) although that version is v2. About how to use it, there are some documents. But it is difficult to find how to use it at GAS.

Retrieve old revision file from Google Drive

I introduce 2 kinds of methods. One is to use curl. Another is to use wget. At this time, I could know that wget can be also used as same as curl. In order to use this, at first, please retrieve your access token and enable Drive API. 1. File ID Retrieve file id from file name. curl -X GET -sSL \ -H 'Authorization: Bearer ### Access token ###' \ 'https://www.

Put a channel to a channel for golang

I have never heard this. I would like to use this from now. package main import "fmt" type st struct { data1 int data2 int } func main() { c1 := make(chan *st, 1) c2 := make(chan *st, 1) c1 <- &st{1, 2} c2 <- <-c1 close(c1) close(c2) res, _ := <-c2 fmt.Println(res.data2) } >>> 2

Retrieving File ID from File Name using GAS

This is a sample script of GAS for converting file name to file id on Google Drive. Drive API is used for this. So please enable Drive API at Advanced Drive Services and Google API Console. function nameToId(filename){ return [i.id for each (i in Drive.Files.list({q: "title='" + filename + "' and trashed=false"}).items)]; }

Transposing Array From (n x m) To (m x n) for javascript

This script transposes from an array with n rows x m columns to the array with m rows x n columns. In this script, you can use array of n != m . array = [ [a1, b1, c1, d1, e1], [a2, b2, c2, d2, e2], [a3, b3, c3, d3, e3], [a4, b4, c4, d4, e4], [a5, b5, c5, d5, e5], [a6, b6, c6, d6, e6], [a7, b7, c7, d7, e7], [a8, b8, c8, d8, e8], [a9, b9, c9, d9, e9], [a10, b10, c10, d10, e10] ] var result = []; for (i in array[0]){ result.