php
<?php

namespace App\Http\Controllers;

use App\Jobs\SendNewsletterChunk;
use App\Models\NewsletterSend;

Chunk-Process a Large Newsletter Send with Laravel Job Batching and Progress Tracking

laravel queues job-batching
by codesnips 3 tabs
rust
const CONSECUTIVE_BONUS: f64 = 8.0;
const WORD_START_BONUS: f64 = 10.0;
const MATCH_BASE: f64 = 4.0;
const LEADING_PENALTY: f64 = 0.5;

#[derive(Debug, Clone, Copy)]

Fuzzy Search Ranker with Subsequence Matching and Score-Based Sorting in Rust

fuzzy-search ranking algorithms
by codesnips 3 tabs
ruby
module HealthCheckable
  extend ActiveSupport::Concern

  CheckResult = Struct.new(:name, :ok, :message, keyword_init: true)

  private

Rails Health-Check Endpoint With a Controller Concern and Database Ping

rails health-check monitoring
by codesnips 3 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
python
from datetime import datetime
from app.extensions import db


class IdempotencyKey(db.Model):
    __tablename__ = "idempotency_keys"

Idempotency-Key Deduplication for POST Requests in a Flask Blueprint

flask idempotency postgres
by codesnips 3 tabs
typescript
export interface UseClipboardResult {
  copied: boolean;
  error: Error | null;
  copy: (value: string) => Promise<boolean>;
}

Copy-to-Clipboard Button With a useClipboard Hook and Timed Success Feedback

react hooks clipboard
by codesnips 3 tabs
go
package main

import (
	"log"
	"net/http"
	"time"

Serving Partial Video Content with HTTP Range Requests in Go

go http range-requests
by codesnips 3 tabs
typescript
import { useEffect, useState } from "react";

export function useDebouncedValue<T>(value: T, delay = 800): T {
  const [debounced, setDebounced] = useState<T>(value);

  useEffect(() => {

Debounced Draft Autosave with React Query and a Saving-Status Indicator

react react-query autosave
by codesnips 4 tabs
php
<?php

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

Slugify Post Titles on Save With a Laravel Model Observer and Guaranteed Uniqueness

laravel eloquent observer
by codesnips 4 tabs
go
package httpmetrics

import "github.com/prometheus/client_golang/prometheus"

var (
	httpRequestDuration = prometheus.NewHistogramVec(

HTTP Latency and Status Code Middleware with Prometheus in Go

go middleware prometheus
by codesnips 3 tabs
python
import time
import uuid
from dataclasses import dataclass

import redis

Sliding-Window Per-User Rate Limiting With Redis and a Flask Decorator

rate-limiting redis flask
by codesnips 3 tabs
php
<?php

namespace App\Domain;

use InvalidArgumentException;

Serializing a Money Value Object with a Custom Symfony Normalizer

symfony serializer value-object
by codesnips 3 tabs