Skip to content

Instantly share code, notes, and snippets.

Bryan Davis brydavis

Block or report user

Report or block brydavis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View base.dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y golang
RUN apt-get install -y python3
CMD tail -f /dev/null
@brydavis
brydavis / docker_wasteland.sh
Last active Aug 14, 2019
Removes all Docker images and containers
View docker_wasteland.sh
# 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
View get_rental_info.py
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"
View dynamo_multithread.py
"""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')
@brydavis
brydavis / database.py
Created Aug 13, 2019
Mongo Code from Lesson 5 and 7
View database.py
import csv
from pprint import pprint
from pymongo import MongoClient
import threading
# https://stackoverflow.com/questions/35813854/how-to-join-multiple-collections-with-lookup-in-mongodb
"""
High Level Requirements
View threading_race_conditions.py
import logging
import threading
import time
class FakeDatabase:
def __init__(self):
self.value = 0
def update(self, name):
logging.info("Thread %s: starting update", name)
View simple_threading.py
import sys
import threading
import time
def func():
for i in range(5):
print("hello from thread %s" % threading.current_thread().name)
time.sleep(1)
threads = []
@brydavis
brydavis / simple_s3_demo.py
Created Aug 10, 2019
Simple S3 operations
View simple_s3_demo.py
# install boto3
# pip install --upgrade boto3
# setup IAM and get credentials
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html
# https://console.aws.amazon.com/iam/home
"""
- Create a User
- Give user a name and set "Programmatic access" only for Access Type
@brydavis
brydavis / demo.py
Last active Aug 10, 2019
UWPCE - Lesson 06
View demo.py
import time
import math
# from timeit import timeit
# print(timeit('[x for x in range(100)]', number=1000))
# print(timeit('[x for x in range(100)]', number=1000))
# print(timeit(lambda: [x for x in range(100)], number=1000))
def do_math():
View docker_run_mongo.sh
docker run --name mongo -p 27017:27017 -d mongo mongod
You can’t perform that action at this time.