Welcome to My Blog.

Here, you will find posts, links, and more about code (primarily Ruby), business (bootstrapped SaaS), and a little of everything in between.

I would buy Ratio’s Protein yogurt in buckets if it were available.

#

Aaron Judge is Back

Aaron Judge is Back!!!

Aaron Judge answered baseball's burning offseason question Wednesday, agreeing to a nine-year, $360 million contract to remain with the New York Yankees, sources confirmed to ESPN.

I do not follow baseball much (season starts in late September?), but I am excited to see Judge back.

In today's terms, this feels like it will be a painful contract in the future. However, as media rights continue to increase and average salaries climb, it may not be too bad. Not to mention the fact the Yankees quite literally print money.

#

Tot - this is one of the few apps I use daily on all my devices.

Tot is a simple app. It lets you collect & edit text on your Mac, iPhone, iPad, and Apple Watch.

In this case, the tagline is 100% accurate.

I sometimes wish I could change the number of notes available, but otherwise, it is perfect.

#

A First Look at Hanami

I have not spent any time with Hanami, but I am hoping to change that.

I like Sinatra when your goal is to respond to requests and do not need the full Rails functionality and ecosystem.

Hanami looks like it fits somewhere between the two.

#

Hansel Emmanuel, the one-armed basketball star, has announced through his Instagram he has a new NIL deal with Gatorade. He also said the deal was powered by Z-Axis Sports, a sports agency representing a limited number of clients.

source

If you have never seen Hansel play, do yourself a favor and look him up on YouTube.

#

“It’s never a perfect time. The house could burn down tomorrow. “

Gamble on yourself

#

On Grammarly

Grammarly is the most essential browser extension I use daily and happily pay for the premium edition.

It does the small things you expect, like correct spelling and highlighting missing (or unnecessary) commas. However, my favorite feature is calling out words that are not necessary.

For example, "would" was originally in the sentence, "It does the small things you would expect."

#

Shipping is Never Free

The biggest fallacy in online shipping is free shipping. UPS, FedEx, USPS, DHL, etc., all charge for their services.

When shipping is free, it just means the product is being sold for enough to cover the shipping cost.

Amazon has driven this home the most, but most of us are paying for shipping with Prime membership fees anyway.

#

Optimizing ActiveRecord SQL Memory Usage in Rails

A decent suggestion by Patel Urbanek - Easy to Miss Way to Optimize ActiveRecord SQL Memory Usage in Rails.

Urbanek recommends using select in your ActiveRecord queries to limit the fields returned and thus save memory. While this certainly will work, I find it messy long term.

  1. It is not obvious what data you have access to. Your code appears to have access to the user object, but most of the data is missing.
  2. Similar to #1, other helpers/decorators/etc. that you have in your codebase may have model requirements that are not obvious as well. You pass along this partial object, and you may have some unintended consequences.
  3. If you use any kind of caching, you may accidentally expose this partial object to completely unaware parts of your app

I typically use two approaches:

  1. pluck - As suggested in the article, you may be giving up some of your model niceties. Still, it is usually a worthwhile trade-off if the amount of data returned warrants optimization. It can also help expose some code that should not live directly within your model.
  2. pluck and Struct - when using pluck gets too messy, you can always take the data returned and load it into a struct (or a PORO).
#

Finding Duplicate Charactes in Multiple Arrays with Ruby

We needed to find duplicate characters in multiple arrays for Saturday's Advent of Code.

In the first part of the problem, it was among two arrays, so I did something quick like this:

first_array.select { |char| second_array.include?(char) }

This worked as expected, but in part 2, you needed to perform a similar search across three arrays.

I could have chained a second select or duplicated the line entirely, but I figured there was a more straightforward way...and of course, in Ruby, there is almost always a more straightforward way.

~~I do not have a traditional comp sci background, so my mind rarely jumps to Bitwise operators, but in this case, this is the Bitwise & operator is exactly what we needed.~~

@scott pointed this is not Bitwise when dealing with strings:

It is the unary and operator. On arrays, #& is a method that returns the set union of two arrays. On integers, it is indeed implemented as a bitwise and.

a = "vJrwpWtwJgWrhcsFMMfFFhFp".chars
b = "jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL".chars
c = "PmmdzqPrVvPwwTWBwg".chars

duplicates = a & b & c

Even better, this easily scales across N arrays.

#