performance

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
erb
{% load cache %}
<section class="dashboard">
  <h1>{{ team.name }} — Overview</h1>

  {% cache 3600 team_order_stats team.id stats_version %}
    <div class="stat-grid">

Cache an Expensive Dashboard Fragment with Django's Template Cache Tag and Signal-Based Invalidation

django caching template-cache
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.caching.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.ShallowEtagHeaderFilter;

Conditional GET with ETag ShallowEtagHeaderFilter and Cache-Control in Spring Boot

spring-boot http-caching etag
by codesnips 3 tabs
python
import asyncio
import time
from dataclasses import dataclass
from typing import Any, Dict

In-Memory TTL Cache for FastAPI Endpoints With a Cache-Key Builder Dependency

fastapi caching ttl
by codesnips 3 tabs
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
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

Cursor Pagination in Laravel with API Resources and Encoded Cursors

laravel pagination cursor-pagination
by codesnips 3 tabs
ruby
class CounterFlushJob
  include Sidekiq::Job
  sidekiq_options queue: :counters, retry: 3

  def perform
    CounterBuffer.flush_all.each do |field, delta|

Coalesced Counter Cache with Redis Buffering and Nightly Reconciliation in Rails

rails counter-cache redis
by codesnips 4 tabs
python
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mydb',
        'USER': 'myuser',
        'PASSWORD': 'mypassword',

Django database connection pooling for performance

django python database
by Priya Sharma 1 tab