This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_months_to_years(months) | |
years = months / 12 | |
remaining_months = months % 12 | |
[years, remaining_months] | |
end | |
def get_friendly_years_and_month(months_count) | |
years, months = convert_months_to_years(months_count) | |
friendly_years = "#{years > 1 ? "#{years} anni" : '1 anno'} e #{months > 1 ? "#{months} mesi" : '1 mese'}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove a file from repository (example .DS_Store) | |
# Remember to add **/filename.extension to your .gitignore! | |
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch | |
# merge a branch in your current one | |
git pull origin <remote_branch_name> | |
# get total lines of code of a repo | |
git ls-files | xargs -I {} find {} -type f | xargs wc -l | grep ' total' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_with_levels(number_of_levels) | |
Hash.new { |i, parent| | |
i[parent] = number_of_levels == 1 ? {} : hash_with_levels(number_of_levels - 1) | |
}.compare_by_identity | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Permission of file or folder | |
ls -l | |
#Example output: drwxr-xr-x 2 root root 4096 Jan 19 08:45 database_backups/ | |
#1. Type: - for file and d for directories | |
#2. Permissions: rwxr is for root user | xr is for root group users | x is for others | |
#3. User Owner: root | |
#4. Group Owner: root | |
#Docs: https://www.redhat.com/sysadmin/linux-file-permissions-explained | |
# Find things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Generate the private and the public keys | |
#Docs: https://www.ssh.com/academy/ssh/keygen#command-and-option-summary | |
ssh-keygen -t ed25519 -C "Comment" | |
#Now the private key must be used connecting to the server | |
ssh-i /path/of/private/key <user>@<hostip-host-url> | |
#You must copy the public key (.pub) in the server, specifically in .ssh/autorized_keys | |
#Or you can add your custom ssh key with: ssh-add github_ssh_key (private key) |