Skip to content

Instantly share code, notes, and snippets.

@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 / calendar.js
Created April 26, 2012 02:10
google apps scriptで直接Google Calendar API(v2)を呼ぶ(Call Google Calendar API with Google Apps Script in direct)
function myFunction() {
//oauth の設定
var oauth = UrlFetchApp.addOAuthService(Session.getActiveUser().getEmail());
oauth.setConsumerKey("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ
oauth.setConsumerSecret("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ
oauth.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F");
oauth.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauth.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
@soundTricker
soundTricker / main.js
Created June 12, 2012 05:28
Google Apps 2 legged OAuth of Google Calendar API with Google Apps Script. Please import oauth.js and sha1.js from http://code.google.com/p/oauth/. if you happen any problem,Please modify oauth.js to below oauth.js code.
function twoleggedOAuth() {
var action = "https://www.google.com/calendar/feeds/default/private/full?xoauth_requestor_id={user mail address}";
var accessor = { consumerSecret: '{consumerSecret}' };
var message = { method: 'get', action: action, parameters: {}, };
OAuth.setParameter(message, 'oauth_version', '1.0');
OAuth.setParameter(message, 'oauth_nonce', OAuth.nonce(32));
OAuth.setParameter(message, 'oauth_timestamp', OAuth.timestamp());
OAuth.setParameter(message, 'oauth_consumer_key', '{your domain}');
OAuth.SignatureMethod.sign(message, accessor);
@soundTricker
soundTricker / gas.js
Created June 18, 2012 02:39
Google Apps Script GroupsManager and NicknameManager
function グループ() {
// {ユーザ名}@{ドメイン名}のユーザ名の部分を指定
var user = UserManager.getUser("k-ohashi");
//全グループの取得
var groups = GroupsManager.getAllGroups();
for(var i = 0; i < groups.length; i++) {
Logger.log(groups[i].getName());
}
@soundTricker
soundTricker / github_ranking.js
Created June 22, 2012 12:31
#ajn21のスクリプト
function BigQueryLiveDemo() {
//6219749
var list = BigQuery.Projects.list();
Logger.log(list);
//プロジェクトIDの取得
var projectId = list.getProjects()[0].getId();
@soundTricker
soundTricker / writeSpreadsheetDataAsCsv.js
Last active December 16, 2015 06:39
SpreadsheetからDriveへデータの書き込み(Date型データのフォーマット付き)
function writeSpreadsheetDataAsCsv() {
//Spreadsheetからデータ取得
var data = SpreadsheetApp.openById('id').getSheetByName('sheetName').getDataRange().getValues();
//二次配列→カンマ区切り文字列の一次配列
var writeDataArray = [];
for(var r = 0; r < data.length; r++) {
var row = data[r];
@soundTricker
soundTricker / formの作成
Created May 15, 2013 04:31
I/O 2013のGoogle Apps Script Update その1 Form上のGASとFormApp ref: http://qiita.com/items/42266e56c0212ce6b997
function createNewForm() {
var form = FormApp.create('フォームのタイトル');
}
@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);
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 / 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.