My Blog

Passing on knowledge about software development and related technologies.

Counting Records With ActiveRecord

While counting records with ActiveRecord seems straightforward, you can quickly experience performance problems if not done properly. In the context of Rails ActiveRecord, the methods for counting records each do it a bit differently. Let's take a look at the three methods available in Rails:

  1. count - When called on an ActiveRecord::Relation object, count will perform a SQL COUNT query, which is very fast, especially on large result sets.

  2. size - Like count, size works differently depending on whether you call it on an ... Continue reading

Statistics In Ruby

With users demanding more sophisticated dashboards and reports in this ocean of Data Science and Artificial Intelligence I thought it would be prudent to review how to calculate some basic statistical functionality in Ruby. First, let me point out all the code shown below should work with Ruby 2.7 and above. All the examples are in IRB. I am not here to write your code, but I do want to show you how to do the math in Ruby. Let's get started!

Calculating the Average (Mean)
Unfortunately, Ruby does not provide a native method to generate an average (mean) v... Continue reading

Ruby 3.0 - Promises Delivered

After five years of hard work by the core language team, Ruby 3.0 was released on Christmas 2020 with better performance and other features for this high-level general-purpose programming language.

Why am I writing a review six months later? I wanted to get plenty of "hands-on" time with the new version before commenting on it. Let's get going...

Ruby 3.0 was developed with a focus on better performance, concurrency, and typing and achieved its goal of being 3x faster than the performance of Ruby 2.0. That 3x speed-up is when making use of the new Ruby 3.0 J... Continue reading

A Password Site That Respects Your Privacy

I like most of you, are constantly having to create new passwords for sites and applications we use daily. Unfortunately, most of the password generator sites cover you with ads or try to collect info on you to sell. Because of this, I decided to write my own and make it respect everyone's privacy.

I used Rails 6 / Ruby 2.7 / JQuery deployed on Heroku to craft this tool. It has simple use analytics (if you create a simple account) and does not collect identifying info on visitors as I use GoatCounter for my analytics on the site. Check it out and feel free to use this tool I ... Continue reading

Debugging Tips with Chrome Dev Tools

The Google Chrome web browser is the most popular web browser used by web developers today. With the Chrome browser having a six-week release cycle and a powerful set of developer features, Google has turned the browser into a tool all web developers can use. Most reading this may be familiar with many of its well-known features like live-editing the CSS of a page, using the console to check for errors and such, and debugging Javascript for example. In this post, I will share with you some cool tips and tricks that are not so well known and will improve your debugging even more. These ar... Continue reading

Displaying blogs 1 - 5 of 23 in total