php
<?php

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

Aggregate Daily Sales into a Summary Table with a Laravel Console Command

laravel php console-command
by codesnips 4 tabs
sql
CREATE TABLE outbox_deliveries (
    id              BIGSERIAL PRIMARY KEY,
    dedupe_key      TEXT        NOT NULL,
    target_url      TEXT        NOT NULL,
    payload         JSONB       NOT NULL,
    status          TEXT        NOT NULL DEFAULT 'PENDING',

Reliable Webhook Delivery with a Transactional Outbox and Dedupe Key in Spring Boot

spring-boot webhooks outbox-pattern
by codesnips 3 tabs
javascript
const rolePermissions = {
  guest: ['article:read'],
  author: ['article:read', 'article:create', 'article:update:own'],
  editor: ['article:publish', 'article:update:any'],
  admin: ['user:manage', 'role:assign']
};

Role-Based Access Control in Express with Permission Middleware and Protected Routes

express rbac authorization
by codesnips 3 tabs
python
import time
import threading
from dataclasses import dataclass, field
from typing import Callable, Dict, List

Size-and-Time Batching Metrics Buffer With a Background Flush Loop

metrics batching buffering
by codesnips 4 tabs
typescript
import { Injectable } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { FormGroup } from '@angular/forms';
import { Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, take } from 'rxjs/operators';

Sync Angular Reactive Form State to URL Query Params With a Route-Aware Service

angular reactive-forms router
by codesnips 3 tabs
go
package quotes

import (
	"context"
	"encoding/json"
	"fmt"

Fan-In Parallel API Calls With a Bounded Worker Pool and Context Cancellation

go concurrency goroutines
by codesnips 3 tabs
ruby
class DailySignupRollup < ApplicationRecord
  validates :day, presence: true, uniqueness: true
  validates :total, :verified, numericality: { greater_than_or_equal_to: 0 }

  scope :for_range, ->(from, to) do
    where(day: from.to_date..to.to_date).order(:day)

Nightly Signup Rollups in Rails with a Scheduled Job and Upsert

rails postgres background-jobs
by codesnips 3 tabs
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;

Comment Moderation Queue With Pending Scope and Approval Action in Laravel

laravel eloquent moderation
by codesnips 3 tabs
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