Skip to content

Instantly share code, notes, and snippets.

View tanaikech's full-sized avatar

Kanshi TANAIKE tanaikech

View GitHub Profile
@tanaikech
tanaikech / file0.txt
Created January 2, 2017 02:26
Python, Selenium, PhantomJSを使ってルータを再起動する ref: http://qiita.com/tanaike/items/8e8dbf8f04abe62ca7b7
http://ユーザ名:パスワード@ルータのIPアドレス
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:54
Changing Line to Bars for Combo Chart using GAS

Changing Line to Bars for Combo Chart using GAS

Sample data

This is a sample data for this sample script. The column B was created by the normal distribution formula, and the column C was created by multiplying random number for column B.

A, B, C
1.0, 0.0001, 0.0000
1.5, 0.0009, 0.0006
2.0, 0.0044, 0.0037
@tanaikech
tanaikech / submit.md
Created June 15, 2017 04:55
Embedding a Map to a Cell using Custom Function on Spreadsheet

Embedding a Map to a Cell using Custom Function on Spreadsheet

This sample script embeds a map to a cell using custom function on Spreadsheet.

I think that this method is one of various ideas.

Problem

When the map is embeded to a cell on spreadsheet as an image, the function =IMAGE() is suitable for this situation. However, setFormula() for importing =IMAGE() and DriveApp.createFile() for creating images from maps also cannot be used for custom functions.

Solution

@tanaikech
tanaikech / submit.md
Created June 15, 2017 05:12
Send E-mail with Excel file converted from Spreadsheet

Send E-mail with Excel file converted from Spreadsheet

This sample script sends an e-mail with an Excel file exported from Spreadsheet as an attachment file.

function excelSender() {
  var sheetID = [Sheet ID];
  var xlsxName = [Excel file name];
  var params = {
 "headers" : {Authorization: "Bearer [Retrieved AccessToken]"},
@tanaikech
tanaikech / submit.md
Last active July 12, 2017 07:26
(NEW) Retrieve old revision file from Google Drive

(NEW) Retrieve old revision file from Google Drive

This method was updated at July 12, 2017. But I think that this is a temporal workaround. When the official update is done for retrieving revision files, this will be updated.

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.

@tanaikech
tanaikech / submit.md
Created September 6, 2017 07:49
Removing Duplicated Values in Array using CoffeeScript

Removing Duplicated Values in Array using CoffeeScript

This sample script is for removing duplicated values in array using CoffeeScript.

ar = ["a", "b", "c", "a", "c"]
res = ar.filter (e, i, s) -> s.indexOf(e) is i
console.log res

>>> [ 'a', 'b', 'c' ]
@tanaikech
tanaikech / submit.md
Created December 1, 2017 03:18
Adding Object to Object by Javascript

Adding Object to Object by Javascript

This sample script is for adding object to object by javascript.

Script :

var obj = {
  key1: "value1",
  key2: "value2",
  key3: "value3"
};
@tanaikech
tanaikech / submit.md
Created December 17, 2017 23:25
Decoding Gmail Body with Japanese Language using Python

This is a sample script for decoding Gmail body with Japanese language using Python.

msg = service.users().messages().get(userId='me', id=id).execute()
parts = msg['payload']['parts']
for e in parts:
    msg = base64.urlsafe_b64decode(e['body']['data']).decode('utf-8').encode('cp932', "ignore").decode('cp932')
    print(msg)
@tanaikech
tanaikech / submit.md
Created January 15, 2018 00:54
Zaif API for Google Apps Script

Zaif API for Google Apps Script

This sample script is for using Zaif API by Google Apps Script.

The following go script is a sample at Zaif API.

package main

import (
 "fmt"
@tanaikech
tanaikech / submit.md
Last active January 28, 2018 09:32
Which of Drive API v2 or v3 is used for DriveApp.searchFiles()?

Which of Drive API v2 or v3 is used for DriveApp.searchFiles()?

Experiment

It has investigated the differences between the documents of "Search for Files" for v2 and v3. The following table shows the comparison of v2 and v3 for "Valid fields for files.list". The column of DriveApp.searchFiles() means whether the query can be used for DriveApp.searchFiles().

v2 v3 Difference DriveApp.searchFiles()
title name different v2: succeed, v3: fail
fullText fullText same
mimeType mimeType same