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 | |
from uuid import UUID, uuid4 | |
from datetime import datetime, timezone | |
from functools import partial | |
from typing import Any | |
from pydantic import BaseModel | |
from sqlalchemy import select, func, sql | |
from sqlalchemy.dialects.mysql import insert as mysql_insert | |
from sqlalchemy.dialects.postgresql import insert as postgres_insert |
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 logging | |
import typing | |
import psutil | |
T = typing.TypeVar("T") | |
def safe_execute(function: typing.Callable[..., T], *args, **kwargs, timeout: int = 60) -> T: |
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 argparse | |
import bisect | |
from typing import Any | |
from gekko import GEKKO | |
cumulative_deposit_config = { | |
"grossinterest": 2.6, | |
"deduction": 3.5 + 1.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 sys | |
import typing | |
if typing.TYPE_CHECKING: | |
import types | |
def srcfile_import(modpath: str, modname: str) -> "types.ModuleType": | |
"""It imports a python module from its srcfile |
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 | |
def sieve_of_atkin(n: int) -> list[int]: | |
"""The Sieve of Atkin prime finding algorithm, [1]_ | |
References | |
---------- | |
.. [1] A. O. L. Atkin, D. J. Bernstein, 2003 | |
""" |
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 type="text/javascript"> | |
const X = "I am X"; | |
function helloworld() { | |
return "Hello world"; | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""A centralized logging system for any library | |
source code inspired by https://github.com/huggingface/transformers/blob/main/src/transformers/utils/logging.py | |
""" | |
import logging | |
import os | |
import sys | |
import threading | |
from functools import lru_cache |
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 Any | |
# TODO: type hinting | |
def deepfrozenset(obj: Any) -> Any: | |
if isinstance(obj, dict): | |
return frozenset([(key, deepfrozenset(val)) for key, val in obj.items()]) |
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
"""A collection of graph coloring algorithms | |
The problem of assigning colors to the vertices of a graph such that no two adjacent vertices have the same color. | |
""" | |
import random | |
import typing | |
from collections import defaultdict | |
import networkx |
NewerOlder