Skip to content

Instantly share code, notes, and snippets.

View themarcelor's full-sized avatar
🎓
crescat scientia, vita excolatur

Marcelo R Costa themarcelor

🎓
crescat scientia, vita excolatur
View GitHub Profile
@themarcelor
themarcelor / list_service_accounts.js
Created December 13, 2019 01:40
test script to list the Service Accounts from a given Google Cloud Platform project
const {google} = require('googleapis');
var iam = google.iam('v1');
authorize(function(authClient) {
var request = {
// Required. The resource name of the project associated with the service
// accounts, such as `projects/my-project-123`.
name: 'projects/my-project-123/serviceAccounts', // TODO: Update placeholder value.
auth: authClient,
@themarcelor
themarcelor / allure-deployment.yaml
Created November 26, 2019 18:13
allure k8s deployment & service descriptors
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: allure-deployment
labels:
app: allure
spec:
selector:
# Only select pods based on the 'app' label
matchLabels:
Feature('This is a just a test');
const readline = require("readline");
const fenceProps = require('../../services/apis/fence/fenceProps.js');
const chai = require('chai');
const {interactive, ifInteractive} = require('../../utils/interactive.js');
const { Gen3Response, getAccessTokenHeader } = require('../../utils/apiUtil');
const expect = chai.expect;
// this should be included in the core lib
@themarcelor
themarcelor / postman-pre-request-script.js
Created November 18, 2019 22:32
Postman Pre-Request Script to constantly obtain a valid ACCESS TOKEN: Assumes a `python3 -m http.server` running against a ~/.gen3 folder that contains the target environment's `credentials.json` (with the API KEY).
function get_api_key_and_then_the_access_token() {
return new Promise(async(resolve) => {
const get_resp = await pm.sendRequest({
url: 'http://localhost:8000/credentials.json'
},
function (err, response) {
//console.log('req_resp: ' + response.json()['api_key']);
resolve(get_access_token(response.json()['api_key'],
pm.environment.get('TARGET_ENVIRONMENT')));
});
@themarcelor
themarcelor / testing_yamlfmt.txt
Created June 11, 2019 21:38
Using yamlfmt to get rid of white spaces
% cat test.yaml | grep -B1 " config_helper" | tr " " "*"
**************mountPath:*"/var/www/sheepdog/config_helper.py"
**************subPath:*config_helper.py**
% yamlfmt test.yaml -w
% cat test.yaml | grep -B1 " config_helper" | tr " " "*"
**********mountPath:*/var/www/sheepdog/config_helper.py
**********subPath:*config_helper.py
array = [[1,2,[3]],4]
def unpack(arr, flatten = []):
for i in arr:
if isinstance(i, list):
unpack(i, flatten)
else:
flatten.append(i)
return flatten
@themarcelor
themarcelor / DetectPrime.scala
Created January 14, 2019 20:55
Scala snippet for study purposes
import scala.util.control.Breaks._
object DetectPrime {
def isPrime(num: Int):Boolean = {
if (num == 1) {
false
} else if (num == 2) {
true
} else {
@themarcelor
themarcelor / nginxpodchecker.go
Created July 4, 2018 00:30 — forked from yifan-gu/nginxpodchecker.go
nginx pod checker
package main
import (
"fmt"
"os"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api"
@themarcelor
themarcelor / docker_cleanup_notes.sh
Created June 30, 2018 10:36
cleaning up old Docker containers
# easy
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# meh
# docker ps -a | tail -n +2 | awk '{print $1}' | xargs -I {} docker rm {}
############ User input for AWS Access key and AWS Secret key
echo "Please provide your S3 Access Key: "
read -s AWSID
echo "Please provide your S3 Secret key:"
read -s AWSSEC
calculate_signature () {
AWSSEC=$1
x_amz_date_short=$2