This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function retryFetch(url) { | |
var lastError = null; | |
for(var i = 0; i < 3; i++) { | |
try { | |
var res = UrlFetchApp.fetch(url) | |
if(res.getResponseCode() == 200) { | |
return res.getContentText("UTF-8") | |
} else { | |
lastError = 'HTTPステータスコードが200以外: ' + res.getResponseCode() + ', ' + url; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 複数メソッドをロードする | |
* 依存: | |
* - retryFetch https://gist.github.com/naosim/8fc6033b6f92e426eddc0424e7f7aa71 | |
*/ | |
function loadLibForMethods(methodNames, url) { | |
eval(retryFetch(url)) | |
var result = {}; | |
methodNames.forEach(function(name) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GithubApi( | |
accessToken, | |
owner, | |
repo | |
) { | |
var requestOptions = { | |
headers: { Authorization: 'token ' + accessToken } | |
} | |
function exec(url) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SheetDb(spreadSheet) { | |
/** | |
* レコードの全取得 | |
*/ | |
function findAll(name /* シート名 */) { | |
var sheet = spreadSheet.getSheetByName(name); | |
var table = sheet.getDataRange().getValues() | |
return JSON.parse(JSON.stringify(table)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* メールを検索する | |
* 注意: 内部でGmailApp.searchを利用しているため、検索結果は多めに取れる。厳密にするには戻り値に対してもう一度フィルターをかける必要がある。 | |
* | |
* @param {string} searchText | |
* @param {object} option 省略可 | |
* @return {GmailMessage[]} 日付の昇順でソート済み | |
*/ | |
function searchMail(searchText, option) { | |
// optionの初期値セットアップ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function comDate(dates, typesCsv) { | |
var convert = function(d, type) { | |
if(type == '年月') { | |
return d.getYear() + ('0' + (d.getMonth() + 1)).slice(-2); | |
} | |
var nendo = 'FY' + (d.getMonth() + 1 < 4 ? d.getYear() - 1: d.getYear()); | |
if(type == '年度') { | |
return nendo; | |
} | |
if(type == '半期') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* スプレッドシートの2次元配列をエンティティの配列に変換する | |
* - 2次元配列は0番目はヘッダー(カラム名の配列)行、1番目以降にデータが並んでいること | |
* - ヘッダー行のカラム名は空でないこと | |
* - カラム名は値の最初の行だけ採用される 例: "身長\n[cm]" → カラム名は"身長"になる | |
* @param {[['name', 'age'], ['mike', 30]]} ary2d - スプレッドシートのような2次元配列 | |
* @return 例: [{name:"mike", age:30}, {name:"jiro", age:40}] | |
*/ | |
function toEntities(ary2d) { | |
var headers = ary2d[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/frappe-gantt/0.3.0/frappe-gantt.min.css"></link> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/frappe-gantt/0.3.0/frappe-gantt.min.js"></script> | |
<svg id="gantt"></svg> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8" /> | |
<script> | |
/** | |
* 1次元オセロの盤面に白の石を置く | |
* | |
* - 盤は配列で表現する | |
* - 白の石は'白' | |
* - 黒の石は'黒' | |
* - 空の場所はnull |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as board2d from 'https://raw.githubusercontent.com/naosim/deno-board2d/v1.2.0/src/mod.ts'; | |
export { | |
Board, | |
BoardMutable, | |
Pos, | |
Direction, | |
X, | |
Y | |
} from 'https://raw.githubusercontent.com/naosim/deno-board2d/v1.2.0/src/mod.ts'; |