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
/** | |
* @return {Boolean} 祝日かどうか | |
*/ | |
function isJapaneseHoliday() { | |
var startDate = new Date(); | |
startDate.setHours(0, 0, 0, 0); | |
var endDate = new Date(); | |
endDate.setHours(23, 59, 59, 999); | |
// google calenderの提供している祝日カレンダーを取得する | |
var cal = CalendarApp.getCalendarById("ja.japanese#[email protected]"); |
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
def uniq(items: list): | |
''' | |
元の順序を保持したままuniqにする | |
''' | |
return sorted(set(items), key=items.index) | |
def not_none_items(items: list): | |
''' | |
Noneなアイテムを除外する | |
''' |
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 SeededRandom from "../SeededRandom" | |
describe("SeededRandom.ts", () => { | |
it("インスタンスが違っていても、シード値が同じなら同じ値が返ってくる", () => { | |
const seed = 100 | |
const r1 = new SeededRandom(seed) | |
const r2 = new SeededRandom(seed) | |
expect(r1.next()).toBe(r2.next()) | |
expect(r1.next()).toBe(r2.next()) | |
expect(r1.next()).toBe(r2.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
const {PI} = Math | |
const rad1 = PI / 180 | |
export const deg2rad = (deg: number) => deg * rad1 | |
export const rad2deg = (rad: number) => rad / rad1 |
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 { APIGatewayProxyHandler } from "aws-lambda" | |
export const handler: APIGatewayProxyHandler = async event => { | |
const filename = "data.json" | |
return { | |
statusCode: 200, | |
headers: { | |
"Content-Type": "application/force-download", | |
"Content-disposition": `attachment; filename=${filename}`, | |
}, |
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
/** | |
* References: | |
* - https://qiita.com/Ishidall/items/bb0e0db86a2f56fb1022 | |
*/ | |
import * as crypto from "crypto" | |
const ENCRYPT_METHOD = "aes-256-cbc" // 暗号化方式 | |
const ENCRYPTION_KEY = "" // 32byte | |
const IV = Buffer.from("") // 16byte | |
const ENCODING = "hex" // 最終的な文字列のエンコード方式 |
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
/** | |
* 文字列を逆にする | |
* | |
* ex: 'string' → gnirts | |
*/ | |
export const reverse = (target: string) => | |
target | |
.split("") | |
.reverse() | |
.join("") |
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 PyPDF2 | |
from pathlib import Path | |
def merge_pdf(sources: list, filename: str): | |
"""PDFを結合する | |
- sources: もととなるソースファイル。配列の順番通りに結合する。 | |
- filename: 出力するファイル名。 | |
""" | |
merger = PyPDF2.PdfFileMerger() | |
for source in sources: |
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 loadImage = (src) => new Promise((resolve, reject) => { | |
const img = new Image() | |
img.onload = () => resolve(img) | |
img.onerror = reject | |
img.src = src | |
}) |
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
// https://sbfl.net/blog/2017/06/01/javascript-reproducible-random/ | |
class Random { | |
constructor(seed = 88675123) { | |
this.x = 123456789; | |
this.y = 362436069; | |
this.z = 521288629; | |
this.w = seed; | |
} | |
// XorShift | |
next() { |
NewerOlder