class Coupon < ApplicationRecord
before_validation :normalize_code
validates :code,
coupon_code: { min_length: 6 },
uniqueness: { case_sensitive: false }
pub enum Node {
File { name: String, size: u64 },
Dir { name: String, children: Vec<Node> },
}
impl Node {
use std::time::Duration;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Config {
pub endpoint: String,
pub timeout: Duration,
class DashboardMetrics
include ActiveModel::Model
attr_reader :account
def initialize(account)
'use strict';
const { Transform } = require('stream');
class LineSplitter extends Transform {
constructor(options = {}) {
class ShippedEmailJob
include Sidekiq::Job
sidekiq_options queue: :mailers, retry: 5
def perform(order_id)
order = Order.find_by(id: order_id)
import { useLayoutEffect, useRef, useCallback } from 'react';
export function useScrollAnchor(anchorItemCount) {
const containerRef = useRef(null);
const savedRef = useRef(null);
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.
-- 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 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>,