π΅βπ«
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 { Button } from '@/components/ui/button'; | |
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
/// <reference lib="dom" /> | |
import React from 'react'; | |
import { FaMicrophone } from 'react-icons/fa'; | |
import { useIsomorphicLayoutEffect } from 'usehooks-ts'; | |
/* | |
* Intakes a state setter where the component | |
* will store the result of speech to text into |
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 { readFileSync, writeFileSync, readdirSync } from "node:fs"; | |
import { join } from "path"; | |
const paste: string = ` | |
<key>=<value> | |
... | |
` | |
const envFiles: string[] = readdirSync(process.cwd()).filter((file) => file.startsWith(".env")); |
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 { readFileSync } from 'fs'; | |
import { join } from 'path'; | |
import { z } from 'zod'; | |
const packages = readFileSync(join(__dirname, 'package.json'), 'utf8'); | |
const schema = z.object({ | |
devDependencies: z.record(z.string()), | |
dependencies: z.record(z.string()), | |
}); |
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 os | |
import re | |
import sys | |
from typing import List | |
class FileSystem: | |
def __init__(self, path='.') -> None: | |
self.path = path | |
def filter_files(self, files, pattern) -> List[str]: |
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 { fileURLToPath } from "node:url" | |
import { readFileSync, writeFileSync } from "node:fs" | |
import { dirname } from "node:path" | |
(() => { | |
const __dirname = dirname(fileURLToPath(import.meta.url)) | |
console.log(`${__dirname}<path><file_name>.<extension>`) | |
const robots = readFileSync(`${__dirname}<path><file_name>.<extension>`, "utf-8") | |
const kv: Map<string, string> = new Map<string, string>() |
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 fs from 'fs'; | |
import { fileURLToPath } from 'url'; | |
import path from 'path'; | |
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads'; | |
const __filename: string = fileURLToPath(import.meta.url); | |
const __dirname: string = path.dirname(__filename); | |
const filePath = path.join(__dirname, 'server', 'data', 'nsfw-names.txt'); | |
const fileContent = fs.readFileSync(filePath, 'utf8'); |
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 puppeteer from 'puppeteer-extra'; | |
import { LaunchOptions } from 'puppeteer'; | |
import fs from 'fs/promises'; | |
import path from 'path'; | |
import { fileURLToPath } from 'url'; | |
import StealthPlugin from 'puppeteer-extra-plugin-stealth'; | |
import AdblockerPlugin from 'puppeteer-extra-plugin-adblocker'; | |
interface Row { | |
text: string; |
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 binarySearch = (source_text: string, target: string): [number, string] | null => { | |
const source_text_segments: string[] = (source_text.match(/[^.!?]+[.!?]+/g) || [source_text]).map(s => s.trim()); | |
const target_segment = target.trim(); | |
let result: [number, string] | null = null; | |
let left: number = 0; | |
let right: number = source_text_segments.length - 1; | |
while (left <= right) { | |
const mid = left + Math.floor((right - left) / 2); | |
const segment = source_text_segments[mid]; |
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 puppeteer from "puppeteer"; | |
import axios from "axios"; | |
export const scraper = async (url: Readonly<string>): Promise<string[]> => { | |
const browser = await puppeteer.launch({ headless: true }); | |
const page = await browser.newPage(); | |
await page.goto(url, { | |
timeout: 0, | |
waitUntil: "domcontentloaded" |
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
class Memoize: | |
def __init__(self, func: Callable) -> None: | |
self.func = func | |
self.cache = {} | |
def __call__(self, *args, **kwargs) -> Any: | |
if args not in self.cache: | |
self.cache[args] = self.func(*args, **kwargs) | |
return self.cache[args] |