rust
#[derive(Debug, Clone, PartialEq)]
pub enum Line {
    Context(String),
    Remove(String),
    Add(String),
}

Parsing Unified Diff Hunks and Applying Them to a Text Buffer in Rust

diff unified-diff patch
by codesnips 3 tabs
python
from sqlalchemy import select

from .models import Order, db


def stream_orders(batch_size=1000):

Stream a Large CSV Export in Flask With a Generator Response

flask streaming csv
by codesnips 3 tabs
java
package com.example.rates.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.web.client.RestTemplate;

Retrying a Flaky External API with Spring Retry @Retryable and @Recover Fallback

spring-boot spring-retry resilience
by codesnips 4 tabs
php
<?php

namespace App\Dto;

use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;

Symfony Avatar Upload: Constrained Form Type, Image Validation, and an Uploader Service

symfony forms validation
by codesnips 4 tabs
java
package com.example.http;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;

Attaching Bearer Tokens to Spring RestClient Calls with a ClientHttpRequestInterceptor

spring-boot restclient interceptor
by codesnips 3 tabs
rust
use std::path::{Component, Path, PathBuf};

#[derive(Debug)]
pub enum ResolveError {
    Traversal,
    NotFound,

Safely Serving Static Files with Path Traversal Protection in Rust

rust axum tokio
by codesnips 3 tabs
java
package com.example.feed;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;

Keyset (Cursor) Pagination with Spring Data JPA and Base64 Cursors

spring spring-data jpa
by codesnips 3 tabs
php
<?php

namespace App\Services;

use App\Mail\VerifyEmail;
use App\Models\ContactEmail;

Signed URL Email Verification in Laravel Without the Built-in MustVerifyEmail Contract

laravel php signed-urls
by codesnips 4 tabs
rust
use std::collections::HashSet;
use std::hash::Hash;

pub struct DedupByKey<I, K, F> {
    inner: I,
    key_fn: F,

Order-Preserving Stream Deduplication by Key in Rust with a HashSet Guard

rust streams deduplication
by codesnips 3 tabs
javascript
const jwt = require('jsonwebtoken');

const ACCESS_SECRET = process.env.JWT_ACCESS_SECRET;
const REFRESH_SECRET = process.env.JWT_REFRESH_SECRET;
const ISSUER = 'api.example.com';
const AUDIENCE = 'example-web';

Sign and Verify JWT Access Tokens in Express Auth Middleware

express jwt authentication
by codesnips 3 tabs
go
package pipeline

import "context"

func generate(ctx context.Context, nums ...int) <-chan int {
	out := make(chan int)

Fan-Out/Fan-In Pipeline With Channels and Context Cancellation in Go

go concurrency channels
by codesnips 3 tabs
javascript
function createReadiness() {
  let ready = true;

  function markUnready() {
    ready = false;
  }

Graceful HTTP Server Shutdown on SIGTERM With In-Flight Request Draining in Node.js

nodejs http graceful-shutdown
by codesnips 3 tabs