Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / GASでGASのコードをダウンロード
Created June 21, 2013 03:33
Google Apps Scriptのプロジェクトのコードを外部からダウンロード/アップロード(ダウンロード編) ref: http://qiita.com/soundTricker@github/items/8873f29781d1e123cfa8
function downloadGASFiles(downloadUrl) {
//Google OAuth用の設定
var oauthConfig = UrlFetchApp.addOAuthService('drive');
var scope = 'https://www.googleapis.com/auth/drive+https://www.googleapis.com/auth/drive.file+https://www.googleapis.com/auth/drive.scripts';
oauthConfig.setConsumerKey('anonymous');
oauthConfig.setConsumerSecret('anonymous');
oauthConfig.setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken?scope='+scope);
@soundTricker
soundTricker / GASProject.js
Last active September 26, 2016 15:00
A project of GooGoogle Apps Script import / export by Google Apps Script. If u need more detail, please see below. (sorry Japanese) http://qiita.com/soundTricker@github/items/e75ee1f2a7d89fa60a60
//This is a google apps script project json.
//The Import/Export API, that is on the Google Drive API, use this.
//If u have existing project, u can do update, delete, add and rename project's code and file by changing this json structure.
{
//files property is Google Apps Script Project Files.
//It has some hash objects.
"files": [
//Hash object is Google Apps Script File.
//It contain id, name, type, source.
@soundTricker
soundTricker / sample.js
Created October 24, 2013 02:53
Google+ Domain API with Apps Script
var SCOPE_PLUS_ME = "https://www.googleapis.com/auth/plus.me";
var SCOPE_PLUS_PROFILES_READ = "https://www.googleapis.com/auth/plus.profiles.read";
var SCOPE_PLUS_CIRCLES_READ = "https://www.googleapis.com/auth/plus.circles.read";
var SCOPE_PLUS_CIRCLES_WRITE = "https://www.googleapis.com/auth/plus.circles.write";
var SCOPE_PLUS_STREAM_READ = "https://www.googleapis.com/auth/plus.stream.read";
var SCOPE_PLUS_STREAM_WRITE = "https://www.googleapis.com/auth/plus.stream.write";
var SCOPE_PLUS_MEDIA_UPLOAD = "https://www.googleapis.com/auth/plus.media.upload";
var SCOPES = [SCOPE_PLUS_ME,SCOPE_PLUS_STREAM_WRITE].join("+");
var USER_ID = "me";
@soundTricker
soundTricker / AwsCredentials.properties
Created January 7, 2014 08:28
AWS SDK for JavaでEC2のインスタンスを上げたり落としたり取得したり ref: http://qiita.com/soundTricker/items/b5a9045d251d47744107
# Fill in your AWS Access Key ID and Secret Access Key
# http://aws.amazon.com/security-credentials
accessKey= Your AWS Access Key ID
secretKey= Your Secret Access Key
package stk;
import java.util.List;
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.AllocateAddressRequest;
@soundTricker
soundTricker / enum.go
Created June 13, 2014 00:36
[覚書]Goでenumっぽいので表示名を作る ref: http://qiita.com/soundTricker/items/f9d2c3e3902e8ddd4a98
type EnumType int
const (
One EnumType = iota //初期値を0以外にする場合は iota+1とかで調整
Tow
Three
)
//EnumType の文字列表現
@soundTricker
soundTricker / file directory tree
Created August 25, 2014 02:50
GCE with Ansible
```
.
├── credentials/
│   ├── cacert.pem
│   ├── pkey.pem
│   ├── secrets.py*
│   └── secrets.pyc
├── inventory/
│   ├── gce.ini
│   ├── gce.py*
@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パラメータを作成