Skip to content

Instantly share code, notes, and snippets.

@soundTricker
soundTricker / sample.js
Created June 18, 2013 04:14
gas-github library sample code. Please see https://github.com/soundTricker/gas-github
/**
* gas-github library sample codes.
* see https://github.com/soundTricker/gas-github
*/
//Create new gist
function createOrUpdateGist(){
//Create Gist API
var gistApi = Github.create(UserProperties.getProperty("githubApiKey")).gists();
@soundTricker
soundTricker / convertDocs2Html.js
Created February 1, 2013 00:28
Convert Google Docs 2 Html on Google Apps Script GASでGoogle DocumentのファイルをHTMLに変換します。
var KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; //developer key , get from https://code.google.com/apis/console/b/1/
var FILE_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // drive file id
function convertDocuments2() {
var oauthConfig = UrlFetchApp.addOAuthService('drive');
//Create oauth config for drive api
var scope = 'https://www.googleapis.com/auth/drive';
oauthConfig.setConsumerKey('anonymous');
oauthConfig.setConsumerSecret('anonymous');
@soundTricker
soundTricker / bigquery.js
Created June 12, 2012 12:20
BiqQuery API with Google Apps Script CheatSheet
var projectId = ScriptProperties.getProperty("projectId");
function プロジェクトの取得() {
var list = BigQuery.Projects.list();
Logger.log(list);
}
@soundTricker
soundTricker / datastore.js
Created May 17, 2013 11:02
Google Apps ScriptからCloud Datastore APIへのクエリ
function myFunction() {
var option = googleOAuth_();
option.method = "post";
option.contentType = 'application/json';
option.payload = JSON.stringify({
"query":
{
"kinds":
[
@soundTricker
soundTricker / bigquery.py
Created September 12, 2018 05:10
apache beam python dynamic query source
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@soundTricker
soundTricker / convert2Spreadsheet.js
Last active July 28, 2019 08:29
Convert from excel file to Sheets on Google Apps Script. GASでExcelファイルをSpreadsheet形式に変換します。
var KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; //developer key , get on https://code.google.com/apis/console/ and set enable the Drive API.
/**
* Convert from Excel data to Spreadsheet
* @param {Blob} excelFile the excel blob data.
* @param {String} filename file name on uploading drive
* @return {Spreadsheet} spreadsheet instance.
**/
function convert2Spreadsheet(excelFile, filename) {
var oauthConfig = UrlFetchApp.addOAuthService('drive');
@soundTricker
soundTricker / appsscript.json
Last active April 25, 2018 09:24
Gmail Add-ons ハンズオン
{
"timeZone": "Asia/Tokyo",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute"
],
"gmail": {
"version": "TRUSTED_TESTER_V2",
@soundTricker
soundTricker / custom_function_translate.gs
Last active April 25, 2018 05:01
2018/04/25 gtug girls gas
function translate(val) {
if (val.map) {
return val.map(translate);
}
return LanguageApp.translate(val, "en", "ja");
}
@soundTricker
soundTricker / getSpreadsheetComments.js
Last active October 15, 2017 07:42
Get Spreadsheet Comments
var apiKey = "Your API KEY";
function myFunction() {
var option = googleOAuth_();
option.method = "get";
//Spreadsheet.getActive().getId()をそのまま使うと、エラーになるので一回DriveのFileにかえてからIDを取得
var res = UrlFetchApp.fetch("https://www.googleapis.com/drive/v2/files/"+ DriveApp.getFileById(SpreadsheetApp.getActive().getId()).getId() +"/comments?key=" + apiKey , option);
var json = JSON.parse(res.getContentText());
Logger.log(json)
@soundTricker
soundTricker / bigquery.gs
Created August 17, 2017 08:05
Google Apps Script ハンズオン 2017/08/17
function myFunction() {
// シートを取得
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("シート1");
// プロジェクトID、Queryを取得
var projectId = sheet.getRange("B1").getValue();
var query = sheet.getRange("B2").getValue();
// Queryパラメータを作成