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 ResourceLoader { | |
| static jsZipLoaded = false; | |
| static async loadJSZip() { | |
| if (this.jsZipLoaded) return Promise.resolve(); | |
| return new Promise((resolve, reject) => { | |
| if (typeof JSZip !== 'undefined') { | |
| this.jsZipLoaded = true; | |
| resolve(); |
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
| #!/bin/sh | |
| print_usage() { | |
| echo "usage: compress_video <input_file>" | |
| echo "supported formats: mp4, webm, mkv, mov, avi, flv" | |
| } | |
| get_extension() { | |
| f="${1##*/}" | |
| case "$f" in |
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 { motion } from 'framer-motion' | |
| import React from 'react' | |
| const images = [ | |
| { | |
| src: 'https://a0.muscache.com/im/pictures/miso/Hosting-2810308/original/a653d85a-1a97-45d7-a213-78ef2286122a.jpeg?im_w=720', | |
| alt: 'Tree' | |
| }, | |
| { | |
| src: 'https://a0.muscache.com/im/pictures/2cc58022-2004-4034-a281-22fb622e7461.jpg?im_w=720', |
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 { useEffect, useState } from "react"; | |
| function useLocalStorage() { | |
| const [loadingStates, setLoadingStates] = useState<Map<string, boolean>>( | |
| new Map() | |
| ); | |
| const setStorageValue = <T>(key: string, value: T) => { | |
| try { | |
| window.localStorage.setItem(key, JSON.stringify(value)); |
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 { useCallback, useEffect, useRef, useState } from "react"; | |
| /** | |
| * Custom React hook for double-click confirmation for critical actions. | |
| * | |
| * @param action - The action to be executed on the second click. | |
| * @param timeout - Time in milliseconds to reset the unlocked state. | |
| * @returns The current unlocked state and the trigger function. | |
| */ | |
| const useConfirmation = (action: () => void, timeout: number = 5000) => { |
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 { useCallback, useState } from "react"; | |
| // Custom hook to copy text to clipboard | |
| const useCopyToClipboard = (timeoutDuration: number = 1000) => { | |
| const [copied, setCopied] = useState(false); | |
| const [error, setError] = useState<Error | null>(null); | |
| const copyToClipboard = useCallback( | |
| async (text: string) => { | |
| try { |
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
| /** | |
| * Custom hook for dynamically resizing a textarea to fit its content. | |
| * @param {React.RefObject<HTMLTextAreaElement>} textareaRef - Reference to the textarea element. | |
| * @param {string} textContent - Current text content of the textarea. | |
| * @param {number} maxHeight - Optional: maxHeight of the textarea in pixels. | |
| */ | |
| import { useEffect } from "react"; | |
| const useDynamicTextareaSize = ( | |
| textareaRef: React.RefObject<HTMLTextAreaElement>, |
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 { AnimatePresence, motion } from "framer-motion"; | |
| import { PropsWithChildren } from "react"; | |
| import useResizeObserver from "use-resize-observer"; | |
| const ignoreCircularReferences = () => { | |
| const seen = new WeakSet(); | |
| return (key: string, value: Record<string, unknown>) => { | |
| if (key.startsWith("_")) return; | |
| if (typeof value === "object" && value !== null) { | |
| if (seen.has(value)) return; |
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 prompts = require('prompts'); | |
| const {exec} = require('child_process'); | |
| const fs = require('fs'); | |
| (async () => { | |
| const response = await prompts({ | |
| type: 'text', | |
| name: 'fileName', | |
| message: 'What is the file name you want to generate subtitles for?', | |
| description: 'Please enter the file name with the extension. Make sure it is in your public folder.', |
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 child_process = require('child_process'), | |
| http = require('http'); | |
| url = require('url'), | |
| ffmpeg = null; | |
| var livestream = function (req, resp) { | |
| // For live streaming, create a fragmented MP4 file with empty moov (no seeking possible). | |
| var input = 'udp://225.1.1.1:8208'; |
NewerOlder