π΅βπ«
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
// Base utility types | |
type Whitespace = '\u{9}' | '\u{A}' | '\u{20}' // tab, newline, space | |
type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` | |
? TrimLeft<R> | |
: V | |
type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` | |
? TrimRight<R> | |
: V |
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
/** | |
* Node.js file system module for file operations | |
*/ | |
import fs from "node:fs"; | |
/** | |
* Node.js path module for handling file paths | |
*/ | |
import path from "node:path"; | |
/** |
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 React, { Suspense } from 'react'; | |
import { ClientError, Loader } from '@/components' | |
import { fetcher } from "@/lib" | |
import { useSuspenseQuery } from '@tanstack/react-query'; | |
import { catchError, parseCodePath } from '@/utils'; | |
/** | |
* A React component that handles data fetching with built-in loading, error handling, and caching. |
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 axios, { type AxiosRequestConfig, AxiosError } from 'axios'; | |
/** | |
* Wraps a promise to return a tuple containing either the resolved value or an error. | |
* Provides a cleaner way to handle promise rejections without try/catch blocks. | |
* | |
* @template T - The type of value that the promise resolves to | |
* @param {Promise<T>} promise - The promise to handle | |
* @returns {Promise<[undefined, T] | [Error]>} A promise that resolves to a tuple containing either: | |
* - [undefined, T] if the promise resolves successfully, where T is the resolved 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
from typing import List, Dict | |
from datetime import datetime | |
import csv | |
def parse_jobs(file_path: str) -> List[Dict[str, str]]: | |
jobs = [] | |
with open(file_path, "r", encoding="utf-8-sig") as f: # Changed to utf-8-sig | |
reader = csv.DictReader(f) | |
for row in reader: | |
# Parse the date |
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 Counter | |
from typing import Dict, List, Tuple | |
def analyze_patterns(terms_dict: Dict[str, str]) -> Tuple[Dict[str, int], List[str]]: | |
""" | |
Analyzes terms to find common patterns and potential regex optimizations. | |
Returns frequency of patterns and suggested regex patterns. | |
""" | |
# Convert all terms to list and lowercase for consistency |
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 |
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
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 { 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 = [ |