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 join_number(a: int, b: int, base: int) -> int: | |
return a * base ** math.ceil(math.log(b, base)) + b | |
assert join_number(2, 3, 10) == 23 | |
assert join_number(4, 64, 10) == 464 | |
assert join_number(573, 82, 10) == 57382 | |
assert join_number(0b101, 0b111, 2) == 0b101111 |
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
alias py='python3 -i -c "import sys, rich, rich.pretty, rich.traceback; rich.pretty.install(); rich.traceback.install(); rich.print(\'[b]Python[/b]\', f\'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}\')"' && funcsave py |
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 starlette.applications import Starlette | |
from starlette.responses import StreamingResponse | |
from starlette.requests import Request | |
from starlette.routing import Route | |
from pathlib import Path | |
from typing import IO, Generator | |
""" | |
Stream a file, in this case an mp4 video, supporting range-requests using starlette |
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
[One Dark] | |
normal-foreground = #ffffff | |
normal-background = #282c34 | |
keyword-foreground = #c678dd | |
keyword-background = #282c34 | |
builtin-foreground = #56b6c2 | |
builtin-background = #282c34 | |
comment-foreground = #5c6370 | |
comment-background = #282c34 | |
string-foreground = #98c379 |
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
''' | |
Module containing the utility function: include | |
''' | |
import pkgutil | |
import importlib | |
import sys | |
from typing import Callable | |
from _frozen_importlib import ModuleSpec |
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
# Go here for the working version: https://gist.github.com/tombulled/d313c54a0681fcf0ba6d8092f11411e6#gistcomment-3069388 | |
import hashlib | |
from pprint import pprint | |
import base64 | |
import bytebuffer # https://github.com/alon-sage/python-bytebuffer, pip install bytebuffer | |
# Other ByteBuffer classes I've found: https://github.com/iGio90/PyByteBuffer, https://github.com/aglyzov/bytebuffer | |
import secrets | |
import pyaes # https://github.com/ricmoo/pyaes, pip install pyaes |