performance

ruby
class CacheNamespace
  attr_reader :name

  def initialize(name, store: Rails.cache)
    @name = name.to_s
    @store = store

Cache Key Versioning with a Single “namespace”

rails caching cache-invalidation
by codesnips 3 tabs
python
from products.models import Product


def import_products_bulk(product_data):
    """Import thousands of products efficiently."""
    products = [

Django bulk operations for performance

django python performance
by Priya Sharma 1 tab
typescript
import { lazy, Suspense } from 'react'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
import Layout from '@/components/Layout'

// Eager load critical routes
import Home from '@/pages/Home'

Lazy loading routes with React.lazy and Suspense

react performance code-splitting
by Maya Patel 1 tab
python
import base64
import json
from datetime import datetime
from typing import Optional, Tuple

Opaque Cursor Pagination for FastAPI Endpoints with SQLAlchemy

fastapi sqlalchemy pagination
by codesnips 3 tabs
typescript
import { useMemo } from "react";

export type SortDir = "asc" | "desc";
export interface SortConfig<T> {
  key: keyof T;
  dir: SortDir;

Memoized Async Search With a Cached Selector Hook in React

react hooks usememo
by codesnips 3 tabs
java
package com.example.fx.config;

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;

Caching Currency-Conversion Rates in Spring Boot With @Cacheable and Scheduled Eviction

spring-boot caching caffeine
by codesnips 3 tabs
ruby
module StatementTimeout
  extend ActiveSupport::Concern

  class TimeoutExceeded < StandardError; end

  def with_statement_timeout(milliseconds)

Guard Against Slow Queries with statement_timeout

rails postgres performance
by codesnips 3 tabs
css
/* Basic transitions */
.button {
  background-color: blue;
  color: white;
  padding: 1rem 2rem;
  transition: background-color 0.3s ease;

CSS animations and transitions for smooth interactions

css animations transitions
by Alex Chang 1 tab
java
package com.example.feed;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;

Keyset (Cursor) Pagination with Spring Data JPA and Base64 Cursors

spring spring-data jpa
by codesnips 3 tabs
ruby
# Gemfile
group :development do
  gem 'rack-mini-profiler'
  gem 'memory_profiler'
  gem 'stackprof'  # For flamegraphs
  gem 'bullet'     # N+1 detection

Performance profiling with rack-mini-profiler and tools

ruby rails performance
by Sarah Mitchell 2 tabs
python
from blog.models import Post


# Load only specific fields
posts = Post.objects.only('id', 'title', 'published_at')
for post in posts:

Django query optimization with only and defer

django python database
by Priya Sharma 1 tab
javascript
import { useEffect, useState } from "react";

export function useDebouncedValue(value, delay = 300) {
  const [debounced, setDebounced] = useState(value);

  useEffect(() => {

Debounced Search Input in React with a Reusable useDebouncedValue Hook

react hooks debounce
by codesnips 3 tabs