performance

ruby
class ExplainAnalyzer
  def initialize(relation, watched_tables:)
    @relation = relation
    @watched_tables = Array(watched_tables).map(&:to_s)
  end

Fast Fail for Missing Indexes (EXPLAIN sanity check)

rails postgres performance
by codesnips 3 tabs
sql
CREATE TABLE posts (
    id           bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    author_id    bigint NOT NULL REFERENCES authors (id),
    title        text   NOT NULL,
    body         text   NOT NULL,
    published_at timestamptz NOT NULL DEFAULT now()

Cursor-based pagination with stable ordering

postgres performance pagination
by codesnips 4 tabs
ruby
Rails.application.configure do
  # Bullet configuration
  config.after_initialize do
    Bullet.enable = true
    Bullet.alert = true # Show JavaScript alert
    Bullet.bullet_logger = true # Log to bullet.log

Rails N+1 query detection with Bullet

rails performance n-1
by Maya Patel 3 tabs
rust
use parking_lot::Mutex;
use std::sync::Arc;
use std::thread;

fn main() {
    let counter = Arc::new(Mutex::new(0));

Parking_lot for faster synchronization primitives

rust concurrency performance
by Marcus Chen 1 tab
erb
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>

<div class="posts-index">
  <div class="sticky top-0 bg-white border-b" id="search-bar">
    <%= form_with url: posts_path, method: :get, data: { turbo_frame: "_top", turbo_action: "morph" } do |f| %>
      <%= f.search_field :q,

Morphing page updates with Turbo Morphing

hotwire turbo morphing
by Jordan Lee 2 tabs
javascript
export const CACHE_VERSION = 'v7';

export const APP_SHELL = '/index.html';

export const PRECACHE_URLS = [
  '/',

Service worker: cache static assets safely

web performance pwa
by codesnips 3 tabs
typescript
import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';

const shared = {
  keepAlive: true,
  keepAliveMsecs: 1_000,

HTTP keep-alive agent for outbound calls

http performance nodejs
by codesnips 3 tabs
rust
use std::mem::MaybeUninit;

fn main() {
    let mut uninit: MaybeUninit<i32> = MaybeUninit::uninit();
    unsafe {
        uninit.as_mut_ptr().write(42);

MaybeUninit for safe uninitialized memory

rust unsafe memory
by Marcus Chen 1 tab
typescript
import { useCallback, useEffect, useState } from "react";

interface Options {
  rootMargin?: string;
  threshold?: number;
}

IntersectionObserver infinite scroll hook

react hooks intersection-observer
by codesnips 3 tabs
javascript
// Creating elements
const div = document.createElement('div');
div.id = 'container';
div.className = 'box rounded';
div.textContent = 'Hello World';

DOM manipulation best practices and performance optimization

javascript dom manipulation
by Alex Chang 1 tab
swift
import UIKit

class ImageCache {
    static let shared = ImageCache()

    private let cache = NSCache<NSString, UIImage>()

Image caching with NSCache and async loading

swift swiftui images
by Sofia Martinez 2 tabs
ruby
class CheckoutService
  def initialize(cart:, user:)
    @cart = cart
    @user = user
  end

Instrument a Service with Notifications

rails observability instrumentation
by codesnips 3 tabs