programming
programming
event-sourcing
Event Sourcing in practice: Lessons from the trenches
Event Sourcing can be introduced to legacy systems incrementally, no big rewrite required. Lessons from production: the migration event technique, upcasting old events, right-sizing aggregates, stream lifecycles, and payoffs in audits, analytics, and debugging.
ruby
How to create multi trait inside trait in FactoryBot
FactoryBot traits can nest other traits, letting you compose reusable test fixtures instead of copying attribute blocks. A quick refresher on traits, then the traitception pattern: defining traits inside traits and combining them for cleaner Rails test setup.
Latest
The necessity of architectural advancement
Evolutionary architecture treats change as a design input, not a threat. Why rigid paradigms fail, how to make well-informed architecture decisions, and how identifying architectural drivers and writing fitness functions keeps your system resilient.
Embracing Hexagonal Architecture in Ruby
Hexagonal Architecture separates your business logic from databases, UIs, and external services using ports and adapters. What the pattern really means, a practical Ruby implementation, when it pays off, and the common problems teams hit when adopting it.
Living documentation with the P3 model: A practical guide for engineers
Living documentation stops going stale with the P3 model: define the Purpose (why you document), the Process (how it stays current), and the Product (what readers get). A practical framework for engineers tired of outdated wikis and misleading docs.
What is ENVIRONMENT in rake task?
The :environment dependency in Rake tasks is what loads your Rails app, models, and database connections. What task my_task: :environment actually does behind the scenes, how the Rake dependency syntax works, and why skipping it breaks your custom tasks.
OJ is not as safe as you think for your JSON
OJ speeds up JSON in Ruby, but Oj.mimic_JSON silently drops the script_safe option, opening the door to XSS, and adds time precision quirks. What its monkey patching really changes, the stability risks, and best practices for using OJ without surprises.
What is params.expect and how to use it in Rails 8?
params.expect in Rails 8 replaces require/permit and fixes a real weakness: crafted params like ?user=string used to raise NoMethodError and 500 errors. How the new syntax works, how it handles arrays with precision, and how to migrate your controllers.
How to write custom RSpec matchers in your Ruby on Rails app
Custom RSpec matchers turn repetitive assertions into readable, reusable specs. Step by step: define a matcher with RSpec::Matchers.define, add clear failure messages, build flexible matchers that take arguments, and wire them into your Rails test suite.
What's new in Ruby 3.4
Ruby 3.4 adds the new 'it' block parameter that makes .then chains and maps cleaner than numbered parameters, chilled strings as a step toward immutability, and enhanced Range operations. What each change looks like in practice, with before and after code.
How to add rate limiting in Ruby on Rails 8
Rate limiting in Rails 8 is built in: the rate_limit method declares limits per controller and action, like 3 requests per 2 seconds on create. How to combine short and long windows, protect unsafe actions, and practical suggestions for sensible limits.
Mastering database enums in Rails with Postgres - Guide
Database enums in PostgreSQL give Rails apps type safety, implicit ordering, and faster queries than string columns. Single-value enums with validation, multi-select enum arrays, dynamic enum management, and the migrations that wire it all together.
How to run Rails console in safe sandbox mode?
Rails console sandbox mode wraps every database operation in a transaction and rolls it all back on exit, so you can experiment safely. How to launch it, plus the traps: database locking, non-rollbackable operations, and why production use still needs care.
Dealing with legacy code that uses different method naming conventions
Legacy services with mismatched method names (validate, execute!, run!) can be unified with Ruby method objects. How to build one dispatcher that calls the right method on each class, why it beats conditionals, and what it does for readability.
How to get table size in PostgreSQL database?
PostgreSQL table size is more than the data: pg_table_size, pg_indexes_size, and pg_total_relation_size each measure different things. One ready SQL query lists every table with data, index, and total size, sorted by the biggest disk consumers first.
What is Frugal architecture?
Frugal Architecture is Werner Vogels' framework for cost-conscious system design: three pillars (Design, Measure, Optimize) and seven laws, from treating cost as a non-functional requirement to continuous optimization, explained with practical examples.
The Truth About Password Security: Beyond Special Characters
Password security depends on entropy, not special characters. The math behind entropy = N * log2(R), why length beats complexity rules, why database breaches (not login guessing) are the real threat, and implementation tips for saner password policies.
How to listen to Rails events
ActiveSupport::Notifications lets you listen to Rails events like transaction.active_record without extra gems. How the instrumentation API works, subscribing to built-in Rails events, and publishing your own custom events for better observability.
Adding colors to your Ruby scripts and console logs: A Developer's guide
Colored terminal output in Ruby takes a few lines: extend String with ANSI escape methods like red, green, and bold, add colorized logging to the Rails logger, or reach for a gem when you need more. Copy-paste snippets for scripts and console logs.
How to communicate effectively: beyond words
Effective communication in tech teams starts with context: "the payment module shows timeout errors" beats "it's broken". Communication styles, framing, active listening techniques, common pitfalls, and how clear messages build trust with your team.
How to upgrade PostgreSQL from 16 to 17 in Docker
Upgrading PostgreSQL from 16 to 17 in Docker without losing data: run both versions side by side in docker-compose, back up with pg_dump, restore into the new container, then switch the app over. Five concrete steps plus the gotchas to watch out for.
How to deploy NextJS app using Docker with Bun
Deploy a NextJS app with Docker and Bun using a three-stage Dockerfile: install dependencies with a frozen lockfile, build the app, then run the standalone output on oven/bun:alpine. Faster installs than npm and a small production image, step by step.