Template Gallery
Browse curated code screenshot templates. Click “Use this template” to open it in the editor with all settings pre-configured.
20 templates
import { useState, useCallback } from 'react';
export function useToggle(initial = false) {
const [value, setValue] = useState(initial);
const toggle = useCallback(() => {
'use server';
import { z } from 'zod';
const schema = z.object({
email: z.string().email(),
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
const buttonVariants = cva(
'inline-flex items-center rounded-md font-medium transition-colors',
{
import { Request, Response, NextFunction } from 'express';
import jwt from 'jsonwebtoken';
export function authenticate(
req: Request,
res: Response,
// prisma/schema.prisma
model User {
id String @id @default(cuid())
email String @unique
name String?
use thiserror::Error;
#[derive(Error, Debug)]
pub enum AppError {
#[error("Not found: {0}")]
NotFound(String),
package handlers
import (
"encoding/json"
"net/http"
)
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
resource "aws_lambda_function" "api" {
filename = "lambda.zip"
function_name = "${var.project}-api"
role = aws_iam_role.lambda.arn
handler = "index.handler"
runtime = "nodejs20.x"
function binarySearch<T>(
arr: T[],
target: T,
compare: (a: T, b: T) => number
): number {
let lo = 0;
type AnyFn = (...args: unknown[]) => unknown;
function debounce<T extends AnyFn>(
fn: T,
delay: number
): (...args: Parameters<T>) => void {
class ListNode<T> {
constructor(
public value: T,
public next: ListNode<T> | null = null
) {}
}
class Database {
private static instance: Database;
private pool: ConnectionPool;
private constructor() {
this.pool = new ConnectionPool({
type EventMap = Record<string, unknown>;
type Listener<T> = (data: T) => void;
class EventEmitter<E extends EventMap> {
private listeners = new Map<keyof E, Set<Listener<unknown>>>();
interface Notification {
send(to: string, message: string): Promise<void>;
}
class EmailNotification implements Notification {
async send(to: string, message: string) {
import time
import functools
from typing import TypeVar, Callable
T = TypeVar('T')
.dashboard {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 64px 1fr;
grid-template-areas:
"sidebar header"
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
interface AuthState {
user: User | null;
token: string | null;
SELECT
u.name,
o.total,
o.created_at,
ROW_NUMBER() OVER (
PARTITION BY u.id