This file contains hidden or 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 subprocess | |
from ruff.__main__ import find_ruff_bin | |
def ruff_format(code: str) -> str: | |
ruff_args = [ | |
find_ruff_bin(), | |
'format', | |
'--stdin-filename', |
This file contains hidden or 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 re | |
lst = [ | |
( | |
r"(x)", | |
"1x2", | |
["1", "x", "2"], | |
), | |
( | |
r"([^\d]+)", |
This file contains hidden or 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
#!/usr/bin/env python3 | |
r""" | |
This script will install Poetry and its dependencies in an isolated fashion. | |
It will perform the following steps: | |
* Create a new virtual environment using the built-in venv module, or the virtualenv zipapp if venv is unavailable. | |
This will be created at a platform-specific path (or `$POETRY_HOME` if `$POETRY_HOME` is set: | |
- `~/Library/Application Support/pypoetry` on macOS | |
- `$XDG_DATA_HOME/pypoetry` on Linux/Unix (`$XDG_DATA_HOME` is `~/.local/share` if unset) | |
- `%APPDATA%\pypoetry` on Windows |
This file contains hidden or 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 __future__ import annotations | |
import string | |
from typing import Iterator | |
non_word_boundaries = set(string.digits + string.ascii_letters + '_') | |
class SplitSentence: | |
def __init__(self, sentence: str): |
This file contains hidden or 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 __future__ import annotations | |
import time | |
from webdriver_manager.chrome import ChromeDriverManager | |
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
This file contains hidden or 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 __future__ import annotations | |
import concurrent.futures | |
from typing import Callable, Iterable | |
def concurrent_map(func: Callable[[T], T2], *it: Iterable[T], max_n_threads: int) -> list[T2]: | |
""" | |
Map a function to an iterable asynchronously |
This file contains hidden or 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 __future__ import annotations | |
from typing import Iterator, TypeVar | |
T = TypeVar('T') | |
def get_dict_keys_path(dct: dict[T, ...], keys: list[T] | None = None) -> Iterator[T]: | |
if keys is None: | |
keys = [] | |
for k, v in dct.items(): |
This file contains hidden or 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 __future__ import annotations | |
import requests | |
def get_all_symbols(exchanges: set[str]) -> list[str]: | |
""" | |
Get a list with all the symbols filtered by a given exchange. | |
Valid exchanges: {'AMEX', 'OTC', 'NYSE', 'NASDAQ'} |
This file contains hidden or 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
CREATE TABLE `test` ( | |
`title` varchar(255) PRIMARY KEY | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | |
INSERT INTO test (title) VALUES ('1. Līga'), ('1. liga'); -- raises: Error Code: 1062. Duplicate entry '1. liga' for key 'PRIMARY' | |
DROP TABLE `test`; | |
-- ############################################################ | |
CREATE TABLE `test` ( |