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 pdfminer.high_level import extract_text_to_fp | |
from pdfminer.layout import LAParams | |
def extract_text_from_pdf(input_filename: str, output_filename: str, output_images_dir: str | None = None) -> None: | |
with open(input_filename, 'rb') as input_file, open(output_filename, 'w', encoding='utf-8') as output_file: | |
extract_text_to_fp(input_file, output_file, output_dir=output_images_dir, laparams=LAParams()) | |
extract_text_from_pdf( |
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 time | |
from dataclasses import dataclass, field | |
from pathlib import Path | |
from typing import Literal | |
from faster_whisper import WhisperModel | |
model_size = "large-v3" | |
# workaround if we have already installed openai whisper stuff via transformers |
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
# you will need to install the following libraries | |
# - FastAPI | |
# - tweepy (version 4.X) | |
# - twitter-text-parser | |
# - apscheduler (version 3.X) | |
import logging | |
import os | |
from datetime import datetime | |
from typing import Optional, 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
import json | |
import os | |
import tempfile | |
from pathlib import Path | |
import emails | |
import tweepy | |
from apscheduler.schedulers.blocking import BlockingScheduler | |
from apscheduler.triggers.cron import CronTrigger |
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 socket | |
import click | |
from click_params import DomainListParamType | |
@click.option( | |
'-d', '--domains', | |
prompt=True, | |
help='list of domain names separated by a space', |
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 click | |
from click_params import StringListParamType | |
@click.option( | |
'-f', '--flavors', | |
prompt=True, | |
help='list of flavors for your ice cream', | |
type=StringListParamType() | |
) |
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 math | |
from pydantic import validate_arguments, ValidationError, Field | |
from pydantic.typing import Annotated | |
@validate_arguments | |
def get_hypotenuse( | |
a: Annotated[float, Field(gt=0)], | |
b: Annotated[float, Field(gt=0)] |
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 math | |
from pydantic import validate_arguments, ValidationError, Field | |
@validate_arguments | |
def get_hypotenuse( | |
a: float = Field(..., gt=0), | |
b: float = Field(..., gt=0) | |
) -> float: |
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 math | |
from typing import Union | |
def get_hypotenuse(a: Union[int, float], b: Union[int, float]) -> float: | |
if not isinstance(a, (float, int)): | |
raise TypeError | |
if not isinstance(b, (float, int)): | |
raise TypeError |
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 math | |
from dataclasses import dataclass | |
from pydantic import validate_arguments, ValidationError | |
@dataclass | |
class Point: | |
x: int | |
y: int |
NewerOlder