import base64
import json
from datetime import datetime
class InvalidCursor(Exception):
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
import { useCallback, useEffect, useRef, useState } from "react";
export function useIntersectionObserver(options?: IntersectionObserverInit) {
const [isIntersecting, setIsIntersecting] = useState(false);
const nodeRef = useRef<Element | null>(null);
const optionsKey = JSON.stringify(options ?? {});
module KeysetPaginatable
extend ActiveSupport::Concern
class_methods do
def keyset_page(cursor: nil, limit: 20, direction: :desc)
limit = limit.to_i.clamp(1, 100)
package feed
import (
"encoding/base64"
"encoding/json"
"time"
module Paginatable
extend ActiveSupport::Concern
Page = Struct.new(:records, :next_cursor, keyword_init: true)
DEFAULT_LIMIT = 25
package listing
import "encoding/base64"
func Encode(name string) string {
return base64.RawURLEncoding.EncodeToString([]byte(name))
import base64
import json
from datetime import datetime
from typing import NamedTuple
from fastapi import HTTPException
import org.springframework.hateoas.RepresentationModel;
import java.math.BigDecimal;
public class ProductModel extends RepresentationModel<ProductModel> {
private final Long id;
function encodeCursor(row) {
if (!row) return null;
const payload = JSON.stringify({ t: row.created_at, id: row.id });
return Buffer.from(payload, 'utf8').toString('base64url');
}