Skip to content

Instantly share code, notes, and snippets.

View vsmelov's full-sized avatar

Smelov Vladimir vsmelov

View GitHub Profile
@vsmelov
vsmelov / cache2parquet.py
Last active March 2, 2018 07:35
decorator for cache function result to parquet
def cache2parquet(func):
""" decorator for cache function result to parquet
i.e.
# define:
@cache2parquet
def smart_and_slow_calculations(spark, **other_kwargs):
# some smart and slow code
return df
# use:
def foo():
x = 2
while True:
print('a x: {}'.format(x))
x = yield 2*x
print('c x: {}'.format(x))
f = foo()
print('begin')
i = next(f)
@vsmelov
vsmelov / timer.py
Last active August 30, 2018 11:14
Удобный контекстный менеджер для засекания исполнения чего-либо
from time import time
class Timer:
def __init__(self, begin=None, end=None):
self.begin = begin
self.end = end
def __enter__(self):
self.begin = time()
@vsmelov
vsmelov / docker_install
Created March 18, 2017 13:01
Устанавливает Docker и docker-compose на Ubuntu
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"