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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>xAI Canvas Effect</title> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| html, body { width: 100%; height: 100%; overflow: hidden; background: #000; } | |
| canvas { display: block; width: 100%; height: 100%; } |
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 ITEMS = Array(10).fill(LogoPlaceholder) | |
| const GRADIENT_MASK_CLASSNAME = | |
| "[mask-image:_linear-gradient(to_right,transparent_0,_black_64px,_black_calc(100%-64px),transparent_100%)]" | |
| const GRADIENT_MASK_SM_CLASSNAME = | |
| "sm:[mask-image:_linear-gradient(to_right,transparent_0,_black_128px,_black_calc(100%-128px),transparent_100%)]" | |
| const ITEMS_WRAPPER_CLASSNAME = "animate-loop-scroll flex gap-16 pl-16" | |
| export const Carousel = () => { | |
| 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
| import type { ComponentPropsWithoutRef, ElementType } from "react" | |
| type PolymorphicComponentProps<TAs extends ElementType, TProps = object> = Omit< | |
| ComponentPropsWithoutRef<TAs>, | |
| keyof TProps | "as" // Prevent prop conflicts between TProps and built-in props | |
| > & | |
| TProps & { as?: TAs } | |
| export const MyComponent = <T extends ElementType = "div">({ | |
| as, |
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 { Open as unzipperOpen } from "unzipper"; | |
| const response = await fetch("http://example.com/file.zip"); | |
| const arrayBuffer = await response.arrayBuffer(); | |
| const buffer = Buffer.from(arrayBuffer); | |
| const directory = await unzipperOpen.buffer(buffer); | |
| // print out files and its contents | |
| for (const file of directory.files) { | |
| const fileBuffer = await file.buffer(); |
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 { useState } from "react" | |
| const App = () => { | |
| const [value, setValue ] = useState("") | |
| const text = value.split("") | |
| return ( | |
| <div> | |
| <input |
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 SwiftUI | |
| import Foundation | |
| func getRemainingTime(_ remainingSeconds: TimeInterval) -> String { | |
| let remainingSecondsAbs = abs(remainingSeconds) | |
| let hours = Int(remainingSecondsAbs) / 3600 | |
| let minutes = Int(remainingSecondsAbs) % 3600 / 60 | |
| let seconds = Int(remainingSecondsAbs) % 60 | |
| let isNegative = Bool(remainingSeconds < 0) |
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 deepValues = (obj) => { | |
| return Object.values(obj).flatMap((value) => { | |
| if (typeof value === "object") { | |
| return deepValues(value); | |
| } | |
| return 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
| #! /bin/bash | |
| # this script is meant for zsh, there might be some fixes needed to run it in bash or other shells | |
| p() { | |
| # Start at the current directory and check up to two directories above | |
| dirs=( "." ".." "../.." ) | |
| for dir in "${dirs[@]}"; do | |
| if [ -f "$dir/pnpm-lock.yaml" ]; then | |
| echo "Using pnpm" | |
| pnpm "$@" |
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 removeDiacritics = (str: string): string => { | |
| return str.normalize("NFD").replace(/\p{Diacritic}/gu, ""); | |
| }; |
NewerOlder