Skip to content

Instantly share code, notes, and snippets.

Avatar

João Paulo Bochi jpbochi

View GitHub Profile
View simple-git-branching-model.md

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@jpbochi
jpbochi / pubkey.pgp
Created Dec 28, 2020
test public gpg key
View pubkey.pgp
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF+GyRMBEADA8FXW5Ohe9rRU3bfLe5INgIT0sPln+ToPDPNQYhZhqh95amKR
qwJ9XO7R84WL0/b7GCTEdL5PmdkXpHAfWxAk1BNvWMCjsw4BrNZ4DTFywuvQc7Oj
5n5G32u4VB3ylGct808iD0F3tXSnSnoRZNuXTwz8oA73XM3l3fUjbzrpoEd7NPTK
uxn+OcK1591OVW/JKXt12aru+JF/UCfJV5y9droE/b7D47gGqylSp6Ba+AjlVtdt
PLJoUgId2uca5U+Fa1Fe6TeTjJpb9Xh09sRiy5dkE4WIiqdziSjDiy5YFiNXJsNV
KMl7kkBERXHPqVFIR9NNX3bvgB9u5MYdLNgrEIkvQUbDr7jmBoNllA7rpZl66JVn
9Xduvilb7yHKosCS54JSBQ86gEhNxBV1u3QuDhSzwYc7yEtrKEBqePLwRnfzXEAU
/paKIOdnBB8dcQY8TWCkrh9mA5RbisQw4wRkeexhpwvbNWlfeIoTceEYypGEGjoy
View keybase.md

Keybase proof

I hereby claim:

  • I am jpbochi on github.
  • I am jpbochi (https://keybase.io/jpbochi) on keybase.
  • I have a public key whose fingerprint is F786 2518 AC95 8837 46FA 77F0 1E82 F6A5 57A5 C04D

To claim this, I am signing this object:

@jpbochi
jpbochi / delete-baddie.sh
Created Aug 3, 2020
kubectl force delete
View delete-baddie.sh
# Start a kubectl proxy
kubectl proxy
# Get a json with the resource you want to delete
kubectl get challenges.acme.cert-manager.io quickstart-example-tls-1016717128-3781756796-4176224615 -o json > bad.json
# Make a PUT call removing any finalizer
cat bad.json | jq '. | setpath(["metadata","finalizers"]; [])' | curl -kD- -H "Content-Type: application/json" -X PUT --data-binary @- "127.0.0.1:8001$(cat bad.json | jq -r '.metadata.selfLink')"
@jpbochi
jpbochi / .bash_ps1
Created Aug 6, 2019
bash PROMPT_COMMAND + PS1 for git status
View .bash_ps1
#!/usr/bin/env bash
# copied from http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# TODO: scope the following env vars to this file only. They can be seen with `declare -p`
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@jpbochi
jpbochi / runcached.bash
Created Aug 2, 2019
Run speficied (presumably expensive) command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
View runcached.bash
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o noglob
set -o pipefail
#
# Purpose: run speficied command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
# Also cache exit status and stderr.
# License: GPLv3
@jpbochi
jpbochi / pull-aws-creds.sh
Last active Jan 4, 2021
pull-aws-creds.sh
View pull-aws-creds.sh
#!/usr/bin/env sh
set -eu
API_BASE="${API_BASE:-https://github.api.manage.rackspace.com}"
KEY_FILE=${KEY_FILE:-"$HOME/.ssh/id_rsa"}
fail() {
echo >&2 "This tool needs an SSH key to sign a request to $API_BASE."
echo >&2 "The key must be configured as a deploy key in your GitHub repository linked to an AWS account."
@jpbochi
jpbochi / decrypt.sh
Last active Oct 10, 2018
bash SSH encrypt/decrypt/sign
View decrypt.sh
#!/usr/bin/env sh
set -eu
# some inspiration from https://raymii.org/s/tutorials/Sign_and_verify_text_files_to_public_keys_via_the_OpenSSL_Command_Line.html
MESSAGE=$1
ID_FILE=$(ssh -G git@github.com | grep identityfile | cut -d' ' -f2 | xargs -I % sh -c 'test -r % && echo % || true' | head)
echo >&2 '>>> decrypting with this identity file:' $ID_FILE
@jpbochi
jpbochi / init.lua
Created Oct 25, 2017
Hammerspoon config
View init.lua
hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon
FRemap = require('foundation_remapping') -- https://github.com/hetima/hammerspoon-foundation_remapping
remapper = FRemap.new()
remapper:remap('§', '`')
remapper:register()
remapperDE = FRemap.new({vendorID=0x258a, productID=0x1006})
remapperDE:remap('lcmd', 'lalt')
@jpbochi
jpbochi / try-acquire-lock-s3.sh
Created Jul 25, 2017
bash script to lock/unlock resources by using an S3 bucket with file versioning
View try-acquire-lock-s3.sh
#!/usr/bin/env bash
set -eu
log () {
echo >&2 "[lock] $@"
}
putLock () {
aws s3api put-object --region $REGION --bucket $BUCKET --key $LOCK_KEY --output text --query 'VersionId'
}