const { EventEmitter } = require('events');
const HIGH_WATER_MARK = 1 << 20; // 1 MiB of buffered bytes per client
class SseHub extends EventEmitter {
constructor() {
from datetime import datetime
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
export type Validator = (value: string) => string | null;
export const required = (message = 'This field is required'): Validator => {
return (value) => (value.trim().length === 0 ? message : null);
};
package com.example.feed;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
class Article < ApplicationRecord
include PgSearch::Model
pg_search_scope :full_text_search,
against: { title: 'A', body: 'B' },
using: {
import { useEffect, useRef } from 'react';
const TABBABLE = [
'a[href]',
'button:not([disabled])',
'textarea:not([disabled])',
import json
import secrets
import time
from typing import Optional
import redis.asyncio as redis
import { createContext } from 'react';
export type ToastVariant = 'success' | 'error' | 'info';
export interface Toast {
id: number;
<?php
namespace App\Security\Voter;
use App\Entity\Comment;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
export const required = (msg = 'This field is required') => (value) =>
value && value.trim() !== '' ? '' : msg;
export const minLength = (n, msg) => (value) =>
value && value.length >= n ? '' : msg || `Must be at least ${n} characters`;
class User < ApplicationRecord
has_many :posts
has_many :comments
scope :digest_subscribers, -> {
where(digest_opt_in: true).where.not(confirmed_at: nil)
from datetime import datetime
from pydantic import BaseModel
class UserV1(BaseModel):