Prerequisites
One-time installation of dependenciespython3 -m pip install -U jupyter-book ghp-import
sudo yum --enablerepo=extras install centos-release-scl; | |
sudo yum install devtoolset-7; | |
scl enable devtoolset-7 bash |
# Add to ~/.bash_aliases | |
alias port_forward='nohup ssh -N -f -L localhost:8889:localhost:8889 username:password@remote_server_ip' | |
alias remote_notebook_start='nohup ssh -f username:password@remote_server_ip "cd rne; conda activate env_name; jupyter notebook --no-browser --port=8889"; port_forward' | |
alias remote_notebook_stop='ssh username:password@remote_server_ip "pkill -u username jupyter"' | |
# Add this to crontab -e | |
@reboot cd /home/{username}; source ./.bashrc; ./miniconda3/envs/{env_name}/bin/jupyter-lab >> ./cronrun.log 2>&1 |
""" Time-and-Space-Efficient Sampling Methods""" | |
from typing import Iterable | |
from random import random, randint, seed | |
from math import exp, log, floor | |
from itertools import islice | |
__author__ = "Liutong Zhou" | |
def take(iterable, n: int) -> list: |
# pip install autopep8 pylint flake8 black blackcellmagic yapf | |
Program: autopep8 | |
Arguments: --in-place --aggressive --aggressive $FilePath$ | |
Working Directory: $ProjectFileDir$ | |
Regular expression to match output:$FILE_PATH$:$LINE$:$COLUMN$:.* | |
Program: pylint | |
Arguments: "--msg-template='{abspath}:{line}: [{msg_id}({symbol}), {obj}] {msg}'" --output-format=colorized "$FilePath$" | |
Working directory: $ProjectFileDir$ |
{ | |
// For a full list of commands, refer | |
// https://github.com/jupyterlab/jupyterlab/blob/master/packages/notebook-extension/src/index.ts | |
"shortcuts":[ | |
{ | |
"command":"notebook:run-all-above", | |
"keys":[ | |
"F5" | |
], | |
"selector":".jp-Notebook:focus" |
"""BitMask""" | |
class BitMask: | |
__slots__ = ("size", "mask") | |
def __init__(self, size: int = 16): | |
"""Create a bit mask to store (size) 0/1 status""" | |
self.size = size | |
self.mask = 1 << size | |
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0 | |
# Licensed under the Amazon Software License http://aws.amazon.com/asl/ | |
"""S3 Client | |
A helper class which wraps boto3's s3 service | |
""" | |
__author__ = "Liutong Zhou" |
"""UnionFind (Disjoint Sets)""" | |
from typing import Optional, Iterable, Hashable, Any | |
class UnionFind: | |
def __init__( | |
self, initial_disjoint_items: Optional[Iterable[Hashable]] = None | |
): | |
"""Initialize a UnionFind of disjoint sets""" |
"""MinHeap and MaxHeap (Optimized Implementation)""" | |
from abc import ABC, abstractmethod | |
from collections import Counter, UserList | |
from functools import singledispatchmethod | |
from heapq import ( | |
_heapify_max, | |
_heappop_max, | |
_heapreplace_max, | |
_siftdown, | |
_siftdown_max, |