Skip to content

Instantly share code, notes, and snippets.

View freelancing-solutions's full-sized avatar
💯
Available

mobius-crypt freelancing-solutions

💯
Available
View GitHub Profile
from datetime import datetime, timedelta
from flask import Blueprint, render_template, request, make_response, flash, redirect, url_for, Response
from pydantic import ValidationError
from src.logger import init_logger
from src.database.models.auth import Auth, RegisterUser
from src.database.models.users import User, CreateUser, PasswordResetUser
from src.main import user_controller
auth_route = Blueprint('auth', __name__)
@freelancing-solutions
freelancing-solutions / scratch_3.py
Created April 17, 2023 10:49
it will work just fine mate
def this_works_just_fine(my_list: list[int] = []) -> list[int]:
"""
This function will remove the first element of a list
"""
my_list.pop(0)
my_list.reverse()
return my_list
def still_works():
class Cache:
"""
A class to handle caching of data, both in-memory and in Redis.
The class provides thread-safe caching and automatic cache eviction when full.
:param max_size: The maximum size of the in-memory cache. The default is set in the config file.
:param expiration_time: The expiration time of each cache entry, in seconds. The default is set in the config
file.
:param use_redis: Indicates whether to use a Redis cache. The default is False.
"""
@freelancing-solutions
freelancing-solutions / lookup_jobs.py
Created April 7, 2023 15:56
HOw to use LookUP Tables to Simplify Flask Routes
import asyncio
from typing import Callable, Coroutine, Dict
from flask import Blueprint, jsonify
from src.authentication.cron_validator import cron_validator
from src.exceptions import InputError, RequestError, status_codes
from src.external_data.StocklistAPI.update_stock_lists import UpdateStocks
from src.external_data.eod.analystrankingsfundamental import \
AnalystRankingsDataSource
@freelancing-solutions
freelancing-solutions / __init__.py
Last active March 24, 2023 19:41
using regex pattern matching to secure an API
import collections
from CloudFlare.exceptions import CloudFlareAPIError
from starlette.requests import Request
from src.config import config_instance
from CloudFlare import CloudFlare
import ipaddress
import hashlib
import re
async def download_eod_and_store(self, _stock, period, session):
"""
**download_and_store**
download eod data and then store
:param _stock:
:param period:
:param session:
:return:
"""
_data = None
@freelancing-solutions
freelancing-solutions / email.py
Created March 10, 2023 20:10
how to send emails with fastapi + background tasks
import asyncio
from asyncio import Queue
from src.email.templates import EmailTemplate
from src.config.config import config_instance
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
class Emailer:
"""
@freelancing-solutions
freelancing-solutions / generalfundametal.py
Created January 9, 2023 14:21
updated general fundamental data
import asyncio
from asyncio import Future
from typing import List, Optional, Tuple, Coroutine, Callable
from google.cloud import ndb
from src.external_data.eod import DataSource
from src.external_data.eod.data_types import MDict
from src.main.loader import eod_data_source
from src.models.exchanges import Exchange
from src.models.fundamental import (FundamentalGeneral, GeneralAddress, GeneralContact, GeneralListings,GeneralOfficers)
from src.models.stock import Stock
import asyncio
from typing import List, Generator, Callable, Any, Dict, Union
from flask import jsonify
from flask_apispec import doc, marshal_with
from google.cloud import ndb
from src.cache.cache_manager import app_cache
from src.exceptions import status_codes
from src.models.fundamental import (FundamentalGeneral, GeneralAddress, GeneralContact, GeneralListings,
GeneralOfficers,
FundamentalHighlights, FundamentalValuation, FundamentalSharesStats,
@freelancing-solutions
freelancing-solutions / highlightsfundamental.py
Created December 25, 2022 08:01
Python - Fast Method of Processing Fundamental Highlights Data from using asyncio and ndb.put_multi_async
import asyncio
from typing import List, Optional, Coroutine
from google.cloud import ndb
from src.external_data.eod import DataSource, MDict
from src.main.loader import eod_data_source
from src.models.fundamental import FundamentalHighlights
from src.models.temp.fundamental import TempFundamentalJSON
from src.parsers import FundamentalHighlightsParser
from itertools import chain