π΅βπ«
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 subprocess | |
from pathlib import Path | |
from concurrent.futures import Future, ThreadPoolExecutor, as_completed | |
from time import perf_counter | |
import logging | |
from typing import List, Set | |
# Constants | |
EXTENSIONS: tuple[str, ...] = (".png", ".jpg", ".jpeg") |
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 strict"; | |
const sharp = require("sharp"); | |
const fs = require("fs"); | |
const path = require("path"); | |
sharp.cache(false); | |
async function generateLazyImage(src) { | |
const { default: got } = await import("got"); |
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 React, { | |
type PropsWithChildren, | |
cloneElement, | |
isValidElement, | |
type DetailedReactHTMLElement, | |
type ImgHTMLAttributes, | |
type FC, | |
Children, | |
} from "react"; |
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
// Prettify - Prettifies a type by removing readonly and optional modifiers | |
type Prettify<T> = { | |
[K in keyof T]: T[K]; | |
} & {}; | |
// Head - Gets the first element of an array | |
type Head<T extends Array<any>> = T extends [infer U, ...infer _Rest] ? U : never | |
// Tail - Gets the tail of an array | |
type Tail<T extends any[]> = T extends [infer _U, ...infer Rest] ? Rest : never |
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
/** | |
* Extends global interfaces to add Python-like functionality | |
*/ | |
declare global { | |
interface Number { | |
/** | |
* Returns true if the number is within the given range [start, end). | |
* Similar to Python's `in range()`. | |
*/ | |
inRange(start: number, end?: number, step?: number): boolean; |
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
// types.ts | |
export interface WorkerMessage<T = any> { | |
id: string; | |
type: 'TASK' | 'RESULT' | 'ERROR' | 'STATUS'; | |
payload: T; | |
timestamp: number; | |
} | |
export interface WorkerTask { | |
id: 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 threading | |
import queue | |
import concurrent.futures | |
import logging | |
from typing import List, Callable, Any | |
from dataclasses import dataclass | |
from datetime import datetime | |
import time | |
# Configure logging |
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
package concurrency | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"sync" | |
"time" | |
"errors" | |
) |
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 std::{ | |
collections::HashMap, | |
sync::{ | |
atomic::{AtomicBool, AtomicUsize, Ordering}, | |
Arc, Mutex, RwLock, | |
}, | |
thread, | |
time::{Duration, Instant}, | |
}; | |
use tokio::{ |
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
interface Node<T = unknown, Nodes extends Node<any, any>[] = Node<any, any>[]> { | |
value: T; | |
neighbors: Nodes; | |
} | |
type A = Node<1, [B, C]> | |
type B = Node<2, [A, D]> | |
type C = Node<3, [A, B]> | |
type D = Node<4, [B, C]> |