class PresenceRegistry
TTL = 30 # seconds a user counts as present without a heartbeat
def initialize(room_id, redis: REDIS)
@room_id = room_id
@redis = redis
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["wrapper", "template", "anchor"]
add(event) {
class Article < ApplicationRecord
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
scope :published, -> { where.not(published_at: nil) }
module QueryBudget
class Counter
IGNORED = %w[SCHEMA CACHE TRANSACTION].freeze
attr_reader :count
class AddSearchVectorToArticles < ActiveRecord::Migration[7.1]
def up
execute <<~SQL
ALTER TABLE articles
ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (
class AddLockVersionToPosts < ActiveRecord::Migration[6.1]
def change
add_column :posts, :lock_version, :integer, default: 0, null: false
end
end
<%# locals: item %>
<button
type="button"
class="toggle-btn"
data-controller="toggle"
data-action="click->toggle#toggle"
class PaymentService
def initialize
Stripe.api_key = Rails.application.credentials.stripe[:secret_key]
end
def create_payment_intent(amount:, currency: 'usd')
class AttachmentContentTypeValidator < ActiveModel::EachValidator
SIGNATURES = {
"image/png" => ["\x89PNG\r\n\x1a\n".b],
"image/jpeg" => ["\xFF\xD8\xFF".b],
"image/gif" => ["GIF87a".b, "GIF89a".b],
"application/pdf" => ["%PDF-".b]
class Task < ApplicationRecord
POSITION_GAP = 1024
belongs_to :board
scope :ordered, -> { order(:position) }
class SlidingWindowLimiter
Result = Struct.new(:allowed, :count, :limit, :window_ms, keyword_init: true)
SCRIPT = <<~LUA.freeze
local key = KEYS[1]
local now = tonumber(ARGV[1])
class Reminder < ApplicationRecord
belongs_to :user
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone::MAPPING.values }
validates :local_time, presence: true