There are lots of ways to sort data. Insertion sort is particularly interesting because it sorts the data in place and is pretty easy to understand. Of course, most of us just use the #sort method. But interviewers still love to ask questions about sorting algorithms and related topics like Big-O notation. In this post, you'll learn not only how insertion sort works but also how to implement it yourself in ruby.
If you've ever checked the environment in your Rails app with Rails.env.production? you've used a fascinating little utility class called StringInquirer. In this post, Jonathan Miles dives into the rails codebase to show us exactly how StringInquirer works and how we can bring a little of its magic to our own apps.
Before you can decide on a front-end for your Rails app, you need a feel for the options. Does a particular JS framework speak to you or does it make you feel dirty inside? There's only one way to find out! In this article, Julio Sampaio walks us through creating an Angular app from scratch and integrating it with a Rails back-end via webpacker.
The fastest web page is one you've already loaded. Browsers love to avoid round-trips by caching assets. And HTTP provides ways for us to tell browsers what's changed and what hasn't - so they make the right decisions. In this article, Jonathan Miles introduces us to HTTP caching and shows us how to implement it in Rails.
A fast app means happy users. The speed that your pages render depends on which templating system you use. In this article, Diogo Souza puts the three most popular Ruby templating engines to the test to see which is fastest. In the process, he shows us how to construct benchmarks and do our own investigations into performance.
As developers, we spend way more time maintaining and changing code than we do writing it. By optimizing for change through SOLID design principles, we can avoid a lot of pain. In this article, Milap Neupane introduces us to SOLID, explains each principle in-depth, and shows us how to apply them in Ruby.
Logging is tricky. You want logs to include enough detail to be useful, but not so much that you're drowning in noise - or violating regulations like GDPR. In this article, Diogo Souza introduces us to Ruby's logging system and the LogRage gem. He shows us how to create custom logs, output the logs in formats like JSON, and reduce the verbosity of default Rails logs.
What makes Rails magical? It just might be its code loader. Put a few files in the right places, and - presto! - you have a web app. When you use a class, Rails handles the include so you can stay focused on your code. But this magic isn't just for Rails! You can add thread-safe code loading to your own apps via the Zeitwerk gem. In this article, Olasubomi introduces us to Zeitwerk and shows us how to integrate it with our own projects.
We don't get to choose our families. Some of us don't even get to choose our databases. What do you do if you have the bad luck to inherit a database with non-unique ids? In this case study, Regan Ryan shows us how his team faced the challenge.
ActiveRecord makes accessing your database easy, but it can also help make it faster by its intelligent use of caching. In this article, Jonathan Miles shows us the tricks that Rails uses to ensure that your database isn't doing more work than it needs to.
For quick, scalable, highly-available web services, few options compare to AWS Lambda. Just provide your code, add a little configuration, and you're done! In this article, Milap Neupane will introduce us to Lambda, show us how to get it working with Ruby and the Serverless Framework, and discuss reasons to use — or to not use! — Lambda in production.
Every Rails app has a breaking point; a level of activity that it simply cannot handle. Your braking point depends on big architectural decisions, yes — and also on the tiniest changes committed by your most junior developer. That's why it's vital to regularly test your application's performance under load. In this article, Milap Neupane gives us a Rails-centric introduction to load testing with a powerful open-source tool called JMeter.
Many of the concepts you're already familiar with as a web developer are applicable in Go. In this article, Ayooluwa Isaiah shows us how middleware, templating, and other aspects of the go language work together to create a coherent web-development experience.
You'll probably never implement sorting from scratch. But sorting algorithms are foundational in computer science and have become a standard feature of the ritual hazing...er...interview process for developers at all levels. In this article, Julie Kent introduces us to the merge sort algorithm. She'll show us how it works, implement it in ruby, and discuss its performance characteristics.
Understanding parsers is like seeing the matrix. You start to understand the tree-like structure of your code. You begin to realize that so many language features are just syntactic sugar concealing a simple core. In this article, Alex Braha Stoll will guide us through the world of parsers. He'll explain basic concepts, then use Ruby to implement a simple parser for his toy language, Stoffle.
If you've ever built a UI in Rails, you've probably noticed that views tend to get slower over time. That's because adding features to a UI often means adding DB queries to the view. They add up. Fortunately, Rails provides us with an easy-to-apply band-aid in the form of view caching. In this article, Jonathan Miles introduces us to view caching, discusses when it's appropriate to use, and covers common pitfalls to watch out for.
When you inherit a legacy app with no tests, your first step should be to add them. But that can be a huge task! How do you even start? In this article, José will introduce us to a testing workflow called test-commit-revert (TCR) that is particularly useful for adding tests to legacy systems. He'll show us practical examples and help us set up our tooling for minimal friction.
You're doing some currency calculations in your app. It seems to be working well. But after a while, strange discrepancies emerge. The books stop balancing. People get mad. All because the code treated currency like any other number. In this article, Julio Sampaio shows us which of Ruby's number classes are unsuitable for currency, and walks us through better options.
If I asked you to sit down right now and sort a list of numbers, there's a good chance that you'd intuitively rediscover the selection sort algorithm. It's a simple approach that can have significant performance implications. That's why it shows up so frequently in technical interviews - even though most developers never implement sorting from scratch. In this article, Julie Kent walks us through the selection sort algorithm, builds a working implementation in Ruby, and discusses its performance characteristics.
Whoever first said that "the fastest code is no code" must have really liked memoization. After all, memoization speeds up your application by running less code. In this article, Jonathan Miles introduces us to memoization. We'll learn when to use it, how to implement it in Ruby, and how to avoid common pitfalls. Buckle up!