In this post we'll use a little-known command line flag to spy on Ruby as it parses our code.
Did you know that it's possible to log all method calls as they occur in a running process in real time? How about injecting code to be executed inside of a running process? You can – via the magic of the rbtrace gem.
In this post we'll discuss some non-obvious behavior of class variables and show how it's all the fault of lexical scoping.
Have you ever needed to group items in an array, or lines in a file? In this post we'll discuss a few often-overlooked Enumerable methods that let you do just that.
The humble splat operator (
*) is one of those features of Ruby that just gets more interesting the more you look at it. In this post we'll talk about how you can construct and manipulate arrays with splats.
In this post we'll follow the journey of a simple program as it's lexed, parsed and compiled into bytecode. We'll use the tools that Ruby gives us to spy on the interpreter every step of the way.
A lot of problems faced by beginning Rubyists are caused by not understanding
self. In this post we'll take a deep dive into
self under conditions both common and uncommon.
Ruby supports using regex in lots of interesting ways that go beyond the basic
String#match method. In this post I cover a few of my favorites.
In this post, we'll dive into regex conditionals and discuss how to work around the limitations in Ruby's implementation of them
Are refinements slow? I wrote a few benchmarks to find out. The answer was surprising.
If you've never used Ruby's refinements, you might be surprised to learn that they're lexically scoped. We'll discuss what this means, and the implications for your code.
In this post, we'll discuss how to separate an HTML document into logical sections based on heading tags. I'll all also show you a cool trick for rendering arbitrarily-deep subnavigation trees using Liquid templates.
Longer pages often benefit from subnavigation. In this post, we'll make a Jekyll plugin to dynamically generate subnavigation from H2 tags.
You tried turbolinks, once, and soon your app began to fail in strange and wonderful ways. But some people make it work. What's their secret? The answer is so simple, it just might amaze you.
When you treat your collections as enumerators, you get to use all your favorite functions like #map and #reduce without having to write any extra code. In this post I show you how easy it is to create enumerators on the fly, without defining extra classes or messing around with the Enumerable module.
These days it's pretty common to see #freeze used in Ruby code. But it's often not entirely clear WHY freeze is being used. In this post we'll look at the most common reasons a developer might freeze variables.
If you want your app to behave well in a unix environment, it's important that it exit correctly. In this post you'll learn all about unix exit codes, the mechanism that Ruby uses to exit a program, and how you can add custom behavior on exit.
But buried within Ruby's nesting implementation - and Rails' autoload system - are a few traps that can cause your code to fail in strange and wonderful ways. In this post, we'll discuss the origin of these traps and how you can avoid them.
It's often useful to be able to get the most recent exception, even if your code doesn't control the lifecycle of that exception. In this post we explore a few of the ways to do this.