Skip to content

Instantly share code, notes, and snippets.

View learnuidev's full-sized avatar

Vishal Gautam learnuidev

View GitHub Profile
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(" ")
}
})
@learnuidev
learnuidev / phone_number_react
Last active May 5, 2025 20:17
phone number input
"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 =
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!");
const callStackLogger = (num) => {
if (num < 10000) {
console.dir(callStackLogger);
console.log(num);
return callStackLogger(num + 1);
}
return "done";
};
var f;
try {
throw 1;
} catch (a) {
with({b:2}) {
function closure() {
let f = 43
var c = 3;
function foo() {
var d = 4;
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,
// FIFO compose fn
const compose = (...funcs) => (x) => {
let res;
for (let func of funcs) {
if (res) {
res = func(res)
} else {
res = func(x)
}
}
[{"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
const empty = (val) => {
const isInstanceOfSet = val instanceof Set
if (isInstanceOfSet) {
return [...val]?.length === 0
}
if (val === null || val === undefined || isNaN(val)) {
return true
}
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({