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
import { EtchModel, Grain, Palette } from './utils'; | |
const Token = { | |
pixelDensity: 5, | |
strokeWeight: 5, | |
pointVariance: 0.05, | |
lineSegments: 20, | |
numberOfLines: 5, | |
shouldUseFuzzyGrain: false, | |
shouldUseScaledColors: false, |
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
'use client'; | |
import { create } from 'zustand'; | |
type RecordingStore = { | |
recorder?: MediaRecorder; | |
isRecording: boolean; | |
isDiscarding: boolean; | |
recordingTimeMs: number; | |
recordingProgressToMax: number; | |
recordingTimer?: NodeJS.Timeout; |
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
import type React from "react"; | |
import { useEffect, useState } from "react"; | |
export function useCurrentColorValue(ref?: React.RefObject<HTMLElement>) { | |
const [color, setColor] = useState<string | null>(null); | |
useEffect(() => { | |
const updateColor = () => { | |
if (ref?.current) { | |
setColor(getComputedStyle(ref.current).color); |
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
import { ExecSyncOptions, execSync } from 'child_process'; | |
export function sh(command: TemplateStringsArray, ...substitutions: any[]) { | |
const fullCommand = command.reduce((acc, part, i) => acc + part + (substitutions[i] || ''), ''); | |
return (options?: ExecSyncOptions) => execSync(fullCommand, { encoding: 'utf-8', ...(options || {}) }); | |
} |
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
import asyncio | |
import logging | |
from typing import Any, Callable, Coroutine, List, Optional | |
logger = logging.getLogger(__name__) | |
class Waitgroup: | |
def __init__(self, timeout: Optional[float] = None): | |
self.timeout = timeout |
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
import TTLCache, { Options } from '@isaacs/ttlcache'; | |
export type CacheOptions<K = string, V = unknown> = Options<K, V>; | |
export class Cacheable<K = string, V = unknown> { | |
protected cache: TTLCache<K, V>; | |
constructor(options: Options<K, V> = { ttl: 1000 * 60 * 10 }) { | |
this.cache = new TTLCache(options); | |
} |
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
import * as React from 'react'; | |
import { useMediaQuery } from '@/lib/hooks'; | |
import * as DialogParts from '@/ui/dialog'; | |
import * as DrawerParts from '@/ui/drawer'; | |
type ResponsiveDialogPartsKey = | |
| '' | |
| 'Portal' | |
| 'Overlay' |
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 useRelativeTimestamp(ts: number) { | |
const now = Date.now(); | |
let displayTime = ""; | |
const diff = now - ts; | |
const timestamp = new Date(ts); | |
if (diff <= 1000 * 60 * 60) { | |
const formatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" }); |
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 debug = (...messages: unknown[]) => { | |
const { stack } = new Error(""); | |
const caller = stack?.split("\n")?.[2].trim().split(" ")[1]; | |
console.log(`[ededejr|${caller}]: `, ...messages); | |
}; |
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 onProcessExit(callback: () => void): void { | |
[ | |
"SIGINT", | |
"SIGTERM", | |
"SIGHUP", | |
"SIGBREAK", | |
"unhandledRejection", | |
"uncaughtException", | |
].forEach((signal: string) => { | |
process.on(signal, () => { |
NewerOlder