class ShippedEmailJob
include Sidekiq::Job
sidekiq_options queue: :mailers, retry: 5
def perform(order_id)
order = Order.find_by(id: order_id)
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.
import { useLayoutEffect, useRef, useCallback } from 'react';
export function useScrollAnchor(anchorItemCount) {
const containerRef = useRef(null);
const savedRef = useRef(null);
package ratelimit
import (
"sync"
"time"
)
-- KEYS[1] = bucket key
-- ARGV: capacity, refillPerSec, now(ms), cost, ttl(sec)
local capacity = tonumber(ARGV[1])
local refill = tonumber(ARGV[2])
local now = tonumber(ARGV[3])
local cost = tonumber(ARGV[4])
package watch
import (
"sync"
"time"
)
package order
type CreateOrderRequest struct {
Reference string `json:"reference" binding:"required,min=3,max=40"`
Currency string `json:"currency" binding:"required,currency"`
Customer Customer `json:"customer" binding:"required"`
CREATE TABLE country (
code CHAR(2) PRIMARY KEY,
name VARCHAR(128) NOT NULL,
currency CHAR(3) NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
import { RefObject, useEffect, useRef } from "react";
type Handler = (event: MouseEvent | TouchEvent) => void;
export function useClickOutside<T extends HTMLElement>(
ref: RefObject<T>,
class TenantResolver
RESERVED = %w[www app admin].freeze
def initialize(app)
@app = app
end
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Resources\PostResource;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Page<T> {
pub items: Vec<T>,
#[serde(default)]