Skip to content

Instantly share code, notes, and snippets.

@letiesperon
letiesperon / git_blame_deleted_lines.md
Created November 16, 2022 14:58
Git blame who deleted a line

If you want to find out the commits that changed a line with a given string:

git log -S string ./file

Eg. One word: git log -S deleted_method_name ./app/models/accounts/account.rb Multiple words: git log -S "def deleted_method_name" ./app/models/accounts/account.rb

Use -G for regex pattern matching

@letiesperon
letiesperon / SQL_tables_size.sql
Created February 22, 2022 17:59
SQL query to get the size of all the tables in a database
SELECT
table_name,
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))),
pg_total_relation_size(quote_ident(table_name)) as "Raw size"
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY 3 DESC;
@letiesperon
letiesperon / chromedriver.md
Created February 7, 2022 21:45
Fixing chromedriver

Whenever selenium tests are not working anymore do this:

brew reinstall chromedriver

If I then get a:

"chromedriver” cannot be opened because the developer cannot be verified. Unable to launch the chrome browser

then, find chromedriver binary path:

@letiesperon
letiesperon / open-gem-source-code.md
Created December 3, 2021 20:50
How to open a Ruby gem sourcecode locally

Open gem source code locally in Editor

Example with gem devise and Sublime editor (with alias subl)

bundle show devise | xargs subl
@letiesperon
letiesperon / SUBLIME.json
Last active October 17, 2021 15:26
Sublime preferences
{
"font_size": 17,
"margin": 2,
"translate_tabs_to_spaces": true,
"tab_size": 2,
"trim_automatic_white_space": true,
"open_files_in_new_window": "never",
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": "all",
}
@letiesperon
letiesperon / AWS-VAULT.md
Created July 6, 2021 13:04
Aws-vault keychain management

How to visualize aws-vault keychain in Keychain Access

If aws-vault does not show on the left side menu of Keychain Access you can add it by typing:

open ~/Library/Keychains/aws-vault.keychain-db

How to change aws-vault keychain password:

Type:

@letiesperon
letiesperon / GIT-CONFIG.md
Created June 29, 2021 14:55
My git local config to setup a new computer fast

My local git configs

Configure git author

  • Setup your commit authors name and email:
git config --global user.name "Your Name"
git config --global user.email your@email.com
@letiesperon
letiesperon / GIT-GITHUB-KEYS.md
Last active July 4, 2021 21:48
Configure git and github

How to link git to your github account in a new Mac OS

  • Generate new ssh key for your github email:
ssh-keygen -t rsa -b 4096 -C "your@email.com" 
// Intro to accept default directory, set an optional passphrase

eval "$(ssh-agent -s)"
@letiesperon
letiesperon / SETUP.md
Last active March 3, 2023 16:06
Instructions new Macbook computer setup Part I
  • Format MacOs to have latest OS
  • Install Xcode:
    xcode-select --install
  • Install Homebrew and cask:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      

brew install cask

@letiesperon
letiesperon / Rails credentials
Last active January 18, 2024 21:08
What I need to know about Rails 6 credentials and master key
The credentials are stored in the "credentials.yml.enc" file, encrypted.
To decrypt the credentials file, you need a master key that is set on either:
* config/master.key file (for local development)
* ENV["RAILS_MASTER_KEY"] (for deployed environments)
What should you commit?
* The file config/master.key should be ignored in gitignore (you should not commit the master key)
* The file credentials.yml.enc should be commited along with the codebase (but don't worry, only those who have the master key can decrypt it)