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
| async def generate_curl_command(method, url, **kwargs): | |
| curl_cmd = f"curl -X {method.upper()} '{url}'" | |
| headers = kwargs.get('headers') | |
| if headers: | |
| for k, v in headers.items(): | |
| curl_cmd += f" -H '{k}: {v}'" | |
| params = kwargs.get('params') | |
| if params: |
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 numpy as np | |
| def adx(high, low, close, window=14): | |
| """Функция для вычисления Average Directional Index (ADX) | |
| Аргументы: | |
| high: Список или массив значений High цен | |
| low: Список или массив значений Low цен | |
| close: Список или массив значений Close цен | |
| window: Период для вычисления ADX (по умолчанию 14) |
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 tkinter as tk | |
| import time | |
| from argparse import ArgumentParser | |
| from logging import getLogger | |
| from tkinter import messagebox | |
| import schedule | |
| logger = getLogger(__name__) |
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 os | |
| from moviepy.editor import VideoFileClip | |
| def main(): | |
| video = VideoFileClip(os.path.join("path_to", "movie.mp4")) | |
| video.audio.write_audiofile(os.path.join("path_to", "audio.mp3")) | |
| if __name__ == '__main__': |
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 functools import wraps | |
| def dec(fn): | |
| @wraps(fn) | |
| async def wrapper(*args, **kwargs): | |
| print(fn.__name__, args, kwargs) | |
| await asyncio.sleep(5) | |
| await fn(*args, **kwargs) | |
| return wrapper |
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 asyncio | |
| async def ticker(delay, to): | |
| for i in range(to): | |
| yield i | |
| await asyncio.sleep(delay) | |
| async def run(): | |
| async for i in ticker(1, 10): |
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 pytest | |
| import sqlalchemy | |
| @pytest.fixture | |
| def engine(): | |
| return sqlalchemy.create_engine('sqlite://') | |
| @pytest.fixture | |
| def engine_with_table_users(engine): |
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 os | |
| def main(my_path: str, replace_name: str): | |
| for dirpath, dirnames, filenames in os.walk(my_path): | |
| for dirname in dirnames: | |
| dir_old_name = os.path.join(dirpath, dirname) | |
| if dir_old_name.find(replace_name) != -1: |