Writing a Shell in 25 Lines of Ruby Code

If you use Linux or Mac, every time you open a terminal you are using a shell application. A shell is an interface that helps you execute commands in your system. The shell hosts environment variables & has useful features like a command history and auto-completion. If you are the kind of person that likes … Read more

Ruby Ranges: How Do They Work?

What is a Range in Ruby & how does it work? A range is an object which has a starting value & ending value, they help you create sequences that span the whole range between these two values. You could go from 1 to 20, or from “a” to “z”. In this article you’ll discover: … Read more

5 Useful Examples From The Ruby Standard Library

The Ruby Standard Library is a series of modules & classes that come with Ruby but are not part of the language itself. These classes offer a variety of utilities like: Base64 encoding Prime number generation DNS resolution In this article I’m going to show you 5 of these classes with useful examples. Ruby Logger … Read more

How to Generate Weighted Random Numbers

Random numbers usually follow what we call a ‘uniform distribution’, meaning that there is the same chance that any of the numbers is picked. But if you want some numbers to be picked more often than others you will need a different strategy: a weighted random number generator. Some practical applications include: the loot table … Read more