This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging, sys | |
# https://docs.python.org/3/howto/logging-cookbook.html | |
logger = logging.getLogger('app') | |
logify_level = logging.ERROR | |
help_statement = """ | |
Accepts integers of corresponding logging levels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pprint import pprint | |
data = {} | |
def find_files(folder, file_extension): | |
for item in os.listdir(folder): | |
item = "/".join([folder, item]) | |
if os.path.isdir(item): | |
data[item] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
# https://medium.com/@ramojol/python-context-managers-and-the-with-statement-8f53d4d9f87 | |
class MongoDBConnection(object): | |
"""MongoDB Connection""" | |
def __init__(self, host='localhost', port='27017'): | |
self.host = f"mongodb://{host}:{port}" | |
self.connection = None | |
def __enter__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging, sys | |
logger = logging.getLogger('example') | |
# changing this impacts the decorator | |
logify_level = logging.ERROR | |
class logify: | |
def __init__(self, logger, level=None, handler=None, close=True): | |
self.logger = logger |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from boto3.dynamodb.conditions import Key, Attr | |
import csv | |
import json | |
# Get the service resource. | |
session = boto3.Session(profile_name="default") | |
dynamodb = session.resource('dynamodb', region_name='us-west-2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
RUN apt-get update | |
RUN apt-get install -y golang | |
RUN apt-get install -y python3 | |
CMD tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Destroy all your images and containers | |
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) | |
docker rmi $(docker images -q) | |
# Deleting those images that are referenced in repositories | |
docker rmi $(docker images -q) --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
from boto3.dynamodb.conditions import Key | |
session = boto3.Session() | |
dynamodb = session.resource('dynamodb', region_name='us-west-2') | |
def lambda_handler(event, context): | |
# { | |
# "product_id": "P000041" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Dynamo Example""" | |
import csv | |
from pprint import pprint | |
import boto3 | |
import threading | |
session = boto3.Session(profile_name="default") | |
dynamodb = session.resource('dynamodb', region_name='us-west-2') |