π΅βπ«
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
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
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
'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
/** | |
* 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
// 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
interface Node<T = unknown, Nodes extends Node<any, any>[] = Node<any, any>[]> { | |
value: T; | |
neighbors: Nodes; | |
} | |
type A = Node<1, [B, C]> | |
type B = Node<2, [A, D]> | |
type C = Node<3, [A, B]> | |
type D = Node<4, [B, C]> |
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 std::{ | |
collections::HashMap, | |
sync::{ | |
atomic::{AtomicBool, AtomicUsize, Ordering}, | |
Arc, Mutex, RwLock, | |
}, | |
thread, | |
time::{Duration, Instant}, | |
}; | |
use tokio::{ |
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
package concurrency | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"sync" | |
"time" | |
"errors" | |
) |
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 threading | |
import queue | |
import concurrent.futures | |
import logging | |
from typing import List, Callable, Any | |
from dataclasses import dataclass | |
from datetime import datetime | |
import time | |
# Configure logging |