Skip to content

Instantly share code, notes, and snippets.

import cv2
import numpy as np
"""
This histogram will be used to charac- terize the color of the flower petals,
which is a good starting point for classifying the species of a flower
"""
class RGBHistogram:
@youngsoul
youngsoul / create_aws_lambda.py
Created April 28, 2019 15:53
Script to create a lamba zip file distribution. This script lets you specify the exact files you would like in the distribution, and a requirements.txt file that you would like to use for dependencies. If you specify the name of the of the lambda and a profile name it will also generate a script to use the aws cli to update the lambda function.
import os
import subprocess
import zipfile
import sys
import getopt
import shutil
import datetime
"""
@youngsoul
youngsoul / run_aws_py36_docker.sh
Created April 28, 2019 18:53
run script to create a docker environment for AWS Python 3.6
docker run --rm -it -e AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" -e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" -e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" -v "$PWD":/var/task lambci/lambda:build-python3.6 bash
@youngsoul
youngsoul / Install Python 3.6.6 on Raspberry PI.txt
Created May 1, 2019 17:53
Steps to install Python 3.6.6 on Raspberry PI
# create file on RPI, copy contents to a .sh file and execute
# See Gist
# https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f
# setup
echo "Update RPI"
sudo apt-get -y update
sudo apt-get -y install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
# install python 3.6.6
@youngsoul
youngsoul / Install OpenCV 4.1.0 on Buster Raspbian.sh
Created June 27, 2019 03:26
Script / set of instructions for how to install OpenCV 4.1.0 on the Buster version of Raspbian for the Raspberry PI.
# script or instructions to install opencv 4.1.0
# on raspberry pi with buster version of raspbian
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install screen
sudo apt-get -y install htop
# -------------------
# run screen command to put window in background
@youngsoul
youngsoul / automl_bank_client.py
Created March 5, 2020 19:25
Sample Python client for Azure AutoML Model Endpoint
import requests
import json
import pandas as pd
# URL for the web service
scoring_uri = 'http://SOME ID.centralus.azurecontainer.io/score'
# If the service is authenticated, set the key or token
key = 'SOME KEY'
@youngsoul
youngsoul / cognito_client_sign_up.py
Last active March 11, 2020 21:22
snippet showing how to use the AWS Cognito client to sign_up to a user pool.
resp = client.sign_up(
ClientId = os.getenv('CLIENT_ID'),
SecretHash=get_secret_hash(email, os.getenv('CLIENT_ID'), os.getenv('CLIENT_SECRET')),
Username=email,
Password=password,
UserAttributes=[
{
"Name": "custom:favorite_band",
"Value": favorite_band
},
@youngsoul
youngsoul / cognito_confirm_sign_up.py
Created March 11, 2020 21:47
snippet showing how to confirm a sign up with Coginto
resp = client.confirm_sign_up(
ClientId = os.getenv('CLIENT_ID'),
SecretHash=get_secret_hash(email, os.getenv('CLIENT_ID'), os.getenv('CLIENT_SECRET')),
Username=email,
ConfirmationCode=code,
ForceAliasCreation=False
)
@youngsoul
youngsoul / cognito_login.py
Created March 11, 2020 22:10
snippet showing how to have a user login into a Cognito User Pool
resp=client.initiate_auth(
ClientId=os.getenv('CLIENT_ID'),
AuthFlow='USER_PASSWORD_AUTH',
AuthParameters={
'USERNAME': email,
'SECRET_HASH': get_secret_hash(email, os.getenv('CLIENT_ID'), os.getenv('CLIENT_SECRET')),
'PASSWORD': password,
})
return resp
@youngsoul
youngsoul / cognito_token_lambda.py
Last active March 12, 2020 00:47
Python Lambda function receiving a Cognito token and getting the claims from it
import logging
import json
from jose import jwt
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
def lambda_handler(event, context):
logger.debug("Add Note Lambda")