typescript

typescript
import { useEffect, useRef } from 'react';

export function Modal({ open, onClose, title, children }: any) {
  const ref = useRef<HTMLDivElement | null>(null);

  useEffect(() => {

Accessible modal with focus trap

react a11y frontend
by Mateo Rodriguez 1 tab
typescript
import { useState, useEffect } from 'react'

export function useDebounce<T>(value: T, delay: number = 500): T {
  const [debouncedValue, setDebouncedValue] = useState<T>(value)

  useEffect(() => {

Custom hooks for reusable logic

react hooks typescript
by Maya Patel 3 tabs
typescript
import { createConsumer, Cable } from '@rails/actioncable'

let cable: Cable | null = null

export function getCable(): Cable {
  if (!cable) {

WebSocket integration with Action Cable

react actioncable websockets
by Maya Patel 3 tabs
typescript
import nodemailer from 'nodemailer';

const transporter = nodemailer.createTransport({
  host: process.env.SMTP_HOST,
  port: Number(process.env.SMTP_PORT ?? 587),
  auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS }

Email sending with nodemailer + templates

node email background-jobs
by Mateo Rodriguez 1 tab
typescript
import { useState, useMemo, useCallback } from 'react'
import { Post } from '@/types'
import { PostCard } from './PostCard'

interface FilteredPostsProps {
  posts: Post[]

Memoization in React with useMemo and useCallback

react performance memoization
by Maya Patel 1 tab
typescript
import { Injectable } from '@nestjs/common';

export interface RateLimitResult {
  allowed: boolean;
  remaining: number;
  limit: number;

Sliding-Window Webhook Rate Limiting with a NestJS Interceptor and In-Memory Counter

typescript nestjs rate-limiting
by codesnips 3 tabs
typescript
import { useEffect, useState, useRef } from 'react'

interface UseInViewOptions {
  threshold?: number | number[]
  rootMargin?: string
  triggerOnce?: boolean

Intersection Observer API for visibility tracking

react performance intersection-observer
by Maya Patel 2 tabs
typescript
import type { ErrorRequestHandler } from 'express';

export const errorMiddleware: ErrorRequestHandler = (err, req, res, _next) => {
  const requestId = (req as any).requestId;
  // eslint-disable-next-line no-console
  console.error('api.error', { requestId, err: String(err?.message ?? err) });

Backend: normalize errors with a single Express handler

node express reliability
by Mateo Rodriguez 1 tab
typescript
type State = 'closed' | 'open' | 'half_open';

export function circuitBreaker<T>(fn: () => Promise<T>, opts: { failThreshold: number; coolDownMs: number }) {
  let state: State = 'closed';
  let failures = 0;
  let openedAt = 0;

Circuit breaker wrapper for flaky third-party APIs

node reliability
by Mateo Rodriguez 1 tab
typescript
import type { Request, Response } from 'express';
import { pool } from '../db/pool';

export function liveness(_req: Request, res: Response) {
  res.status(200).json({ ok: true });
}

Health checks with readiness + liveness

deploy reliability node
by Mateo Rodriguez 1 tab
typescript
import { useReducer } from 'react'

interface FormState {
  values: Record<string, any>
  errors: Record<string, string>
  touched: Record<string, boolean>

React useReducer for complex state logic

react hooks state-management
by Maya Patel 1 tab
typescript
// 1. Basic types
let username: string = 'Alex';
let age: number = 30;
let isActive: boolean = true;
let items: string[] = ['item1', 'item2'];
let numbers: Array<number> = [1, 2, 3];

TypeScript fundamentals for type-safe front-end code

typescript javascript types
by Alex Chang 2 tabs