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 genYoutubeTranscription = (res, lang) => res.events.map(event => { | |
return { | |
id: crypto.randomUUID(), | |
start: event.tStartMs / 1000, | |
lang, | |
end: (event.tStartMs + event.dDurationMs) / 1000, | |
input: event.segs[0].utf8?.split("\n").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
"use client"; | |
import { useMemo, useState } from "react"; | |
const DIGIT_STRINGS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; | |
const AREA_CODE_LENGTH = 3; | |
const PREFIX_LENGTH = 3; | |
const LINE_NUMBER_LENGTH = 4; | |
const PHONE_NUMBER_LENGTH = |
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 syncBlockingDelay(ms) { | |
const start = Date.now(); | |
while (Date.now() - start < ms) { | |
// Blocking the thread... | |
} | |
} | |
console.log("Start blocking..."); | |
syncBlockingDelay(2000); // Block for 2 seconds | |
console.log("Done blocking!"); |
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 callStackLogger = (num) => { | |
if (num < 10000) { | |
console.dir(callStackLogger); | |
console.log(num); | |
return callStackLogger(num + 1); | |
} | |
return "done"; | |
}; |
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
var f; | |
try { | |
throw 1; | |
} catch (a) { | |
with({b:2}) { | |
function closure() { | |
let f = 43 | |
var c = 3; | |
function foo() { | |
var d = 4; |
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 v3000Parser = (lang) => { | |
return [...document.querySelectorAll("tr")].slice(1)?.map((tr) => { | |
const [idx, en, type, level, input] = [...tr.children].map( | |
(val) => val.innerText | |
); | |
return { | |
id: idx, | |
en, | |
type, |
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
// FIFO compose fn | |
const compose = (...funcs) => (x) => { | |
let res; | |
for (let func of funcs) { | |
if (res) { | |
res = func(res) | |
} else { | |
res = func(x) | |
} | |
} |
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
[{"hanzi":"你好 ","pinyin":"níhǎo ","lit":"you - good ","en":"Hello","lang":"zh","start":0,"end":0},{"hanzi":"哈喽 ","pinyin":"hālóu ","lit":"hello ","en":"Hello","lang":"zh","start":0,"end":0},{"hanzi":"嗨 ","pinyin":"hāi ","lit":"hi ","en":"Hi","lang":"zh","start":0,"end":0},{"hanzi":"再见! ","pinyin":"zàijiàn ","lit":"again - see ","en":"Goodbye","lang":"zh","start":0,"end":0},{"hanzi":"拜拜 ","pinyin":"bāibāi ","lit":"bye-bye ","en":"Bye-Bye","lang":"zh","start":0,"end":0},{"hanzi":"谢谢 ","pinyin":"xièxie ","lit":"thank - thank ","en":"thank you","lang":"zh","start":0,"end":0},{"hanzi":"不用谢 ","pinyin":"búyòng xiè ","lit":"no need thank you ","en":"you're welcome","lang":"zh","start":0,"end":0},{"hanzi":"别客气 ","pinyin":"bié kèqi ","lit":"don’t polite ","en":"you're welcome","lang":"zh","start":0,"end":0},{"hanzi":"好 ","pinyin":"hǎo ","lit":"good ","en":"good","lang":"zh","start":0,"end":0},{"hanzi":"不好 ","pinyin":"bùhǎo ","lit":"not good ","en":"not good","lang":"zh","start":0,"end":0},{"hanzi":"不好意思 ","pinyin":"bùh |
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 empty = (val) => { | |
const isInstanceOfSet = val instanceof Set | |
if (isInstanceOfSet) { | |
return [...val]?.length === 0 | |
} | |
if (val === null || val === undefined || isNaN(val)) { | |
return true | |
} |
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
let res = []; | |
// 2. Function to Update the res | |
const updateRes = () => { | |
const item = document.querySelector(".ytp-caption-segment").innerText; | |
const item2 = document.querySelector( | |
".notranslate.text-selection" | |
)?.innerText; | |
res.push({ |
NewerOlder