Skip to content

Instantly share code, notes, and snippets.

View sancau's full-sized avatar

Alexander Tatchin sancau

View GitHub Profile
#!/bin/bash
# /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/pip install -U keytar jupyter-server-proxy
echo == INSTALLING CODE-SERVER ==
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version=4.13.0
#########################################
### INTEGRATE CODE-SERVER WITH JUPYTER
#########################################
@sancau
sancau / ssh_copy_to_remote.sh
Created February 9, 2023 14:45
SSH copy key to remote (without any installed utils)
cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
@sancau
sancau / challenge.md
Last active May 19, 2022 08:22
Welltory Challenge (Python developer in Data Science)

Предлагается реализовать веб-сервис для обработки данных.

Контекст задачи:

  • у нас есть пользователи от которых мы получаем некоторые данные
  • мы получаем данные каждый день, таким образом каждая точка данных соответствует некоторой дате
  • в рамках этой задачи будем считать что все данные имеют тип float
  • в результате сбора данных мы имеем массивы вида [{"date": ..., "value": ...}, {"date": ..., "value": ...}, ...]
  • видов (например шаги, средняя частота пульса и тп) данных может быть много, в рамках этой задачи будем считать, что они однозначно различаются по строковому названию (см. примеры запросов к АПИ ниже)
  • как данные попадают к нам и как они технически храняться - за рамками данной задачи
@sancau
sancau / lru_with_ttl.py
Created July 19, 2020 13:35
Python LRU cache with TTL. Decorator.
import time
from functools import lru_cache
def lru_with_ttl(*, ttl_seconds, maxsize=128):
"""
A decorator to apply LRU in-memory cache to a function with defined maximum(!) TTL in seconds.
Be design an actual TTL may be shorter then the passed value (in rare randomized cases). But it can't be higher.
:param ttl_seconds: TTL for a cache record in seconds
@sancau
sancau / jupyter_wide_window_hide_code_matplotlib.py
Created September 24, 2019 13:30
Common Jupyter notebook init cell contents. Hide code toggle, make it wide, matplotlib inline
%matplotlib inline
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
HTML("""
<script>
code_show=true;
@sancau
sancau / df_sparse.py
Created December 18, 2018 21:44
Sparse pd.DataFrame
data = [
['User', 'Content Type', 'File', 'Mb'],
['User 1', 'Text', 'F1', 0.1],
['User 1', 'Text', 'F2', 0.5],
['User 1', 'Video', 'V1', 100],
['User 2', 'Text', 'F1', 2],
['User 2', 'Video', 'V1', 75],
['User 3', 'Video', 'V2', 60],
]
@sancau
sancau / comparator.ipynb
Created October 26, 2018 08:31
Windowed comparison in Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sancau
sancau / script.sh
Created July 31, 2018 15:59
Allow to choose specific pipenv kernel in Jupyter
pipenv shell
pipenv install ipykernel
python -m ipykernel install --user --name=VENV_NAME
jupyter lab
@sancau
sancau / task.md
Last active December 18, 2018 21:52
Test task (Python)

Тестовое задание (разработчик Python)

Есть файл Excel содержащий следующий набор данных:

  • Список URL, колонка "url"
  • Текстовые метки, колонка "label"
  • Сооветствующие каждой URL флаги, колонка "fetch" (ИСТИНА или ЛОЖЬ)

Требуется реализовать скрипт который:

@sancau
sancau / gist:907da9d1593702f3077daa791938e039
Last active March 30, 2017 07:58
Totaly and recursively shared directory in Linux (even for newly created files and dirs)
!# /bin/sh
sudo mkdir /shared
sudo chmod a+rwxs /shared
sudo setfacl -d -m o:rwx /shared