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 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:

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
{
"Comment": "Input Routing Example",
"StartAt": "Route Input",
"States": {
"Route Input": {
"Type": "Choice",
"Default": "Step 1",
"OutputPath": "$.Input",
"Choices": [
{
@amancevice
amancevice / IAMAuth.md
Created September 25, 2020 12:12
Using IAM to authorize requests to AWS

IAM Authorizer

Using IAM to authorize requests to AWS

Construct Authorizer

Construct a custom authorizer class

import boto3
@amancevice
amancevice / index.py
Created January 6, 2021 20:38
Simple and uniform logging in AWS Lambda
import json
import logging
import os
import sys
class SuppressFilter(logging.Filter):
def __init__(self, logger):
self.logger = logger
@amancevice
amancevice / commit-msg
Last active March 23, 2021 11:12
A git hook for mining Amulets https://text.bargains/amulet/
#!/bin/sh
# .git/hooks/commit-msg
chksum="$( printf "%s" "$(< $1)" | sha256sum )"
amulet="\e[5;1;48mYOU HAVE FOUND %s AMULET\e[0m\n"
if grep 8888888888 > /dev/null <<< $chksum ; then
printf "$amulet" "AN IMPOSSIBLE"
elif grep 888888888 > /dev/null <<< $chksum ; then
printf "$amulet" "A MYTHIC"
elif grep 88888888 > /dev/null <<< $chksum ; then
printf "$amulet" "A LEGENDARY"