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
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
/** | |
* 複数メソッドをロードする | |
* 依存: | |
* - 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 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
/** | |
* 外部ファイルからjsを読み込む | |
* githubやgists上にあるコードを使いたい時用 | |
*/ | |
function loadLibForOneMethod(mainMethodName, url) { | |
// リトライありのfetch | |
function retryFetch(url) { | |
var lastError = null; | |
for(var i = 0; i < 3; i++) { | |
try { |
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 findAll(name /* シート名 */) { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().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
// 最後に更新されたファイルを取得する | |
// 利用例 | |
// ls -l | node lastupdate.js | |
// => 2018-12-18 10:50 ./worklog/index.js | |
// | |
// サブディレクトリも対象にするならこう | |
// find . -type f | xargs ls -l | node worklog index.js | |
// | |
// 事前準備 | |
// npmで'textpipe'を入れておくこと |
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
// node . inputfile outRootDir | |
if(process.argv.length == 2) { | |
const msg = 'USAGE\nnode . inputMarkdownFile outRootDir' | |
console.log(msg) | |
throw msg | |
} | |
const inputMarkdownFile = process.argv[2] | |
const outRootDir = process.argv[3] |
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> | |
<div id="div20180606"> | |
<table border="1"> | |
<tr><th>名前</th><th>備考</th> | |
<tr><td>ほげ</td><td>改行<br>テスト</td></tr> | |
<tr><td>ふー</td><td>改行<br>テスト</td></tr> | |
</table> | |
</div> | |
<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
const template = ` | |
package __PACKAGE__; | |
import lombok.AllArgsConstructor; | |
import lombok.EqualsAndHashCode; | |
@AllArgsConstructor | |
@EqualsAndHashCode | |
public class __CLASS__ { | |
private final String value; |