git
git
ruby
Understanding anonymous functions: Blocks, Procs, and Lambdas in Ruby
Blocks, procs, and lambdas in Ruby all wrap code you can pass around, but they differ in how they check arguments and handle return. Implicit and explicit blocks with yield, building reusable procs, and when a lambda is the safer pick, all shown with runnable examples.
ruby
Powerful switch statement with pattern matching in Ruby
Pattern matching in Ruby turns case statements into a precise switch over data shapes: match and destructure hashes from an API response, combine several patterns in one branch, capture values across patterns, and validate configuration. Ruby 2.7+ syntax examples.
Latest
Monolith vs microservices vs serverless
Monolith, microservices, or serverless? A side by side comparison of how each backend architecture handles scaling, development speed, deployment, and cost, where each one breaks down in practice, and a summary that helps you pick the right fit for your project.
How to set up XML in Grape API
XML support in Grape API takes two steps: register the additional content_type so endpoints accept and return application/xml, then change the root element name of the XML output. Complete Ruby examples built around a products endpoint you can adapt to your API.
Multiple ways to execute a shell command via Ruby
Running shell commands from Ruby: system, backticks, exec, the IO class, spawn, and Open3.popen3 compared with pros and cons, from quick one-liners to capturing stdout, stderr, and exit status, so you can pick the right method for scripts and production code.
Solutions to paginate data in your databse and which one is the best
Database pagination goes beyond LIMIT and OFFSET: ROW_NUMBER(), the FETCH clause, and keyset pagination each behave differently as tables grow. SQL examples for every approach, why offsets get slow on big datasets, and a verdict on which method scales best.
Database shrading and database partitioning in Rails
Database sharding in Rails step by step: create a separate database per shard, wire them up in database.yml, and query across them. Plus how sharding differs from partitioning, with a native PostgreSQL partitioning example done through Rails migrations.
Sidekiq basic_fetch and super_fetch differences
Sidekiq basic_fetch vs super_fetch: open source Sidekiq fetches jobs with BRPOP and loses them when a process crashes, while Sidekiq Pro's super_fetch uses RPOPLPUSH with private per-process queues to recover orphaned jobs. What that means for queue reliability.
Understanding generic types in Typescript
Generic types in TypeScript let one function, class, or interface work safely with many data types. What generics are, how a type parameter beats hardcoding a concrete entity type in a validation helper, and honest pros and cons before you use them everywhere.
Sample DDD explanation in Ruby with Event-sourcing and Event-driven development
Domain Driven Design in Ruby with a working example: aggregates, entities, value objects, and repositories built around a ProductCatalog, then extended with event-driven design and event sourcing, where projections rebuild state from events instead of a database.
Rails optimistic locking, pessimistic locking and how to solve StaleObjectError
Rails locking strategies for concurrent updates: optimistic locking with a lock_version column that works out of the box, pessimistic locking with lock! and with_lock, and practical ways to rescue and resolve the StaleObjectError that optimistic locking raises.
Rails eager_load, joins and includes - when to use what
Rails eager_load, includes, preload, and joins each fight slow queries differently: LEFT OUTER JOIN versus separate queries, how includes picks its strategy, and when a plain joins is enough. Clear examples showing which loading method to choose for each situation.
Enums with Typescript - why it's bad? Possible solutions
TypeScript enums generate extra JavaScript at compile time and numeric enums are not even type-safe. Why enums can hurt bundle size and correctness, and two safer alternatives: assigning explicit string values or replacing enums with plain objects.
Differences between load, autoload, require, and require_relative in Ruby
Ruby has four ways to load code and each behaves differently: load re-executes a file every time, autoload waits until first use, require loads once from the load path, require_relative resolves from the current file. Examples plus a summary of when to use each.
Ruby in browser via WebAssembly
Ruby 3.2 runs in the browser through WebAssembly: embed Ruby in a script tag with ruby-wasm-wasi or drive the Ruby VM from JavaScript and mix it with HTML. Working examples plus honest limits: no threading or networking, and no extra gems without a custom wasm image.
Solutions for const and enums per class in Ruby
Three ways to define constants and enums per class in Ruby: the ActiveRecord enum macro, a mixed style combining frozen constants with enum, and a dependency-free PORO version. Code for each solution and a comparison to help you pick the right one.
Factory Pattern with auto-detecting classes in Ruby
The Factory Pattern in Ruby, then a step further: using naming conventions and regular expressions so the factory auto-detects which notification class to instantiate. Complete code for both versions, plus when strict class listing is the safer choice.
Map vs WeakMap in practice
Map vs WeakMap in JavaScript comes down to keys and memory: WeakMap only accepts object keys and lets garbage collection reclaim unused entries, while Map holds onto everything. Differences, similarities, and practical guidance on when each one is the right choice.
Ruby SOLID in practice with minimizing nesting rule
SOLID in Ruby with working code for every principle: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion, plus a bonus rule on minimizing nesting and a fair look at the criticisms of SOLID.
Anonymous Arguments Passing Improvements in Ruby 3.2
Ruby 3.2 adds new syntax for anonymous arguments: forward positional and keyword arguments with bare * and ** and unpack them inside the method, no more digging through kwargs hashes. A before-and-after example shows how much cleaner argument passing gets.
How to write Naive Bayes classification algorithm in Ruby
Naive Bayes classification in plain Ruby: how prior and posterior probabilities decide the winning class, then a working spam filter that classifies email titles. Also where the algorithm shines: sentiment analysis, recommendations, and fraud detection.