Home » Ruby » Page 8

Ruby

Writing a microservice in Ruby

Everybody is talking about microservices, but I haven’t seen a lot of good, comprehensive descriptions of how to actually write a microservice in Ruby. This may be because a significant number of Ruby developers are still most comfortable with Rails (which is not a bad thing in and of itself, but it’s not all Ruby is capable of). So I ...

Read More »

Solving Backwards Compatibility in Ruby with a Proxy Object

In a previous article, I documented the upcoming public API changes slated for Sucker Punch v2. Because of a poor initial design, these API changes are backwards incompatible. When I published the previous article, Mike Perham rightly pointed out the opportunity to support the previous versions’s API through an opt-in module. I was hesitant to include support for the old ...

Read More »

Visualizing Algorithms Before Implementation

In mathematics, problem-solving flows through a series of steps, otherwise known as a formula or algorithm. It’s helpful to visualize algorithms before trying to implement them — it’s a safer and more efficient design route than simply trying to plan a process in your head. An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining ...

Read More »

The Straight Dope on Deprecations

The road to stability is paved with good deprecations. A deprecation is a warning message that tells a user they’re using some piece of code or interface that will go away soon. In this post, we’ll peel back the seemingly simple veneer of deprecations, and we will learn when and how to use deprecations effectively. There Is No Going Back ...

Read More »

How to Build a Math Evaluation Engine

One of the first things you learn to do with Ruby is to evaluate a mathematical expression in irb. But what’s the magic behind this seemingly trivial operation? Let’s create our own evaluation engine and find out! Note: You could cheat and just use eval, but that would defeat the point of this exercise. Tokenizing Our Input We are given ...

Read More »

Coming to Rust from Ruby

I like to keep an open mind for other languages and what I may learn and how I may be better for it. Yet I’m cautious about the shift toward languages that become suddenly popular. Programming languages are tools designed with particular focus that bring with them both benefits and costs. Not every language is a hammer and not every ...

Read More »

Exploring the Structure of Ruby Gems

When creating Rails apps, especially ones that don’t diverge too far from a typical/standard one, we don’t have to think very often about how to structure our files or what goes where. Models go in the models folder, Controllers in the controllers folder, etc. But what about all of those gems we include in our Gemfile? How are they structured? ...

Read More »

Refactoring Faster Than You Can Spell Phoenix

Plug is a fantastic tool, and Phoenix is built on top of it! In my last blog post, we added a way to create sessions and tokens for authentication. However, we didn’t actually authenticate anything in our API. This time, we’re going to build a Plug that checks for an API token and inserts the current user into our application. ...

Read More »

Counting Distinct Values With HyperLogLog

Counting distinct values is a trivial matter with small datasets, but it gets dramatically harder for streams with millions of distinct points. Absolute counting accuracy can be attained through a set, but then you have the undesirable tradeoff of linear memory growth. What you really want when dealing with enormous datasets is something with predictable storage and performance characteristics. That ...

Read More »