name | name_title | name_first | name_middle | name_last | name_suffix | name_nickname | |
---|---|---|---|---|---|---|---|
0 | Mr. Lin-Manuel Miranda | Mr. | Lin-Manuel | Miranda | |||
1 | Mz. Katrina Lenk | Mz. | Katrina | Lenk | |||
2 | Renée Elise Goldsberry | Renée | Elise | Goldsberry | |||
3 | Scott Leo "Taye" Diggs | Scott | Leo | Diggs | Taye | ||
4 | Mz. Rebecca "The Boss" Teichman | Mz. | Rebecca | Teichman | The Boss |
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 abc import ABC, abstractmethod | |
import builtins | |
from typing import Optional, Dict | |
import pytest | |
class BaseInput(ABC): | |
@abstractmethod |
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 fastapi import FastAPI | |
app = FastAPI() | |
@app.get("/") | |
def hello(): | |
"""Simple hello world function""" |
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
""" | |
665. Non-decreasing Array [Medium] | |
https://leetcode.com/problems/non-decreasing-array/ | |
# PROBLEM: | |
Given an array nums with n integers, your task is to check if it could become | |
non-decreasing by modifying at most one element. | |
We define an array is non-decreasing if nums[i] <= nums[i + 1] holds |
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
""" | |
787. Cheapest Flights Within K Stops | |
https://leetcode.com/problems/cheapest-flights-within-k-stops/solution/ | |
DFS Solution in python | |
""" | |
from collections import deque, defaultdict | |
class Solution: | |
def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int: |
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
SELECT | |
html | |
FROM | |
url_content | |
WHERE | |
url=url | |
AND date_created >= '1 week ago' | |
ORDER BY | |
date_created DESC | |
LIMIT 1; |
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 datetime import datetime | |
# Create a helpful lambda to get timestamp for n hours ago | |
n_hours_ago = lambda x: datetime.utcnow() - datetime.timedelta(hours=x) | |
# Your query | |
# Note: I don't bother properly importing `session` or `UrlContent` here | |
query = session.query(UrlContent)\ | |
.filter_by( | |
url==url, |
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 requests | |
url = 'https://www.python.org/' | |
# Query with pseudo-code | |
result = """ | |
SELECT | |
html | |
FROM | |
url_content |
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 datetime | |
from sqlalchemy.orm import declarative_base | |
# declarative base class | |
Base = declarative_base() | |
class UrlContent(Base): | |
__tablename__ = 'url_content' | |
id = Column(Integer, primary_key=True, autoincrement=True) | |
url = Column(String(500), nullable=False, unique=False) |
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 pandas as pd | |
from nameparser import HumanName | |
from functools import lru_cache | |
# sample data | |
records = [{"name":"Mr. Lin-Manuel Miranda"}, {"name":"Ms. Katrina Lenk"}, | |
{"name":"Renée Elise Goldsberry"}, {"name":"Scott Leo \"Taye\" Diggs"}, | |
{"name":"Ms. Rebecca \"The Boss\" Teichman"}] | |
# Load into a dataframe |
NewerOlder