performance

typescript
import Redis from "ioredis";

export const redis = new Redis(process.env.REDIS_URL ?? "redis://localhost:6379");

export interface Codec<T> {
  encode(value: T): string;

Redis cache-aside for expensive reads

redis performance caching
by codesnips 3 tabs
ruby
class Order < ApplicationRecord
  belongs_to :customer

  scope :for_export, -> {
    select(:id, :reference, :total_cents, :currency, :created_at, :customer_id)
      .where.not(exported_at: nil)

Avoid Memory Blowups: find_each + select Columns

rails activerecord performance
by codesnips 3 tabs
ruby
module ConditionalGet
  extend ActiveSupport::Concern

  private

  def render_conditional(resource, extra: nil)

ETag + Conditional GET for JSON API

rails performance http-caching
by codesnips 2 tabs
go
package main

import (
  "os"
  "runtime/debug"
  "strconv"

Set a soft memory limit with debug.SetMemoryLimit

go performance memory
by Leah Thompson 1 tab
rust
use rayon::prelude::*;

fn main() {
    let numbers: Vec<_> = (0..1000).collect();

    let sum: i32 = numbers

Rayon for data parallelism with par_iter

rust parallelism rayon
by Marcus Chen 1 tab
sql
-- Basic query debugging with EXPLAIN
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';

-- Output shows query plan:
-- Seq Scan on users (cost=0.00..25.00 rows=1 width=100)
--   Filter: (email = 'test@example.com'::text)

Query debugging and troubleshooting techniques

postgresql debugging troubleshooting
by Maria Garcia 2 tabs
sql
CREATE TABLE daily_events (
    id          BIGSERIAL PRIMARY KEY,
    category    TEXT        NOT NULL,
    item_id     BIGINT      NOT NULL,
    score       NUMERIC(10,2) NOT NULL DEFAULT 0,
    occurred_at TIMESTAMPTZ NOT NULL DEFAULT now()

Database-Driven “Daily Top” with window functions

postgres sql analytics
by codesnips 3 tabs
typescript
import { useState, useMemo, useCallback } from 'react'
import { Post } from '@/types'
import { PostCard } from './PostCard'

interface FilteredPostsProps {
  posts: Post[]

Memoization in React with useMemo and useCallback

react performance memoization
by Maya Patel 1 tab
swift
import Foundation
import UIKit

// MARK: - Memory Leak Prevention
class ImageDownloader {
    private var tasks: [URL: URLSessionDataTask] = [:]

Instruments and performance profiling

ios performance profiling
by Sofia Martinez 1 tab
rust
use std::collections::HashMap;
use std::hash::Hash;
use std::sync::{Arc, RwLock};

pub struct Memoizer<K, V> {
    store: RwLock<HashMap<K, Arc<V>>>,

Thread-Safe Memoization in Rust with RwLock and OnceCell Sharding

rust concurrency memoization
by codesnips 3 tabs
typescript
import { useEffect, useState, useRef } from 'react'

interface UseInViewOptions {
  threshold?: number | number[]
  rootMargin?: string
  triggerOnce?: boolean

Intersection Observer API for visibility tracking

react performance intersection-observer
by Maya Patel 2 tabs
php
<?php

namespace App\Services;

use App\Models\Order;
use Illuminate\Support\Facades\Cache;

Cache Expensive Dashboard Aggregates and Bust Them on Write in Laravel

laravel caching redis
by codesnips 4 tabs