π΅βπ«
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 client'; | |
import type { JSXElementConstructor, ReactNode } from 'react'; | |
type InferProps<T> = T extends JSXElementConstructor<infer P> ? P : never; | |
type ProviderWithProps<T extends JSXElementConstructor<unknown>> = [ | |
T, | |
Omit<InferProps<T>, 'children'> | |
]; |
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 * as fs from 'node:fs'; | |
import { $ } from 'bun'; | |
const hslToRgb = (h: number, s: number, l: number): [number, number, number] => { | |
h /= 360; | |
s /= 100; | |
l /= 100; | |
if (s === 0) { | |
return [l, l, l].map((v) => Math.round(v * 255)) as [number, number, number]; |
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
type Success<T> = { | |
readonly success: true; | |
readonly value: T; | |
}; | |
type Failure<E> = { | |
readonly success: false; | |
readonly error: E; | |
}; |
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 | |
# Store your new Git credentials | |
NEW_NAME="<$1>" | |
NEW_EMAIL="<$2>" | |
# Color codes for output | |
GREEN='\033[0;32m' | |
BLUE='\033[0;34m' | |
NC='\033[0m' # No Color |
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 | |
# Function to extract package versions from flutter pub outdated | |
get_latest_versions() { | |
flutter pub outdated | grep -v "Package Name" | grep -v "dependencies:" | grep -v "^$" | while read -r line | |
do | |
# Skip the header line with dashes | |
if [[ $line == *"Current"* ]]; then | |
continue | |
fi |
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
from collections import defaultdict | |
try: | |
book: defaultdict[str, str] = defaultdict(str) | |
with open("test.txt", "r", encoding="utf-8") as file: | |
for line in file: | |
if line.strip(): | |
parts = line.split() | |
if len(parts) >= 2: | |
book[parts[0]] = parts[1] |
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 { promises as fs } from 'fs'; | |
import path from 'path'; | |
/** | |
* Utility class for cleaning and standardizing filenames across programming language directories. | |
* Handles conversion to kebab-case, roman numeral suffixes, and ensures unique filenames. | |
*/ | |
class FilenameCleaner { | |
/** List of programming language directories to process */ | |
private static readonly PROGRAMMING_DIRECTORIES = [ |
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
type Decrement<N extends number> = [ | |
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | |
10, 11, 12, 13, 14, 15, 16, 17, 18, 19 | |
][N]; | |
type ExtractNthProperty<T, N extends number> = | |
T extends readonly [infer First, ...infer Rest] | |
? N extends 0 | |
? First | |
: ExtractNthProperty<Rest, Decrement<N>> |
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 { toast } from "sonner"; | |
import { useMutation, useQueryClient } from "@tanstack/react-query"; | |
import { InferRequestType, InferResponseType } from "hono"; | |
import { hono_api } from "@/providers/core/server/react"; | |
import { useRouter } from "next/navigation"; | |
type MutationOptions<TRoute extends keyof typeof hono_api> = { | |
route: TRoute; | |
method: keyof (typeof hono_api)[TRoute]; | |
successMessage?: 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
/** | |
* Represents infinity for graph algorithms, using JavaScript's maximum safe integer | |
*/ | |
const INF = Number.MAX_SAFE_INTEGER; | |
/** | |
* Creates a 2D array (matrix) initialized with zeros | |
* @param {number} x - Number of rows | |
* @param {number} y - Number of columns | |
* @returns {number[][]} A 2D array of dimensions x by y filled with zeros |