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>repro</title> | |
<style> | |
#popover1 { | |
top: 100px; | |
left: 100px; | |
width: 100px; |
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
// 試合を繰り返して昇格する確率を求める | |
// ・5勝の貯金を積み上げると昇格 | |
// ・3敗の借金を積み上げると降格 | |
// ・借金中に勝利すると今までの借金がチャラになり+1勝になる | |
generateCSV(); | |
function generateCSV() { | |
const header='1試合の勝率,昇格確率,降格確率,合計'; | |
let csv = header + '\n'; | |
for (let p = 0; p <= 100; p ++) { |
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 effects: Map<number, () => void> = new Map(); | |
let nextEffectId = 1; | |
/** | |
* Similar to useEffect, but an effect from another randomly chosen instance of useButterflyEffect is called | |
* when given deps change. | |
*/ | |
function useButterflyEffect(effect: () => void, deps: readonly unknown[]) { | |
useEffect(() => { | |
const effectId = nextEffectId++; |
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 svg = document.querySelector('svg.vlmbi.H21Mnd'); | |
const svg2 = cl(svg); | |
const paths = svg2.querySelectorAll('path.xH0v4d'); | |
const cs = [ | |
'rgb(218, 220, 224)', | |
'rgb(0, 155, 216)', | |
'rgb(166, 220, 241)', | |
'rgb(241, 176, 180)', | |
'rgb(219, 29, 40)', |
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 offsetRange(arr) { | |
return ( | |
arr.map(v => [v, v+1]) | |
.join(",") | |
.replace(/(,\d+)\1/g, "-") | |
.replace(/(-+,)\d+/g, (_, s) => "-" + (s.length)) | |
.replace(/(,\d+),\d+/g, (_, s) => `${s}-1`) | |
.split(",") | |
.map((v) => { | |
const [offset, range] = v.split("-"); |
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
Promise.prototype.then = (()=> { | |
const _then = Promise.prototype.then; | |
return function(...args) { | |
_then.call(this, (res) => { | |
promiseResultMap.set(this, res); | |
}) | |
this.then = _then; | |
return _then.apply(this, args); | |
} | |
})(); |
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 use\uffa0std = { | |
collections: { | |
get HashMap() { | |
globalThis.HashMap = class HashMap {}; | |
return undefined; | |
} | |
} | |
} |
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
let fizzbuzz = false; | |
function* range() { | |
for (let i=1; i<=100; i++) yield i; | |
} | |
async function fizz() { | |
for (const i of range()) { | |
if (i % 3 === 0) { | |
fizzbuzz=true; | |
process.stdout.write("Fizz"); | |
} |
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 numBegArr = ["-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; | |
const numBegSet = new Set(numBegArr); | |
const isNumericBeginning = char => numBegSet.has(char); | |
const isNumericBeginning2 = char => numBegArr.includes(char); | |
const isNumericBeginning3 = char => | |
char === "-" || | |
char === "0" || | |
char === "1" || | |
char === "2" || |
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
type AtLeast<N extends number, T> = AtLeastRec<N, T, T[], []>; | |
type AtLeastRec<Num, Elm, T extends unknown[], C extends unknown[]> = { | |
0: T; | |
1: ((arg: Elm, ...rest: T) => void) extends ((...args: infer T2) => void) | |
? ((arg: unknown, ...rest: C) => void) extends ((...args: infer T3) => void) | |
? AtLeastRec<Num, Elm, T2, T3> | |
: never | |
: never; | |
}[C extends { length: Num } ? 0 : 1]; |
NewerOlder