This file contains hidden or 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 postgres:13.2-alpine | |
| ADD init.sql /docker-entrypoint-initdb.d/ |
This file contains hidden or 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
| . . . | |
| def requires_auth(permission=""): | |
| def requires_auth_decorator(f): | |
| @wraps(f) | |
| def wrapper(*args, **kwargs): | |
| permissions = get_jwt()["permissions"] | |
| if not permissions: | |
| raise AuthError( | |
| { |
This file contains hidden or 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
| class MemberModel(db.Model, ModelMixin): | |
| __tablename__ = "members" | |
| id = db.Column(db.Integer, primary_key=True) | |
| email = db.Column(db.String(100), nullable=False, unique=True) | |
| password_hash = db.Column(db.String(94), nullable=False) | |
| mobile_phone = db.Column(db.String(15)) | |
| first_name = db.Column(db.String(50), nullable=False) | |
| last_name = db.Column(db.String(50), nullable=False) | |
| linkedin_profile = db.Column(db.String(75)) |
This file contains hidden or 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 typing import Union | |
| class Node(object): | |
| """Node class consisting of data and a left / right branches""" | |
| def __init__(self, data: Union[float, int, str]) -> None: | |
| self.data = data | |
| self.left = None | |
| self.right = None |
This file contains hidden or 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 typing import Union | |
| class Node: | |
| """Node class consisting of data and a pointer to the next node""" | |
| def __init__( | |
| self, | |
| data: Union[float, int, str], | |
| next_node: Union["Node", None] = None, |
This file contains hidden or 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 random | |
| import time | |
| from typing import List | |
| def quicksort(l: List) -> List: | |
| """Recursive solution to performing quicksort on a list""" | |
| # Base case | |
| if len(l) <= 1: | |
| return l |
This file contains hidden or 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 time | |
| import sys | |
| def string_length(s: str) -> int: | |
| """Recursive solution to counting the characters of a string""" | |
| # Base case | |
| if len(s) <= 1: | |
| return len(s) | |
| # Recursive case |
This file contains hidden or 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 time | |
| import sys | |
| from typing import List | |
| def list_sum(l: List) -> float: | |
| """ | |
| Recursive solution to computing the sum of all elements in a | |
| list of numbers | |
| """ |
This file contains hidden or 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 time | |
| def gcd(a: int, b: int) -> int: | |
| """ | |
| Recursive solution to computing the greatest common divisor of | |
| two integers a and b | |
| """ | |
| # Base case | |
| if b == 0: |
This file contains hidden or 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 time | |
| def factorial(n: int) -> int: | |
| """Recursive solution to the factorial of n""" | |
| # Base case | |
| if n <= 1: | |
| return 1 | |
| # Recursive case | |
| else: |