Home » Archives for Jesus Castello

Author Archives: Jesus Castello

Jesus is a Ruby developer who likes to help other developers improve their Ruby skills & fill-in the gaps in their education.

Using Genetic Algorithms in Ruby

Did you know that there’s a way to use the power of natural selection to solve programming challenges? With genetic algorithms (GA), you can solve optimization problems using the same concepts that you find in nature: Reproduction Survival of the fittest Adaptation to the environment So what’s an optimization problem? It’s when you want to find not just a valid ...

Read More »

Tracking Object Allocation in Ruby

Whenever you do something like MyClass.new, Ruby creates a new object, which uses a little bit of memory. But that’s not the only way you are creating objects. Many actions will create objects, including strings and arrays. Even if you don’t say String.new or Array.new, it’s still a new object that is being created for you. Because memory is not ...

Read More »

An Overview of Caching Methods

Caching is a way to store and reuse the same data multiple times. By data, I mean anything like images, CSS files, JSON, etc. Caching will help you serve more requests per second and save on precious resources like network bandwidth and CPU load. What are some of the benefits and challenges that come with caching? What are the most ...

Read More »

Parsing Binary Data Formats

This story started with me wanting to write a steganography tool. Steganography is the process of hiding information inside a file, typically an image. To do that, I had to write an image decoder first because you can’t just start changing random bytes. All that will do is make the image invalid or corrupt. I selected PNG as the image ...

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 »