Hiding .gemrc credentials in dotfiles
I recently came across this problem with the
~/.gemrc file used by the
gem command since I needed to store a
a private token for accessing a GemFury gem source. I struggled to figure
out a way to keep the file in my dotfiles without exposing myself to the possibility that I would publish them. Finally,
at the end of my rope I reached out to my colleagues with this problem and within minutes
Adam Strickland responded with a great approach that was not-obvious but ends up
being a great way to provide configuration outside of the committed
~/.gemrc file. A true hidden gem.
–do you see what I did there?
Memoizing in Ruby
Memoization is the pattern of calculating a value once, and re-using that value each subsequent time it is needed.
It’s common to encounter this in Ruby in the form
@variable ||= calculation. It’s so common that it
is often used even where it’s not expensive or re-used; it’s become a part of idiomatic Ruby. In my
last post I made an off-hand reference to solving the problem
of using memoization for falsy values, and it seems a topic worth talking about in and of itself.