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 sys | |
import re | |
# Dataframe | |
import pandas as pd | |
import numpy as np | |
# Powerpoint | |
from pptx import Presentation |
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 typing import Dict | |
import re | |
from dataclasses import dataclass, field | |
import sqlparse | |
@dataclass | |
class SQLColumnLineage(): | |
sql: str | |
target_column: str | |
aliased_columns: Dict[str, str] = field(default_factory=lambda: dict()) |
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 typing import List | |
from pydantic import BaseModel | |
class CharacterClass(BaseModel): | |
name: str | |
is_ranged: bool | |
is_magic: bool | |
class Item(BaseModel): | |
name: str |
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
def flatten_json_object_to_lines(obj, remove_keys=None, line_prefix=None, add_key_index=True): | |
''' | |
flattens a JSON parsed obj into multiple lines | |
Last Element [-1] in each line is the value | |
Elements [0:-1] is the path to that value | |
line_prefix if specified will prefix a value to the begining of each outputted line | |
add_key_index will add 0-based index position when encoutering lists or tuples | |
remove_keys if a key (any point in the path) matches then remove it | |
adapted from: https://thispointer.com/python-how-to-iterate-over-nested-dictionary-dict-of-dicts/ | |
''' |
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
<div id="main"> | |
<div class="fof"> | |
<h1>Error 404</h1> | |
</div> | |
</div> |
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 arcade | |
""" | |
A silly demo with the python arcade library | |
""" | |
SCREEN_WIDTH = 640 | |
SCREEN_HEIGHT = 480 | |
HALF_SQUARE_WIDTH = 2.5 |
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 | |
# docs can be found at http://gspread.readthedocs.io/en/latest/ | |
import gspread | |
from oauth2client.service_account import ServiceAccountCredentials | |
def get_googlesheet_worksheet(json_keyfile_name, sheet_name, worksheet_name): | |
scope = ['https://spreadsheets.google.com/feeds'] | |
creds = ServiceAccountCredentials.from_json_keyfile_name(json_keyfile_name, scope) | |
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
# Credit for this: Nicholas Swift | |
# as found at https://medium.com/@nicholas.w.swift/easy-a-star-pathfinding-7e6689c7f7b2 | |
from warnings import warn | |
import heapq | |
class Node: | |
""" | |
A node class for A* Pathfinding | |
""" |
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 | |
import numpy as np | |
def compare_two_dfs(input_df_1, input_df_2): | |
# explicitly calling fillna with "" | |
# as if you've used np.nan it has the | |
# property of nevery being able to be equals | |
# i.e. `np.nan == np.nan` will always be False | |
df_1, df_2 = input_df_1.copy().fillna(""), input_df_2.copy().fillna("") |
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 | |
import yaml | |
from bravado_core.spec import Spec | |
from bravado_core.validate import validate_schema_object, validate_object | |
from jsonschema.exceptions import ValidationError | |
# get a formatted swagger url for yaml definition | |
def get_swagger_yaml_url(organisation, api, version): | |
return "https://api.swaggerhub.com/apis/{}/{}/{}/swagger.yaml".format(organisation ,api, version) |
NewerOlder