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
/* | |
Javaのファイルを漁ってクラス構成を分析する | |
--- | |
# 実行環境 node.js | |
古いバージョンでも動くようにする。モダンな書き方はアロー式を使う程度にする | |
# 出力形式 | |
[ | |
{ | |
filePath: string, |
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 getFilePathListById(fileId) { | |
var file = DriveApp.getFileById(fileId); | |
return getParentPathList(file).map(v => 'G:\\' + v + '\\' + file.getName()); | |
} | |
function iteratorToArray(iterator) { | |
var result = []; | |
while (iterator.hasNext()) { | |
result.push(iterator.next()); | |
} |
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 addBusinessDays(date, daysToAdd, holidays) { | |
// weekends: 0 = Sunday, 6 = Saturday | |
const weekendDays = [0, 6]; | |
// create a set of holidays for O(1) lookup time | |
const holidaySet = new Set(holidays.map((holiday) => holiday.getTime())); | |
let businessDaysAdded = 0; | |
let currentDate = new Date(date.getTime()); | |
while (businessDaysAdded < daysToAdd) { | |
// add one day to the current date |
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 parseDateString(dateStr, holidays) { | |
let date; | |
if (/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(dateStr)) { | |
// 日付指定の場合 | |
date = new Date(dateStr); | |
} else if (/^FY\d{2}\/\dQ$/.test(dateStr)) { | |
// 年度・四半期指定の場合 | |
const fy = parseInt(dateStr.slice(2, 4), 10); | |
const q = parseInt(dateStr.slice(-2, -1), 10); |
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 headers = ["ID", "タスク名", "開始日", "終了日", "日数", "依存タスク"]; | |
function setup() { | |
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("シート1"); | |
if(sheet.getRange(1, 1).getValue() == "入力用") { | |
throw new Error("すでに実行済みです"); | |
} | |
sheet.appendRow(["入力用"]) | |
sheet.appendRow(headers) | |
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 exportCalendarEvents() { | |
// カレンダーIDを入力してください | |
var calendarId = "primary"; | |
// フォーマット | |
var format = "yyyy/MM/dd HH:mm:ss"; | |
// 今日の日付を取得 | |
var today = new Date(); | |
// 今日の0時0分0秒を計算 | |
var startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate()); |
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
// いい感じに同期します | |
// 新規タスクの追加 | |
// 変更点の更新 | |
// GoogleTasksの読み込み | |
function update() { | |
new MainService().update(); | |
} | |
function onOpen() { | |
const customMenu = SpreadsheetApp.getUi() |
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 getBitsAfter33(ipv6) { | |
function hexTo2Bits(v, bitLength = 4) { | |
if(v >= 10) { | |
v = "ABCDEF"[v - 10] | |
} | |
return (new Array(bitLength).fill("0").join("") + parseInt(v, 16).toString(2)).slice(-bitLength); | |
} | |
function bit2toHex(num) { | |
var p = num.split("").reverse().map((v, i) => Math.pow(2, i) * parseInt(v)).reduce((memo, v) => memo + v, 0); | |
if(p < 10) { |
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 http from "http"; | |
import fs from "fs"; | |
import path from "path"; | |
import { fileURLToPath } from 'url'; | |
const __filename = fileURLToPath(import.meta.url); | |
const __dirname = path.dirname(__filename); | |
const server = http.createServer((req, res) => { | |
const reqPath = req.url; | |
const sanitizedPath = path.normalize(reqPath).replace(/^(\.\.[\/\\])+/, ''); |
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
{ | |
"type": "array", | |
"items": { | |
"$ref": "#/$defs/table" | |
}, | |
"$defs": { | |
"table": { | |
"name": "table", | |
"type": "object", | |
"properties": { |