Skip to content

Instantly share code, notes, and snippets.

View aeciopires's full-sized avatar

Aécio Pires aeciopires

View GitHub Profile
@aeciopires
aeciopires / rethinkdb.py
Created April 7, 2018 12:24 — forked from Faheetah/rethinkdb.py
Ansible RethinkDB dynamic inventory module
#!/usr/bin/env python
import json
import rethinkdb as r
from os import environ as env
HOST = env.get('RETHINK_HOST', '127.0.0.1')
PORT = env.get('RETHINK_PORT', 28015)
DB = env.get('RETHINK_DB', 'inventory')
GROUP = env.get('RETHINK_GROUP', 'dev')
@aeciopires
aeciopires / Jenkinsfile.groovy
Created April 7, 2018 12:26 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'No quotes in single backticks'
sh 'echo $BUILD_NUMBER'
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"'
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"'
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"'
echo 'Using three backslashes still results in preserving the single quotes'
@aeciopires
aeciopires / Dockerfile
Created April 7, 2018 12:27 — forked from Faheetah/Dockerfile
Docker patterns/anti-patterns
### Generic Dockerfile demonstrating good practices
### Imports
# Bad-ish, we do not need Ubuntu for this, nor do we want latest if we are using in a build system, predictable is better
FROM ubuntu:latest
# Better, using a small image since our app has no dependency on Ubuntu
FROM alpine:3.3
@aeciopires
aeciopires / module.sh
Created April 7, 2018 12:27 — forked from Faheetah/module.sh
Ansible bash module boilerplate
#!/bin/bash
# Source arguments from Ansible
# These are passed into the module as $1 with a key=value format
# Sourcing this file sets the variables defined in the Ansible module
# Note that variables that are unused in the module are silently ignored
source $1
# Helper function to fail the module with the specified error
# This can accept $@ in printf for the full error
@aeciopires
aeciopires / grafana-dashboard-exporter
Created November 20, 2018 21:40 — forked from crisidev/grafana-dashboard-exporter
Command to export all grafana 2 dashboard to JSON using curl
KEY=XXXXXXXXXXXX
HOST="https://metrics.crisidev.org"
mkdir -p dashboards && for dash in $(curl -k -H "Authorization: Bearer $KEY" $HOST/api/search\?query\=\& |tr ']' '\n' |cut -d "," -f 5 |grep slug |cut -d\" -f 4); do
curl -k -H "Authorization: Bearer $KEY" $HOST/api/dashboards/db/$dash > dashboards/$dash.json
done
@aeciopires
aeciopires / updateGit.sh
Last active January 21, 2022 10:41
Shell Script for update git repositories local
#!/bin/bash
#------------------------
# Authors: Aecio Pires
# Date: 13 jan 2020
#
# Objective: Update git repositories local
#
#--------------------- REQUISITES --------------------#
# 1) Install packages: git
git remote add <other-fork-alias> <other-fork-URL>
git checkout <branch>
git fetch <other-fork-alias>
git cherry-pick <commit-hash>
git push <your-fork-alias>
git remote remove <other-fork-alias>
git remote -v
@aeciopires
aeciopires / .bash_prompt
Last active February 10, 2024 11:25 — forked from jason-kane/.bash_prompt
Bash prompt with git branch and k8s context/namespace
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
#
# USAGE: