Blog

Not much time to write these days, but below are some tidbits I picked up and a few things I wanted to get off my chest - in case you feel like reading.

Production console in Kubernetes from your laptop

A small Docker image with a baked-in service account and a few kubectl scripts so any dev can get a Rails console, a dbconsole, or a fat pod with extra disk in the cluster, without stepping on each other.

  • Docker
  • DevOps
  • Kubernetes
  • Ruby on Rails

Typo-aware email search in PostgreSQL

Finding customers who signed up with a misspelled email - using pg_trgm, GIN trigram indexes, similarity operators, and a domain-splitting trick to keep it fast.

  • Databases
  • PostgreSQL
  • Search
  • TypeScript

A/B testing in Rails outside of controllers

Using the split gem for A/B tests in GraphQL resolvers and background jobs, and recording conversions outside the web request flow - scenarios split.rb doesn't document.

  • Programming
  • Ruby
  • Ruby on Rails
  • GraphQL

Inlined images in Next.js

Configuring a Next.js webpack loader to inline small images as base64 so they ship with the bundle instead of costing an extra network request.

  • nextjs
  • TypeScript

Migration locks for TypeORM

Adding PostgreSQL advisory locking to TypeORM migrations so concurrent deploys can't run migrations on top of each other in a distributed system.

  • Databases
  • NodeJS
  • TypeORM
  • TypeScript

Using image loader in Next.js

How to write your own Next.js image loader (using Cloudinary as an example) so you keep image optimization without hitting Vercel's transformation limits.

  • nextjs
  • TypeScript

HTTP server in Ruby 3 - Fibers & Ractors

Part 2 of building an HTTP server in Ruby: single-threaded vs multi-threaded vs Fibers vs Ractors, with benchmarks and the limitations of each.

  • Concurrency
  • Fibers
  • HTTP
  • Ractors
  • Ruby

Ruby HTTP server from the ground up

Part 1 of building an HTTP server in Ruby: the HTTP protocol from the wire up, then a basic single-threaded, Rack-compatible server from scratch.

  • HTTP
  • Ruby

Track Opened Emails In Rails

Tracking email opens in Rails with Postmark webhooks and a 1x1 tracking pixel — a SentEmail model, an observer, and the webhook endpoint.

  • Emails
  • Postmark
  • Ruby
  • Ruby on Rails
  • Tracking

Turbocharge HTTP requests in Ruby

A PersistentHttpClient that reuses TCP connections via HTTP keep-alive — roughly a 4x speedup on repeated requests, with automatic cache cleanup.

  • HTTP
  • Performance
  • Ruby

Next.js: restrict pages to authenticated users

A higher-order function for Next.js pages that requires authentication — server-side cookie handling plus a client-side redirect to the login page.

  • authentication
  • Javascript
  • nextjs
  • TypeScript

Phone Authentication in Ruby

Implementing phone/SMS authentication in Ruby on Rails — verification codes, rate limiting, and encrypted phone tokens for sign-in and sign-up flows.

  • Authentication
  • Phone
  • Redis
  • Ruby
  • Ruby on Rails
  • Security
  • SMS

Encrypt & Decrypt text in Ruby

A small TextEncryptor class built on ActiveSupport for encrypting and decrypting strings you don't want clients to read or tamper with.

  • Ruby
  • Ruby on Rails
  • Security

Faster Google Maps load times

Five techniques to stop Google Maps from wrecking your Lighthouse score: lazy loading, the Static Maps API, skipping fonts, and static placeholders.

  • Google Maps
  • Javascript
  • Optimization
  • React
  • TypeScript

Ruby on Rails optimization techniques

A practical tour of Rails performance: killing N+1 queries, indexing, query rewriting, denormalization, caching, HTTP tuning, assets and background jobs.

  • Databases
  • Optimization
  • Programming
  • Ruby
  • Ruby on Rails
  • SQL

Running ActiveJob after transaction

Deferring ActiveJob enqueues until after the database transaction commits, so background jobs never run against data that hasn't been saved yet.

  • ActiveJob
  • Databases
  • Programming
  • Ruby
  • Ruby on Rails

Importing Compose.IO MongoDB dump into local docker instance

