Skip to content

Instantly share code, notes, and snippets.

View xnuinside's full-sized avatar
🐍
ssssss

Iuliia Volkova xnuinside

🐍
ssssss
View GitHub Profile
@xnuinside
xnuinside / gang_of_four_patterns.md
Last active June 20, 2018 15:12
List of all patterns described in "Gang of Four" book (Design Patterns: Elements of reusable Object-Oriented Software). Shortly.

In the scope of "Gang of Four" book patterns split up on three categories by their purpose: creational, structural, and behavioral. And also pattens split up by criterion, called scope, specifies whether the pattern applies primarily to classes or to objects.

Page 22.:

Class patterns deal with relationships between classes and their subclasses. These 
relationships are established through inheritance, so they are static—
fixed at compile-time. Object patterns deal with object relationships, which can be

changed at run-time and are more dynamic. Almost all patterns use inheritance to some

@xnuinside
xnuinside / postgres_check_table_exist_airflow.txt
Last active January 18, 2021 12:12
Apache Airflow: Check Table Exist and get schema name with Python callable and PostgresHook
from datetime import datetime
from airflow.hooks.postgres_hook import PostgresHook
from airflow.operators.python_operator import PythonOperator
from airflow import DAG
with DAG(dag_id="postgres_check_table", start_date=datetime(2018, 10, 12)) as dag:
def check_table_exist(sql_to_get_schema, sql_to_check_table_exist,
@xnuinside
xnuinside / tox_ini_for_airflow_project.txt
Last active December 10, 2018 09:35
Tox.ini example for Airflow Project (plugins, dags and etc) tests runner
# example for tox.ini with test mode for airflow turned on
[tox]
envlist = flake8, py27
[testenv]
basepython = python2.7
[testenv:flake8]
deps=
@xnuinside
xnuinside / postgres_check_table_exist_airflow.txt
Last active December 10, 2018 10:17
PostgreSQLCheckTable and PostgreSQLCountRows Operators Airflow Plugin
""" import operators with
from airflow.operators.postgres_custom import PostgreSQLCheckTable, PostgreSQLCountRows """
import logging
from airflow.models import BaseOperator
from airflow.plugins_manager import AirflowPlugin
from airflow.utils.decorators import apply_defaults
from airflow.hooks.postgres_hook import PostgresHook
import timeit
i = [str(x) for x in range(1000000)]
def funct_write_with_print():
with open('test1.txt', 'w') as fout:
print(i, file=fout)
def write_with_write():
with open('test12.txt', 'w') as fout:
import multiprocessing as mp
from multiprocessing import Queue
from datetime import datetime
import sympy
start_time = datetime.now()
q = Queue()
def is_prime(left_border, right_border):
result = 0
@xnuinside
xnuinside / sql_alchemy_classical_class.py
Last active March 19, 2020 22:27
SQLAlchemy_classic_model_class_SAMPLE
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
fullname = Column(String)
nickname = Column(String)
class User(Base):
id: int
name: str
fullname: str
nickname: str
@xnuinside
xnuinside / example_of_simple_metaclass.py
Last active March 19, 2020 22:32
medium_broke_files_from_one_gist (
class MySuperMeta(type):
def __call__(cls, *args, **kwargs):
print(f'Do you need an instance of {cls}?')
return super(MySuperMeta, cls).__call__(*args, **kwargs)
class A(metaclass=MySuperMeta):
pass
a = A()
@xnuinside
xnuinside / admin.dockerfile
Last active May 17, 2020 16:44
integration_tests_article
FROM python:3.7.7 as base
RUN pip install poetry==1.0.5
WORKDIR /app
# hack to avoid reinstall dependencies each time when source code of gino_admin changed
# without it poetry will say error what there is no package gino_admin
RUN mkdir /app/gino_admin && touch /app/gino_admin/__init__.py
COPY pyproject.toml poetry.lock README.rst /app/
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi