Skip to content

Instantly share code, notes, and snippets.

View rproenca's full-sized avatar

Rodrigo Proença rproenca

  • FWW
  • Brazil
View GitHub Profile
@rproenca
rproenca / clean_branches.sh
Created April 18, 2016 17:36
Delete all git local branches except the ones between double quotes
git branch | grep -v "master\|develop\|release" | xargs git branch -D
@rproenca
rproenca / aliases.md
Created October 13, 2017 18:14
Git alias - A list of useful git aliases

Based on: https://gist.github.com/mwhite/6887990

[alias]
    # one-line log
    l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short

    a = add
 ap = add -p
@rproenca
rproenca / sequential_parallel_promises.js
Last active June 27, 2019 14:40
Javascript sequential vs parallel promise execution
const fetch = require('node-fetch')
async function fetchDogsImagesSequential(dogs) {
const images = []
for (const dog of dogs) {
const response = await fetch(`https://dog.ceo/api/breed/${dog}/images/random/3`)
const data = await response.json()
images.push({
const fetch = require('node-fetch')
const pipe = require('p-pipe')
const { table } = require('table')
async function fetchDogs(dogs) {
const promises = dogs.map(async function (dog) {
const response = await fetch(`https://dog.ceo/api/breed/${dog}/images/random/1`)
const data = await response.json()
return {
[dog]: data.message
@rproenca
rproenca / gen_cidr_list.sh
Created October 13, 2020 20:01
A bash script that generates a list of CIDRs given a Azure IP Ranges JSON file
#!/bin/bash
# Generates a list of CIDRs given an Azure IP Ranges JSON file
# https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519
INPUT_FILENAME=$1; # Name of the JSON file downloaded from MS website (ServiceTags_Public_YYYYMMDD.json)
OUTPUT_FILENAME=cidr_list.txt
if [ -z $INPUT_FILENAME ]
then
@rproenca
rproenca / update_vault.sh
Last active October 13, 2020 20:12
A bash script that updates Azure Vault network ACLs given list of CIDRs addresses
#!/bin/bash
# This script updates Azure Vault network ACLs given list of IP Addresses in CIDR format
VAULT_NAME=$1; # Vault name
INPUT_FILENAME=cidr_list.txt
if [ -z $VAULT_NAME ]
then
printf "Incorrect usage. Please use: ./update.sh [vault_name]\n";
@rproenca
rproenca / gist:bfa316618823ff01c39a5643f90637a7
Created November 6, 2020 17:09
Transform an arbitrary JSON array into CSV
cat input.json | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > output.csv
### Keybase proof
I hereby claim:
* I am rproenca on github.
* I am proenr (https://keybase.io/proenr) on keybase.
* I have a public key ASDlJxkD5QtJUszTbPVNFaCwDhaqM4_uqUo6VJNpJAkSPAo
To claim this, I am signing this object:
@rproenca
rproenca / smartsheet_column_mapper.js
Last active March 24, 2021 17:35
An ad hoc solution for mapping smartsheet columns ids to columns titles and vice-versa given an arbitraty object as input
/*
Usage
-----
$ npm init
$ npm install axios
Replace variables "token", "smartsheetId" and "payload"
$ node smartsheet_column_mapper.js
@rproenca
rproenca / gen_random_string.js
Created November 10, 2020 12:22
Generate a random string (letters and numbers) of a given length
const getRandomString = length => {
let s = '';
do {
s += Math.random()
.toString(36)
.substring(2);
} while (s.length < length);
s = s.substr(0, length);