Skip to content

Instantly share code, notes, and snippets.

View izikeros's full-sized avatar

Krystian Safjan izikeros

View GitHub Profile
@izikeros
izikeros / pytest.ini
Last active March 15, 2024 20:05
[pytest CLI logging] Logging settings for pytest. log_cli=true enables display logs during testing. #pytest #configuration
[pytest]
log_cli=true
log_level=NOTSET
log_format=[%(levelname)-.1s] %(message)s
@izikeros
izikeros / yahoo_download_ticker_ohlc.py
Last active March 15, 2024 20:12
[OHLC from Yahoo] Download OHLC ticker data from Yahoo #finance
import yfinance as yf
from datetime import datetime # To get the current date and time
start_date = datetime(2011, 1, 1)
end_date = datetime(2011, 5, 1)
ticker = "MSFT"
yf_ticker_obj = yf.Ticker(ticker)
@izikeros
izikeros / get_project_root.py
Last active March 14, 2024 09:59
[get python project root] #python
# if this file is located in e.g.
# my_project/src/get_project_root.py
# it will return absolute path to the project root e.g.
# /home/john/projects/my_project
# If you have different structure - play with chaining '.parrent'
def get_project_root() -> Path:
return Path(os.path.dirname(os.path.realpath(__file__))).parent
@izikeros
izikeros / README.md
Last active July 4, 2023 03:44 — forked from redpeacock78/docker.yml
lima + docker + docker-compose

lima + docker + docker-compose

Setup

$ brew install lima docker docker-compose
$ echo 'export DOCKER_HOST=unix://$HOME/docker.sock' >> ~/.zshrc
$ . ~/.zshrc

Start

@izikeros
izikeros / file_signature.py
Last active April 13, 2022 04:13
Create signature of file without reading it.
import stat
def _sig(st):
"""Create signatures of files without reading them.
Can be used to determine if files are the same or not.
Example:
>>> s1 = _sig(os.stat(file_name))
"""
@izikeros
izikeros / reduce_pdf_size_with_ghostscript.sh
Last active March 31, 2022 11:39
Reduce size of pdf file using GhostScript
# Requires ghostscript installed.
# - On MacOSX: brew install ghostscript
# - On Windows: install binaries via https://www.ghostscript.com/
#
# use PDFSETTINGS: '/default','/prepress','/printer','/ebook','/screen'
# 0: default - almost identical to /screen
# 1: prepress - high quality, color preserving, 300 dpi imgs
# 2: printer - high quality, 300 dpi images
# 3: ebook - low quality, 150 dpi images
@izikeros
izikeros / README.md
Last active March 25, 2022 08:33
Function for visualization sample count on each step of filtering process

Plot filtering stages with funnel plot

Function for visualization sample count on each step of filtering process

Screenshot 2022-03-25 at 09 28 42

Requirements

Requires plotly_express installed.

Usage

Create "stages" dict during the filtering process. At each stage of filtering add elements both to lists under "count" and "stage" keys.

@izikeros
izikeros / .pylintrc
Created February 17, 2022 19:18
Set new logging style for pylint
[LOGGING]
# Format style used to check logging format string. `old` means using %
# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings.
logging-format-style=new
@izikeros
izikeros / tox.ini
Last active March 14, 2024 09:56
[tox configuration] with black, flake8, mypy, pytest, coverage for the project with code in "src" and "tests" directories #tox #project #python #configuration
[tox]
envlist = black,flake8,mypy,pytest,coverage
skipsdist = true
; tox_pip_extensions was reported to fix the issue with wrong calculation of pytest coverage
; Run --recreate before running tox every time
;$ tox --recreate && tox
; https://stackoverflow.com/a/46968274/3247880
;tox_pip_extensions_ext_venv_update = true
@izikeros
izikeros / add_parent_directory_to_path_jupyter.py
Last active February 22, 2022 10:25
Add parent directory to path. Useful for jupyter notebooks.
# Add parent directory to path
import sys; sys.path.insert(0, '..')