Skip to content

Instantly share code, notes, and snippets.

View marcelomgarcia's full-sized avatar

Marcelo Garcia marcelomgarcia

  • Jeddah, Saudi Arabia
View GitHub Profile
@marcelomgarcia
marcelomgarcia / splitvals.sh
Created July 4, 2019 13:03
Split variables in format "WWxHH" "WW" and "HH" (width and height) in Bash.
#!/usr/bin/env bash
# Split the values passed as wwwXhhh in width and height
#
function wh_vals {
# Convert upper 'X' to lower 'x' so the 'cut' command works.
size="$(tr '[:upper:]' '[:lower:]' <<<"$1")"
width="$(cut -d'x' -f1 <<<"$size")"
height="$(cut -d'x' -f2 <<<"$size")"
@marcelomgarcia
marcelomgarcia / str2arr.sh
Created July 4, 2019 14:23
bash split a string "a, b, c" into an array arr[a, b, c]
#!/usr/bin/env bash
# Split a string passed as parameter into array elements.
# "a, b, c" -> arr[a,b,c]
# https://stackoverflow.com/questions/10586153/split-string-into-an-array-in-bash
function splity {
IFS=', ' read -r -a array <<< "$1"
}
# Before splitting the string:
@marcelomgarcia
marcelomgarcia / mg_tmux_conf.md
Last active December 26, 2021 17:50
tmux configuration and more
@marcelomgarcia
marcelomgarcia / mysql.md
Last active May 30, 2022 08:50
MySQL tips

MySQL Daily Admin

Basic MySQL administration, and useful commands.

Location of the Database

Locating the directory with the database files

root@lthlibpub:/etc/mysql# mysqladmin -u root -p variables | grep datadir
@marcelomgarcia
marcelomgarcia / powershell_venv.md
Created June 5, 2021 14:56
Starting virtual environment in Powershell

Using Virtual Environment in Powershell

Create the virtual environment

PS C:\Users\mgarcia\Documents\Work\ml> python -m venv venv

Starting the environment

@marcelomgarcia
marcelomgarcia / Git_cookbook.md
Last active January 18, 2023 10:45
Using Git

Git Cookbook

Using Git for every work.

Branch

Creating a branch

mgarcia@wsl2:~/Documents/Work/orcid-integration$ git checkout -b dockerfile_no_ssh_key
@marcelomgarcia
marcelomgarcia / read_user_passwords.md
Last active October 23, 2023 12:48
Using Ansible vault to read passwords in a dictionary

Read Passwords from Ansible Vault

Declaring username and password in a vault and reading the dictionary into a playbook.

The files mysql_vault and mysql_users were renamed to library_vault_key and library_vault to include other secrets than MySQL only.

The Vault

The dictionary, mysql_users has the database name as key, and the values are the username and the password. The password for the vault is in the file mysql_vault, which is a simple text file like this

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcelomgarcia
marcelomgarcia / movie_club_suggestions.md
Last active November 19, 2023 14:17
Suggestions for the movie club
@marcelomgarcia
marcelomgarcia / Windows.md
Last active April 3, 2024 10:47
Configuration after a fresh install of Ubuntu