Skip to content

Instantly share code, notes, and snippets.

View toolittlecakes's full-sized avatar

Nikolay Sheyko toolittlecakes

  • CodeSignal
  • Yerevan, Armenia
View GitHub Profile
@toolittlecakes
toolittlecakes / function_polymorphism.py
Last active April 17, 2024 03:44
Inspired by this article about unobvious usage of polymorphism in order to embrace functional approach to create alternative solution
import syslog
from dataclasses import dataclass
from typing import Callable, Generic, Literal, Protocol, Type, TypeVar, TypeVarTuple
# Initial solution with classes
#
# class Filter(Protocol):
# def filter(self, message: str) -> bool: ...
# class TextFilter(Filter):
@toolittlecakes
toolittlecakes / st_fixed_container.py
Last active October 1, 2025 16:03
Sticky/fixed container for streamlit apps. Supports dynamic width change as well as dynamic color updates. Both top/bottom positions are available.
from typing import Literal
import streamlit as st
from streamlit.components.v1 import html
"""
st_fixed_container consist of two parts - fixed container and opaque container.
Fixed container is a container that is fixed to the top or bottom of the screen.
When transparent is set to True, the container is typical `st.container`, which is transparent by default.