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 | |
import secrets | |
from fastapi import FastAPI, Security, HTTPException, status, Depends | |
from starlette.responses import JSONResponse | |
from fastapi.security.api_key import APIKeyHeader, APIKey | |
auth_header = APIKeyHeader(name="Authorization", auto_error=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
def parse(path): | |
with open(path) as gf: | |
file_stream = gf.read() | |
import re | |
dependencies = [] | |
lines = re.findall(r"\s+?gem\s\s?(?:\'|\")[a-zA-Z0-9\_\-\.]+(?:\'|\"),?\s?(?:(?:\'|\")[0-9\.]+(?:\'|\"),\s)?git:.*", file_stream) | |
if lines: | |
temp = [] | |
for line in lines: |
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 typing | |
import datetime | |
import warnings | |
from .enums import QueryFields, Operator, MimeType | |
class Query: | |
def __init__(self) -> None: | |
self.data = list() |
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 pydantic import validate_arguments, ValidationError | |
# A function with type hints | |
def arg_not_validated(s: str, i: int) -> str: | |
return f'{type(s)}, {type(i)}' | |
# A function using the Pydantic validate_arugments decorator. | |
# Refer https://pydantic-docs.helpmanual.io/usage/validation_decorator/ | |
@validate_arguments | |
def arg_validated(s: str, i: int) -> 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
# This snippet reads a Pydantic model and gets data via std input and validates them back with the same model. This validated data can be exported for further processing in your own code. | |
from pydantic import BaseModel, AnyUrl | |
from typing import Optional | |
# Create a Pydantic Model. All Pydantic models needs be validated as dictionary mappings. A model can also contain a sub model. Such feature can be used to validate a Dictionary object within a dictionary. Pydantic also provides ways to validate data without creating models. For more info refer the docs, https://pydantic-docs.helpmanual.io/ | |
class MyModel(BaseModel): | |
name: str = None # Demonstrating the bahaviour of providing default value as None | |
title: Optional[str] # Demonstrating the behavior when using Optional without setting a default value (will auto default to None) |
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 pydantic import BaseModel | |
from datetime import datetime | |
import time | |
class Model(BaseModel): | |
a: datetime | |
b : datetime | |
c : datetime | |
d : datetime | |
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
<!doctype html> | |
<html> | |
<head> | |
<script> | |
// Adding a Javascript redirct | |
// The replace() will replace the current document with provided document | |
window.location.replace('//example.com'); | |
</script> | |
<noscript> | |
<!-- |
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
var dueBy = "A"; // Provide the appropriate column ID | |
var todayIs = "B" // Provide the appropriate column ID | |
var resultField = "C"; // Provide the appropriate column ID | |
var onTrack = "D" // Provide the appropriate column ID | |
// first sheet | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; | |
// row range | |
var startRow = 2; // Mention the range start only |