Discover and search community code snippets.
claude test
# MacOS SnipperApp 3 - Claude Code Instructions This file is automatically loaded by Claude Code on every session. All project memory and coding rules live in `.ai/`.
A simple result builder for generating HTML strings.
@resultBuilder struct HTMLBuilder { static func buildBlock(_ components: String...) -> String { components.joined(separator: "\n")
A robust bash script template with error handling.
#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t'
Convert dataclasses to and from JSON with type safety.
from dataclasses import dataclass, asdict import json from typing import Optional
A custom React hook for debouncing values.
import { useEffect, useState } from "react"; export function useDebounce<T>(value: T, delay: number): T { const [debouncedValue, setDebouncedValue] = useState(value);
A frosted glass card effect using backdrop-filter.
.glass-card { background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
Properly clean up side effects in React hooks to prevent memory leaks.
import { useEffect, useRef } from "react"; export function useInterval(callback: () => void, delay: number | null) { const savedCallback = useRef(callback);
A concurrent worker pool using goroutines and channels.
package main import ( "fmt"
Define custom error types with the thiserror crate pattern.
use std::fmt; #[derive(Debug)] pub enum AppError {
A decorator that retries a function call with exponential backoff.
import time import functools from typing import Callable, TypeVar
Modern async/await pattern for making network requests in Swift.
func fetchData<T: Decodable>(from url: URL) async throws -> T { let (data, response) = try await URLSession.shared.data(from: url) guard let httpResponse = response as? HTTPURLResponse,