sql
CREATE TABLE idempotency_keys (
    id              BIGSERIAL PRIMARY KEY,
    idempotency_key TEXT        NOT NULL,
    request_path    TEXT        NOT NULL,
    request_fingerprint TEXT    NOT NULL,
    status          TEXT        NOT NULL DEFAULT 'in_progress',

Idempotent POST Requests with an Idempotency-Key Middleware in Express

express idempotency middleware
by codesnips 3 tabs
typescript
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';

export interface ConfirmDialogData {
  title: string;
  message: string;

Reusable Angular Confirmation Dialog Service Returning an Observable of the User's Choice

angular rxjs observables
by codesnips 3 tabs
java
package com.example.health;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

Custom Spring Boot HealthIndicator for Queue Depth on /actuator/health

spring-boot actuator health-check
by codesnips 4 tabs
rust
use anyhow::{anyhow, Result};
use chrono::{DateTime, Utc};
use cron::Schedule as CronSchedule;
use std::str::FromStr;

pub struct Schedule {

Parse Cron Expressions and Run Due Recurring Jobs in Rust with Tokio

rust tokio cron
by codesnips 3 tabs
python
import uuid
from django.db import models


class Cart(models.Model):
    OPEN = "open"

Prevent Duplicate Order Submissions in Django with select_for_update Row Locking

django postgres concurrency
by codesnips 3 tabs
ruby
class CounterBuffer
  DELTA_HASH = "counter:deltas".freeze

  READ_RESET = <<~LUA.freeze
    local v = redis.call('HGET', KEYS[1], ARGV[1])
    if v then redis.call('HDEL', KEYS[1], ARGV[1]) end

Debounce Expensive Counter Cache Updates with a Throttled Redis Buffer in Rails

rails redis counter-cache
by codesnips 3 tabs
javascript
import React from 'react';

export function UndoSnackbar({ pending, onUndo }) {
  if (!pending) return null;

  return (

Undoable Delete with a Snackbar and useReducer Timeout Controller in React

react hooks usereducer
by codesnips 3 tabs
php
<?php

namespace App\Models;

use App\Support\TransientUrl;
use Illuminate\Database\Eloquent\Model;

Generate Temporary Signed S3 Download URLs for Private Files in Laravel

laravel s3 storage
by codesnips 4 tabs
java
@RestController
@RequestMapping("/api/customers")
public class CsvImportController {

    private final CsvImportService importService;

Streaming CSV Import in Spring Boot with MultipartFile and JDBC Batch Inserts

spring-boot csv jdbc
by codesnips 4 tabs
typescript
import { Injectable } from '@nestjs/common';
import { HealthIndicator, HealthIndicatorResult, HealthCheckError } from '@nestjs/terminus';
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class PrismaHealthIndicator extends HealthIndicator {

NestJS Health Checks With Terminus and a Custom Prisma Indicator

nestjs terminus health-checks
by codesnips 3 tabs
php
<?php

namespace App\Console\Commands;

use App\Jobs\CompileReportJob;
use Carbon\CarbonImmutable;

Schedule a Recurring Report Job in Laravel's Console Kernel

laravel scheduler cron
by codesnips 3 tabs
go
package apiclient

import (
	"context"
	"fmt"
	"io"

Sharing a golang.org/x/time/rate Limiter Across Goroutines for Outbound API Calls

go rate-limiting concurrency
by codesnips 3 tabs