Skip to content

Instantly share code, notes, and snippets.

View techsolx's full-sized avatar

John MacTavish techsolx

  • Redmond ORE or Middlebury VT
View GitHub Profile
@techsolx
techsolx / yaml2json.py
Created June 7, 2022 20:16
Convert yaml to json using python. To use: cat <input.yaml> | yaml2json | tee <output.json>
#! /usr/bin/env python3
import json
import sys
import yaml
f = yaml.safe_load(sys.stdin.read())
json.dump(f, sys.stdout)
@techsolx
techsolx / unlock-keychain.md
Last active February 1, 2022 18:47
Error saving credentials: error storing credentials - err: exit status 1, out: `User interaction is not allowed.`

Error when remote on OSX cli and running docker commands for aws login or other login

Issue is that the cli lacks access to the keychain

aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456789112.dkr.ecr.us-west-2.amazonaws.com
Error saving credentials: error storing credentials - err: exit status 1, out: `User interaction is not allowed.`

Fix with:

@techsolx
techsolx / openssl.md
Last active January 20, 2022 18:04
Open ssl commands I use from time to time

Shamelessly borrowed from the internets

General OpenSSL Commands

These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.

Generate a new private key and Certificate Signing Request openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key

Generate a self-signed certificate openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt

@techsolx
techsolx / assume_working_role.md
Last active January 6, 2021 20:02
Bash function to export aws credentials into environment

Using aws named profiles allow export using a bash function:

# Allow user to set aws profile in env
# requires aws and jq
# assume working role
awr() {
   if [ -x "$(command -v jq)" ] && [ -x "$(command -v aws)" ]; then
       export AWS_PROFILE=$1
 echo -n "Assumed working role: "

Keybase proof

I hereby claim:

  • I am techsolx on github.
  • I am techsolx (https://keybase.io/techsolx) on keybase.
  • I have a public key ASAl_twsIhl7Vx1qRUvZhIAzx8nfi32TXvT8YkBORPJZvgo

To claim this, I am signing this object:

@techsolx
techsolx / ycm_core_pyenv.md
Last active September 18, 2020 21:16
Updating ycm_core with pyenv

The problem I had was how to update ycm_core when it is out of date.

Using pyenv and pyenv virtualenv

Linux 20.04 box with build deps installed:

apt-get -y install build-essential cmake vim python3-dev

ycm installed with: Vundle

@techsolx
techsolx / gist:38705dc8fbb0203b0e1ee821abe70062
Last active December 8, 2021 16:46
git push to trigger ci build
git commit --allow-empty -am '<feat:fix:breaking:> Trigger CI build'
Fetch and checkout branches
git fetch git@<url>:<repo>.git <branch>
git checkout -b <repo>/<branch> FETCH_HEAD
Review the changes in vim https://github.com/tpope/vim-fugitive
Then merge and fix conflicts
git fetch upstream
git checkout upstream/main
@techsolx
techsolx / ses_from_iam.py
Last active June 10, 2022 20:53
Obtaining Amazon SES SMTP Credentials by Converting AWS Credentials with Python3
#!/usr/bin/env python3
import argparse
import base64
import hashlib
import hmac
def hash_iam_secret(sakey, version):
key_bytes = str.encode(sakey)