Skip to content

Instantly share code, notes, and snippets.

View jessdaubner's full-sized avatar

Jessie Daubner jessdaubner

View GitHub Profile

Mastery Data Coding Challenge

The purpose of this exercise is to simulate real world requirements and delivering on those requirements.

LTL Service

You have been tasked with implementing a Less-than-load (LTL) truck-shipment matching system. The system combines LTL shipments into a single truckload so that all shipments can be completed by a single truck. For example, you can assume that the average truck can haul 48,000 lbs while the average LTL shipment is 8,000 lbs or less.

Requirements

  • Must expose some kind of API (REST/GraphQL or other) to create trucks and shipments
@jessdaubner
jessdaubner / pyspark_retry_exception_decorator.py
Created June 14, 2019 17:21
Glue PySpark retry decorator discussed AWS Community Day 6/20/19
def retry(exception_to_retry, max_retry, delay=10):
"""Implements a decorator function to retry specific exceptions in PySpark jobs.
Since the function takes in arguments defining the retry mechanism, it
returns a normal decorator function that takes no arguments.
Args:
exception_to_retry: str, exception to search for in PySpark stack trace
max_try: int, max number of times to retry the function
delay: int, seconds to wait before next retry
@jessdaubner
jessdaubner / ngrams_example.py
Last active February 4, 2019 22:09
Example of comparing hashed n-grams using dice coefficient
from hashlib import sha512
def generate_ngrams(last_name, n):
"""Splits a single string into a series of strings comprised of continuous letters of length n.
Args:
last_name (str): a person's last name
n (int): the number of letters in each token (e.g. 2 is a bigram, 3 is a trigram, etc)
Returns:
list of strings
"""