Category: code shorts
-
How to merge specific file changes from branch B into branch A without merging the entire branch
Use this git command to fetch changes from specific file instead of merging the whole branch! git checkout B — path/to/your/file
-
How to get rid of SQLAlchemy deprecated API while TDD with pytest
Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to “sqlalchemy<2.0”. Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings. Set environment variable export SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
-
How to Install a .deb Package on Ubuntu
To install a .deb package on Ubuntu, follow these steps: Download the .deb Package: Obtain the .deb file from a trusted source. Open Terminal: Press Ctrl + Alt + T to open the terminal. Navigate to the Directory: Use the cd command to go to the directory where the .deb file is located. For example:…
-
How to stream media file from s3 directly to AWS lambda FFMPEG Python example
There is no need to download a file and put it inside your lambda’s /tmp folder to process it with FFMPEG. I will show you how to do it “on the fly”. Just stream a damn file directly into ffmpeg! def execute_ffmpeg_command(input_file: str): “”” Execute the given ffmpeg command against the input file. Args: input_file…
-
How to measure execution time of a function in Python, with example
this would be the timeit decorator: from functools import wraps import time def timeit(func): @wraps(func) def timeit_wrapper(*args, **kwargs): start_time = time.perf_counter() result = func(*args, **kwargs) end_time = time.perf_counter() total_time = end_time – start_time print(f’Function {func.__name__}{args} {kwargs} Took {total_time:.4f} seconds’) return result return timeit_wrapper example how this decorator works: @timeit def lol(): print(“lmao, Serhii is the…