const rules = {
required: (v) => v.trim() !== '' || 'This field is required.',
email: (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v) || 'Enter a valid email.',
min: (n) => (v) => v.length >= n || `Minimum ${n} characters required.`,
max: (n) => (v) => v.length <= n || `Maximum ${n} characters allowed.`,
const rules = {
required: (v) => v.trim() !== '' || 'This field is required.',
email: (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v) || 'Enter a valid email.',
min: (n) => (v) => v.length >= n || `Minimum ${n} characters required.`,
max: (n) => (v) => v.length <= n || `Maximum ${n} characters allowed.`,
<?php
class Collection implements Countable, IteratorAggregate {
private array $items;
public function __construct( array $items = [] ) {
#[derive(Debug)]
pub struct Request {
pub url: String,
pub method: String,
pub body: Option<String>,
import pandas as pd
import numpy as np
def clean_dataframe(df: pd.DataFrame) -> pd.DataFrame:
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# ── Config ──────────────────────────────────────────────────────────────────
:root {
/* Primitives */
--color-blue-50: #eff6ff;
--color-blue-500: #3b82f6;
--color-blue-600: #2563eb;
<?php
/**
* Generic transient cache wrapper.
*
* @param string $key Cache key (will be prefixed).
/**
* Like Promise.all but returns [result, error] tuples (never throws).
*/
export async function allSettledTuples(promises) {
const results = await Promise.allSettled(promises);
-- Composite index for common filter + sort
CREATE INDEX idx_orders_user_date
ON orders (user_id, created_at DESC);
-- Partial index (only active records)
import time
import contextlib
from typing import Generator
interface RateLimiterOptions {
windowMs: number;
max: number;
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
export class EventEmitter {
#listeners = new Map();
on(event, listener) {
if (!this.#listeners.has(event)) {
version: '3.9'
services:
app:
build: .
<?php
add_action( 'init', 'register_book_cpt' );
function register_book_cpt() {
$labels = [
import { useState, useMemo } from 'react';
export default function SortableTable({ columns, data }) {
const [sort, setSort] = useState({ key: null, dir: 'asc' });
from datetime import datetime, timedelta
from typing import Optional
from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer
<dialog id="modal" class="modal" aria-labelledby="modal-title" aria-describedby="modal-body">
<div class="modal__inner" role="document">
<header class="modal__header">
<h2 id="modal-title" class="modal__title">Confirm Action</h2>
<button class="modal__close" aria-label="Close dialog" autofocus>✕</button>