Welcome to another edition of This Week in #dev, a series of posts where we bring some of the most interesting Slack conversations to the public.
Matheus Richard recommended using DeMorgan Laws to simplify boolean operations or spot wrong refactoring. He also shared a RailsConf talk by Joël Quenneville about this very topic: The Math Every Programmer Needs.
Steve Polito shared that Mozilla maintains a guide on web security which provides information on how to protect websites from security threats. It covers topics such as authentication, encryption, and secure coding. The guide has a web security cheat sheet that is particularly useful!
Summer shared a client’s tip to use glob expansion on rake tasks. Here’s an example:
# This is the same as:
rake db:drop db:create db:migrate db:test:prepare
Neil Carvalho suggests using the
accessed_fields method to help optimize
heavy queries on Rails when using
select. This method returns all the database
fields that were read by an ActiveRecord model instance.
Jeanine Soterwood advised a client to use git’s
--force when pushing to a git branch, as it will not allow you to force
push if another developer has added other commits to the branch in the meantime.
She also mentioned that she uses
--force-with-lease even when working on a feature branch by herself to make it a habit and avoid accidentally force-pushing over someone else’s work when working together on a feature branch.