java
package com.shop.catalog;

import org.springframework.data.jpa.domain.Specification;

import java.math.BigDecimal;

Dynamic Product Filtering with JPA Specifications from Optional Query Params

spring-boot jpa specifications
by codesnips 4 tabs
ruby
class EmailDedupService
  DEFAULT_TTL = 5.minutes.to_i

  def self.claim(fingerprint, ttl: DEFAULT_TTL)
    key = "email_dedup:#{fingerprint}"
    # Atomic set-if-absent with expiry; returns true only for the first caller.

Throttle Duplicate Emails in Rails with a Mailer Interceptor and Redis Dedup Service

rails actionmailer redis
by codesnips 3 tabs
typescript
export interface Post {
  id: string;
  title: string;
  updatedAt: string;
}

Deduplicating Paginated API Results With a Normalized Entity Store and Reducer

react reducer normalization
by codesnips 3 tabs
php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Validate an Unredeemed Coupon Code with a Custom Laravel Rule Object

laravel validation eloquent
by codesnips 4 tabs
go
package httpcache

import (
	"strconv"
	"strings"
	"time"

Parsing Cache-Control max-age for a TTL In-Memory Cache in Go

go caching http
by codesnips 3 tabs
rust
use tokio::sync::mpsc::{self, Sender};
use tokio::sync::mpsc::error::TrySendError;

use crate::email::{EmailJob, EmailMessage};
use crate::worker::EmailWorker;

Retry-Aware Email Queue With a Tokio mpsc Worker and Exponential Backoff

rust tokio async
by codesnips 3 tabs
python
import hashlib
import json


def compute_etag(payload, weak=False):
    body = json.dumps(payload, sort_keys=True, separators=(",", ":"))

Conditional GET with ETag Generation and 304 Not Modified in Flask

flask http caching
by codesnips 3 tabs
java
package com.example.orders.dto;

import com.example.orders.validation.ValidationGroups.Create;
import com.example.orders.validation.ValidationGroups.Update;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;

Cascading @Valid on Nested DTOs with Validation Groups in Spring Boot

spring-boot validation bean-validation
by codesnips 4 tabs
ruby
Rails.application.routes.draw do
  resources :articles do
    resources :comments, shallow: true, only: %i[index new create show edit update destroy]
  end

  root "articles#index"

Nested Comments on Articles with Shallow Routing and Scoped Lookups in Rails

rails routing controllers
by codesnips 3 tabs
rust
use std::fmt;

#[derive(Debug)]
pub enum HashError {
    Backend(String),
    InvalidHash,

Pluggable Password Hasher Trait in Rust with Argon2 and Bcrypt Backends

rust argon2 bcrypt
by codesnips 3 tabs
javascript
const Busboy = require('busboy');
const { storeFile } = require('./storage');

function parseMultipart(req, { maxFileSize = 20 * 1024 * 1024 } = {}) {
  return new Promise((resolve, reject) => {
    const busboy = Busboy({

Streaming Multipart Form Upload Parser Using Busboy in Node.js

nodejs multipart streaming
by codesnips 3 tabs
python
import os
import uuid

from flask import Blueprint, current_app, jsonify, request
from werkzeug.exceptions import RequestEntityTooLarge

Streaming Large Multipart File Uploads to Disk in Flask Without Buffering

flask werkzeug streaming
by codesnips 3 tabs