Skip to content

Instantly share code, notes, and snippets.

View amancevice's full-sized avatar
🐠
oh hello

Alexander Mancevice amancevice

🐠
oh hello
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from datetime import datetime
from time import sleep
class Timer(object):
""" ActiveRecord Migration-style timer using context management. """
def __init__(self, name):
self.name = name
self.start = datetime.utcnow()
def print_docker_stream(stream):
""" Emulate docker pull/push output on stderr. """
# Initialize list of layers
layers = []
# Interate through stream
for line in stream:
# Print normal layer progress
try:
# Get layer ID
def block_helper begin_msg, ensure_msg
start = Time.now
puts begin_msg.call(start)
begin
yield
rescue Exception => err
abort err.to_s
ensure
puts ensure_msg.call(start)
end

Keybase proof

I hereby claim:

To claim this, I am signing this object:

Managing ENV with AWS SecretsManager for NodeJS

AWS SecretsManager is a service that allows you to store encrypted secrets in the cloud as raw strings or JSON docs.

Storing secrets as JSON allows you to store ENV settings, similar to a .env file.

Using the aws-sdk library for NodeJS, we can update our application's process.env with the encrypted environment.

Install AWS SDK

@amancevice
amancevice / dotenv.sh
Last active February 20, 2022 13:40
Source .env file into new shell
#!/bin/sh
function dotenv() {
dotfile="${1:-.env}"
# Error if file does not exist
if ! [ -f $dotfile ] ; then
echo "$dotfile: No such file or directory" >&2
return 1
fi
@amancevice
amancevice / terraform-use.md
Last active March 30, 2021 13:39
Terraform version switching

Terraform Version Switching

Add the following to your bash profile:

function terraform-use {
  vsn=$1
  pkg="terraform_${vsn}_darwin_amd64.zip"
  url="https://releases.hashicorp.com/terraform/$vsn/$pkg"
 tf="$( which terraform || echo /usr/local/bin/terraform )"
{
"Comment": "Input Routing Example",
"StartAt": "Route Input",
"States": {
"Route Input": {
"Type": "Choice",
"Default": "Step 1",
"OutputPath": "$.Input",
"Choices": [
{