Skip to content

Instantly share code, notes, and snippets.

View dinhoabreu's full-sized avatar

Edison E. Abreu dinhoabreu

View GitHub Profile
@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 / 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