Skip to content

Instantly share code, notes, and snippets.

View dinhoabreu's full-sized avatar

Edison E. Abreu dinhoabreu

View GitHub Profile
@dinhoabreu
dinhoabreu / main.sh
Created September 24, 2021 11:49
Bash - Associative Array
#!/usr/bin/env bash
a2l() {
jq '.[] | (.name, .value)' <<-EOF
[
{ "name": "x", "value": "v1 vv1" },
{ "name": "y", "value": "v2 vv2" },
{ "name": "z", "value": "v3 vv3" }
]
EOF
@dinhoabreu
dinhoabreu / macos-contacts-phones-normalize.js
Created April 2, 2021 22:57
macos - contacts - update phone values to international format
function normalizePhoneValues(ab, country, ddd, save) {
ab.people().forEach((person) => {
const name = person.name()
person.phones().forEach((phone) => {
const oldValue = phone.value()
if (!oldValue.startsWith('+')) {
let newValue = oldValue.replace(/\D/g, '')
if (newValue.startsWith('0')) {
newValue = newValue.substr(1)
}
@dinhoabreu
dinhoabreu / jq_tut.sh
Last active May 3, 2019 21:35
jq_tut.sh - Simple jq tutorial by example
#!/usr/bin/env bash
jq_tut() {
local expr=$1 doc=$2
shift 2
echo "--> cat doc.json"
echo "$doc"
echo
echo "--> # $comment"
echo " cat doc.json | jq" "$@" "'$expr'"
@dinhoabreu
dinhoabreu / authorized_keys
Last active July 5, 2019 20:43
My SSH Public keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmxOmnBRCOVa4DU+rmBV3E4BZf7eGLJ06obEXQ7CTdEX128YzJIyADfh4EDQY1eNDsfOZbYEAZVyMbR9UuJoUpUHzm43kJk+dGmr3TrVfhAZlqDI1Pt/Wdl7tZKbcL1RVAQgvGQGsgueDBZRBoAqzE4bPacYZVz/DS/YvEHG4go0kjLpvE5EtIQ9TDU/HkVX93Sw986Gt5LmLZDTcKFpgjLrIIvYw8OHoW37zSz5BPyNdbSKwQ0hEEZ9drC2MQRWhCxsftAoSzhoYS4/Vqg23hr5jgRpvZecciaBlXvgnFXrrpUqc8Gvl5O/Q0zyVeX+CrPDxEm03olMdI68yRMGsJ edison@ironman
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHnBPPscnXvng/tO2SVC5pGFuvFKYcxcWSGJH882zUdMPuf9H6aDTSpWDncjhUWzUixVbiznN4lMrOgTzmmU2XFdZ/bGYR9Czz/uWUSTprc95ddgE7TDKxIzMEptf0ErmJTNKmw/znhLkQvo8tj9mN03hOiL/QARuv25GfAYqPX2JfzVjkfzWxqUS8sw7bYjVgXzEiYe0Mga1QbuB17j1q8tYJf3CkOSXBdbBa0Kir1tRW8+OptIq1c2QTGWnu7ngxkcNwNUwmx2ARqXRR1jNACK+D804bvUbIVygYzF6IuQ0jQoeoyokUKXSLe9hGrrTV2wAnGoi7O6nRvkMNdDc3 edison@amix.com.br
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDfGTolOyjTYtDIsqGSo4dgRQ/TPR6ilfHTyXSSCFeEhHPOUQ8YsBN8kg31YoQvRmUy9GgtDLlNwL3jFaoiI6DW+fORs/bWZemnBs45UvXTOlOLDaM5rQYNHTaCiHkKqlMfiXqpf8of4eDUYPxvje9mzmh8ystYk0AgOF9lijvpW1YB9MQlXA5oyPMVQlh
@dinhoabreu
dinhoabreu / tmux.conf
Created April 11, 2017 15:40 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@dinhoabreu
dinhoabreu / .profile
Created March 21, 2017 03:57 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@dinhoabreu
dinhoabreu / CL_PROTEUS_LNX.sh
Created January 17, 2017 17:10 — forked from wendelhp/CL_PROTEUS_LNX.sh
Bash - Applying Proteus baseline
#!/usr/bin/env bash
#
##################################################################
# Script para aplicar baseline da Proteus #
# 12 Jan 2016 - Wendel Amix - v1.0 #
##################################################################
#
# Historico / Atualizacoes
#
# Data: 17/Jan/2017 - Wendel
@dinhoabreu
dinhoabreu / linux.md
Last active June 20, 2018 21:09
UltraWide display configuration

Linux

Ubuntu 18.04

xrandr --newmode "2560x1080"  159.84  2560 2567 2591 2720  1080 1083 1093 1119 +hsync +vsync
xrandr --addmode HDMI-1 2560x1080
xrandr --output HDMI-1 --mode 2560x1080
@dinhoabreu
dinhoabreu / README.md
Created August 2, 2016 19:05 — forked from awmichel/README.md
Docker Machine OSX Autostart

Docker Machine OSX Autostart

This is a simple launchd config that will start your default docker-machine on startup. You can customize the machine that is started by updating lines 11 and 16 with the correct machine name.

Install

  1. Copy the file com.docker.machine.default.plist below to ~/Library/LaunchAgents/com.docker.machine.default.plist.
  2. Run the following in a terminal: launchctl load ~/Library/LaunchAgents/com.docker.machine.default.plist
  3. Profit!
@dinhoabreu
dinhoabreu / str_pad.sh
Created December 31, 2015 22:44
Bash - Stream line padding
#!/usr/bin/env bash
function str_pad() {
local pad_length="$1" pad_string="$2" pad_type="$3"
local pad length llength offset rlength
pad="$(eval "printf '%0.${#pad_string}s' '${pad_string}'{1..$pad_length}")"
pad="${pad:0:$pad_length}"