This file contains 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
#!/usr/bin/env bash | |
convert -background none image.svg -define icon:auto-resize=64,48,32,16 favicon.ico |
This file contains 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 -e 'require("fs").writeFileSync(process.argv[1], "\uFEFF" + require("iconv-cp932").decode(require("fs").readFileSync(process.argv[1])))' filename.csv |
This file contains 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 getTimezoneOffset = (timeZone, dt) => new Intl.DateTimeFormat("en-US", {timeZoneName: "longOffset", timeZone}).formatToParts(dt).find(v => v.type === "timeZoneName")?.value; | |
getTimezoneOffset("America/New_York", new Date()); // => "GMT-05:00" | |
getTimezoneOffset("America/New_York"); // => "GMT-05:00" | |
getTimezoneOffset("invalid"); // => Uncaught RangeError: Invalid time zone specified: |
This file contains 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
01 | 北海道 | / | / | |
---|---|---|---|---|
02 | 青森県 | /03/05/ | /岩手県/秋田県/ | |
03 | 岩手県 | /02/04/05/ | /青森県/宮城県/秋田県/ | |
04 | 宮城県 | /03/05/06/07/ | /岩手県/秋田県/山形県/福島県/ | |
05 | 秋田県 | /02/03/04/06/ | /青森県/岩手県/宮城県/山形県/ | |
06 | 山形県 | /04/05/07/15/ | /宮城県/秋田県/福島県/新潟県/ | |
07 | 福島県 | /04/06/08/09/10/15/ | /宮城県/山形県/茨城県/栃木県/群馬県/新潟県/ | |
08 | 茨城県 | /07/09/11/12/ | /福島県/栃木県/埼玉県/千葉県/ | |
09 | 栃木県 | /07/08/10/11/ | /福島県/茨城県/群馬県/埼玉県/ | |
10 | 群馬県 | /07/09/11/15/20/ | /福島県/栃木県/埼玉県/新潟県/長野県/ |
This file contains 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> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>benchmark</title> | |
</head> | |
<body> | |
Open DevTools | |
<script> | |
setTimeout(function() { |
This file contains 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
#!/usr/bin/env node | |
/** | |
* text-decoder-bench.js | |
* @copyright Kawanet | |
* @licence MIT | |
* @see https://gist.github.com/kawanet/a66a0e2657464c57bcff2249286d3a24 | |
*/ | |
const readString = (buffer, offset, length) => { |
This file contains 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
// オンデマンドに T や Promise<T> を返す関数実装を許容する | |
type OnDemandType<T> = (T | (() => T) | (() => Promise<T>)); | |
// すべてのプロパティがオンデマンド対応 | |
type LazyType<T> = { [K in keyof T]: OnDemandType<T[K]> }; | |
// T や Promise<T> を返す関数実装なら T を取り出す | |
type ResolvedType<T> = (T extends () => Promise<infer P> ? P : T extends () => infer P ? P : T); | |
// T のうち __typename プロパティを無視して、残りのプロパティは必須とする |
This file contains 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(url, cb) { | |
var req = new XMLHttpRequest(); | |
req.onreadystatechange = function() { | |
var err, res; | |
if (req.readyState === 4) { | |
if (req.status >= 200 && req.status < 300) { | |
try { | |
res = JSON.parse(req.responseText); | |
} catch (e) { |
This file contains 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 esc = str => str.replace(/(\\)|[\ud800-\udfff]/g, (m, c) => c ? ('\\' + c) : ("\\u" + m.charCodeAt(0).toString(16))); | |
esc('\\') === '\\\\'; | |
'🍺' === '\ud83c\udf7a'; | |
esc('🍺') === '\\ud83c\\udf7a'; | |
JSON.parse(esc('"\\"')) === '\\'; |
This file contains 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 -e '(e=require("express"))().use(e.static("htdocs")).listen(3000)' |
NewerOlder