Skip to content

Instantly share code, notes, and snippets.

View rogerluan's full-sized avatar
🚀

Roger Oba rogerluan

🚀
View GitHub Profile
@rogerluan
rogerluan / commit-message-guidelines.md
Created December 3, 2021 10:06
Commit Message Guidelines

Commit Message Guidelines

These guidelines are based off of this guide. Some of the key takeaways, plus some other opinionated guidelines:

  1. Clarity is key: a commit should be clear even to a viewer who doesn’t have the full context in which it was made.
  2. Start your commit message with a verb, and use sentence case capitalization.
  3. Use the imperative verb when writing a commit message (see the link above if you don’t know what that means). Example: "Fixed" → "Fix"
  4. Commit things that make sense to be grouped in a single commit. Ask yourself "does it make sense for someone to cherry pick this single commit? Is there something missing in it, or something extra that the person wouldn't need?" - if you do that, you'll end up aiming for 1 commit per fix or feature, which makes the codebase cleaner.
  5. Test what you are fixing before committing. Only commit what you’ve tested and are sure that is good to go. This avoids unnecessary comm
@rogerluan
rogerluan / calculate_cpf_digits.rb
Last active December 27, 2022 20:18
Calculates the digits of a CPF, given the first 9 digits of it.
# Usage: `ruby calculate_cpf_digits.rb "123456789"`
cpf = ARGV[0]
cpf_array = cpf.split("").map(&:to_i)
def calculate_digit(base_array:)
# Constants
divisor = 11 # Constant, fixed number
weighted_array = [10, 9, 8, 7, 6, 5, 4, 3, 2] # Digits, starts with 10 and decrements by 1
# Algorithm