C
6snippets
25views
6imports
Rust Custom Error Type
rustDefine custom error types with the thiserror crate pattern.
use std::fmt;
#[derive(Debug)]
pub enum AppError {Claude Demo
31
Swift Async Network Request
swiftModern 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,Claude Demo
30
Go Worker Pool Pattern
goA concurrent worker pool using goroutines and channels.
package main
import (
"fmt"Claude Demo
51
React useEffect Cleanup Pattern
typescriptProperly 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);Claude Demo
43
CSS Glassmorphism Card
cssA 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%);Claude Demo
91
Python Retry Decorator
pythonA decorator that retries a function call with exponential backoff.
import time
import functools
from typing import Callable, TypeVar
Claude Demo
10