Skip to content

Instantly share code, notes, and snippets.

View alexwebgr's full-sized avatar
😎

Alexandros alexwebgr

😎
View GitHub Profile
PARENS = {
"(" => ")",
"{" => "}",
"[" => "]"
}
OPENING_PARENS = PARENS.keys
CLOSING_PARENS = PARENS.values
def valid_parentheses(string)
stack = []
string.each_char do |ch|
@alexwebgr
alexwebgr / shell.sh
Last active June 3, 2025 09:58
Install MySQL on ubuntu 20.04 and set the root password
# Completely remove any previous config
sudo apt remove --purge mysql*
sudo apt autoremove
sudo find / -iname mysql
# install the server
sudo apt update
sudo apt install mysql-server
# run the wizard
sudo mysql_secure_installation
@alexwebgr
alexwebgr / counter
Last active November 12, 2020 14:36
str = "aabbbaa"
count = Hash.new(0)
str.each_char { |c| count[c] += 1 }
puts count
@alexwebgr
alexwebgr / creds.rb
Last active August 9, 2021 11:44
How to generate, manage and use env-specific encrypted credentials in rails 5.2
# generate and edit env-specific encrypted credentials
EDITOR=nano bin/rails encrypted:edit config/development.yml.enc --key config/development.key
# override credentials in application.rb
def credentials
encrypted(
"config/#{Rails.env.downcase}.yml.enc",
key_path: "config/#{Rails.env.downcase}.key"
)
end