Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

View GitHub Profile
#!/bin/env bash
if ! [ -x "$(command -v aws)" ]; then
echo "[couchbase-backup] Error: git is not installed." >&2
exit 1
fi
if ! [ -x "$(command -v curl)" ]; then
echo "[couchbase-backup] Error: curl is not installed." >&2
exit 1
@marcelaraujo
marcelaraujo / goGetPrivate.md
Created October 6, 2023 11:08 — forked from StevenACoffman/goGetPrivate.md
How to `go get` private repos using SSH key auth instead of password auth.

Set GOPRIVATE to match your github organization

Cloning the repo using one of the below techniques should correctly but you may still getting an unrecognized import error.

As it stands for Go v1.13, I found in the doc that we should use the GOPRIVATE variable like so:

GOPRIVATE=github.com/ORGANISATION_OR_USER_NAME go get -u -f github.com/ORGANISATION_OR_USER_NAME/REPO_NAME

The 'go env -w' command (see 'go help env') can be used to set these variables for future go command invocations.

How to go get private repos using SSH key auth instead of password auth.

@marcelaraujo
marcelaraujo / react-track-elements.md
Created September 6, 2021 10:29
React Tracking Elements DOM changes
    import { useState, useEffect, useRef } from "react";
    import "./styles.css";
    
    const weak = new WeakMap();
    
    let i = 0;
    const unique = () => i++;
    
    export default function App() {
@marcelaraujo
marcelaraujo / extract-libraries-jobs.groovy
Created February 24, 2021 17:55
Extract Libraries from job executions
import java.util.regex.Pattern
import java.util.regex.Matcher
import jenkins.branch.BranchSource
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
Pattern p = Pattern.compile("Loading\\slibrary\\s(jenkins-(\\w+)-library(@.*)?)");
Jenkins.instance.getAllItems(WorkflowMultiBranchProject.class).each { it ->
if (it.fullName.contains("Maintenance")) {
return
@marcelaraujo
marcelaraujo / Jenkinsfile
Created February 9, 2021 12:14 — forked from docwhat/Jenkinsfile
Example pipeline usage of the Jenkins Mask Passwords plugin
// Requires https://plugins.jenkins.io/mask-passwords to run
/**
* Runs code with secret environment variables and hides the values.
*
* @param varAndPasswordList - A list of Maps with a 'var' and 'password' key. Example: `[[var: 'TOKEN', password: 'sekret']]`
* @param Closure - The code to run in
* @return {void}
*/
def withSecretEnv(List<Map> varAndPasswordList, Closure closure) {
@marcelaraujo
marcelaraujo / macos-port-forward.sh
Created November 30, 2020 10:22 — forked from gregjhogan/macos-port-forward.sh
local port forwarding on macOS
#!/bin/bash
ifconfig lo0 alias 127.0.1.1
ifconfig lo0 alias 127.0.10.1
# clear rules
pfctl -F all -f /etc/pf.conf
# set rules
echo "
@marcelaraujo
marcelaraujo / macos-port-forward.sh
Created November 30, 2020 10:22 — forked from gregjhogan/macos-port-forward.sh
local port forwarding on macOS
#!/bin/bash
ifconfig lo0 alias 127.0.1.1
ifconfig lo0 alias 127.0.10.1
# clear rules
pfctl -F all -f /etc/pf.conf
# set rules
echo "
@marcelaraujo
marcelaraujo / kill_all.groovy
Last active October 21, 2020 14:30 — forked from steven-terrana/kill_all.groovy
[Kill All Builds] kill all queued and running jobs #Jenkins
import java.util.ArrayList
import hudson.model.*;
// Remove everything which is currently queued
def q = Jenkins.instance.queue
for (queued in Jenkins.instance.queue.items) {
q.cancel(queued.task)
}
// stop all the currently running jobs
@marcelaraujo
marcelaraujo / README.md
Last active October 14, 2023 18:17
Convert P12 to PEM and extract RSA public and private keys

Convert P12 into PEM

openssl pkcs12 -in google-service-account-key.p12 -nocerts -nodes -out google-service-account-key.pem

openssl pkcs12 -in google-service-account-key.p12 -clcerts -nokeys -out google-service-account-crt.pem

Private RSA key

openssl rsa -in google-service-account-key.pem -out google-service-account-key-rsa

Public RSA key

openssl rsa -in google-service-account-key.pem -out google-service-account-key-rsa.pub -pubout

OpenSSL Playground

Verify downloaded file
➜  openssl dgst -sha256 openssl-1.1.1.tar.gz
SHA256(openssl-1.1.1.tar.gz)= 2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d
➜  cat openssl-1.1.1.tar.gz.sha256
2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d
RSA Public Key pad and encrypt