python
import abc
from typing import IO


class Exporter(abc.ABC):
    name: str = ""

Plugin Registry with Class Decorators and setuptools Entry-Point Discovery

python plugins decorators
by codesnips 4 tabs
java
package com.shop.orders.events;

import java.math.BigDecimal;
import java.time.Instant;

public final class OrderPlaced {

Publishing and Consuming an OrderPlaced Domain Event with Spring's ApplicationEventPublisher

java spring-boot spring
by codesnips 4 tabs
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
export interface Todo {
  id: string;
  title: string;
  done: boolean;
}

Optimistic Todo Toggling in React with Rollback via useReducer

javascript typescript react
by codesnips 3 tabs
go
package export

import (
	"encoding/csv"
	"log"
	"net/http"

Streaming Large CSV Exports in Go Without Buffering the Whole File

go http csv
by codesnips 3 tabs
ruby
require "securerandom"
require "digest"

class SlidingWindowLimiter
  Result = Struct.new(:allowed, :count, :remaining)

Sliding-Window API Rate Limiting with Rack Middleware and Redis

ruby rack redis
by codesnips 4 tabs
rust
use std::time::Duration;
use rand::Rng;

#[derive(Clone, Debug)]
pub struct BackoffPolicy {
    pub base_delay: Duration,

Exponential Backoff With Jitter for Retrying Fallible Async Operations in Rust

rust tokio async
by codesnips 3 tabs
python
import random
from dataclasses import dataclass
from typing import Iterator


@dataclass(frozen=True)

Retry Flaky HTTP Requests with Exponential Backoff and Full Jitter in Python

python requests retry
by codesnips 3 tabs
java
package com.example.security;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.io.Decoders;

Stateless JWT Authentication Filter and SecurityFilterChain in Spring Boot

java spring-boot spring-security
by codesnips 3 tabs
yaml
auth:
  - authentication required for non-public endpoints
  - authorization rules documented and tested
data:
  - secrets stored outside source control
  - encryption in transit enabled

Security review checklist for production readiness of new services

security-review checklist production-readiness
by Kai Nakamura 1 tab
bash
#!/usr/bin/env bash
set -euo pipefail

cosign sign --key env://COSIGN_PRIVATE_KEY ghcr.io/example/codesnips:${GITHUB_SHA}
cosign verify --key env://COSIGN_PUBLIC_KEY ghcr.io/example/codesnips:${GITHUB_SHA}

Signed release artifacts with cosign for software supply chain trust

supply-chain cosign signing
by Kai Nakamura 1 tab
plaintext
example.com.          IN TXT  "v=spf1 include:_spf.google.com -all"
default._domainkey    IN TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
_dmarc.example.com.   IN TXT  "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com; adkim=s; aspf=s"

Email security baseline with SPF DKIM and DMARC records

email-security spf dkim
by Kai Nakamura 1 tab