Step-by-step: importing a production MongoDB dump from Compose.io into a local Docker instance, including copying and renaming the database.

  • Bash
  • Databases
  • Docker
  • MongoDB

Better Ruby serialization into JSON

JsonDumper: a small gem for cleaner Ruby-to-JSON serialization that also solves the N+1 problem with built-in ActiveRecord preloading.

  • Programming
  • Ruby
  • Ruby on Rails

List all Rails helper methods

A short Ruby snippet to enumerate every helper method available in a Rails app, including ones from nested helper subdirectories.

  • Programming
  • Ruby on Rails

Pusher with Redux

pusher-redux: a small library that wires Pusher real-time channels into a Redux app, dispatching incoming events as actions with a clean subscribe API.

  • Javascript
  • Programming
  • Pusher
  • React
  • Redux

Smart page titles in Ruby on Rails

A small, gem-free pattern for page titles in Rails — set them per controller, per action, or let them fall back to a sensible implicit name.

  • Programming
  • Ruby on Rails

DNS over HTTPS

Run your own DNS-over-HTTPS proxy with a small Go program to bypass ISP-level DNS censorship — setup, /etc/hosts, and how to test it.

  • DNS
  • Go
  • Security

Easy error handling in Rails

Handling exceptions at the boundary of a Rails app with a custom UserError class, and rendering clean responses for JSON, HTML and JS requests.

  • Programming
  • Ruby on Rails

Subscribing to your VK friends Instagram

A small Ruby script that scrapes the Instagram links off your VK friends' profiles and follows those accounts for you via a headless browser.

  • Ruby

High Performance Browser Networking - Book Review

My review of Ilya Grigorik's High Performance Browser Networking — TCP, UDP, TLS, mobile networks, HTTP/1.1, HTTP/2 and WebRTC, chapter by chapter.

  • Books
  • Networks
  • Programming

Seamless ActiveRecord Model extension

Splitting a bloated ActiveRecord model into a separate model while keeping attribute access transparent via delegation and an assign_attributes override.

  • Databases
  • Programming
  • Ruby on Rails

Parsing HTML generated outside of Angular

Using Angular's $injector and $compile to bind HTML that was rendered outside Angular (e.g. by server-side jQuery code) into your Angular app.

  • Angular
  • Javascript
  • Programming

AngularJS directive for slide-down animation with lazy rendering

Building a reusable AngularJS directive that slide-down-animates a block and skips rendering its contents until it's actually expanded.

  • Angular
  • JavaScript
  • Programming

AngularJS + Socket.io

A small factory pattern for using Socket.io in AngularJS without piling up duplicate event subscriptions every time you navigate between views.

  • Angular
  • JavaScript
  • Programming

Readable NodeJS authorization

A readable middleware-style pattern for role-based authorization in Node.js/Express that plays nicely with async checks.

  • CoffeeScript
  • JavaScript
  • NodeJS
  • Programming
  • Security

Flexible Mock

A tiny, magic-free Mock class for Ruby built with metaprogramming — it keeps closure context and avoids the heavyweight mocking libraries.

  • Programming
  • Ruby
  • Testing

Thoughts on programming podcasts

How to actually get value out of programming podcasts — plus a 2013 list of favourites covering Ruby, software engineering and the wider industry.

  • Podcasts
  • Programming

Software construction == fighting bugs

A short reflection, inspired by Code Complete, on why software construction practices — reviews, testing, TDD — are ultimately all about killing bugs.

  • Debugging
  • Programming

Best Ruby resources

A 2013 collection of Ruby learning resources — docs, guides, interactive tutorials, screencasts, podcasts and tools — grouped by category.

  • Programming
  • Resources

Testing private methods

On testing private methods: instead of reflection tricks or loosening visibility, extract them into a collaborator class you can test directly.

  • Ruby
  • Testing

Technology whirlwind

A 2013 personal rant about the overwhelming flood of languages, frameworks and tools — and the impossible question of what to actually learn.

  • Programming
  • Rant

Hello Blog

The first post — a short hello, a Russian proverb about brevity, and a deliberately empty blog to grow from.

  • Blog
  • Programming