This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
NewerOlder