@varundubey
Member since March 11, 2026
8 pastes ยท 1 collection
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
// Array helpers v2
function array_flatten($array) {
A simple multi-file web page demonstrating HTML, CSS, and JavaScript working together.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World (v3)</title>
Register a custom REST API endpoint in WordPress with proper authentication and validation.
<?php
/**
* Register a custom REST API endpoint.
*
* Usage: GET /wp-json/my-plugin/v1/items?per_page=10&page=1
Handy Python functions for working with files: reading, writing JSON, watching directories.
"""File utility functions for common operations."""
import json
import os
from pathlib import Path
Common SQL queries: joins, aggregations, window functions, CTEs.
-- ==========================================
-- SQL Query Cheatsheet
-- ==========================================
-- 1. Basic JOIN with aggregation
A reusable React hook for debouncing values, with TypeScript types and usage example.
import { useState, useEffect } from "react";
/**
* Debounce a value by a given delay.
*