This file contains 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
# install Jupyter Notebook into system site-packages | |
pip install -U notebook | |
# create a virtualenv and use the Jupyter from the system site-packages | |
mkvirtualenv --system-site-packages myvenv | |
# the virtualenv is now activated | |
pip install ipykernel | |
VM_NAME=myvm python -m ipykernel install --user --name $VM_NAME --display-name $VM_NAME | |
python -m jupyter notebook | |
# In the browser: New -> select kernel "myvm" |
This file contains 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
# Source: | |
# https://forum.sublimetext.com/t/retrieving-inserted-and-deleted-text/18697/24 | |
import sublime | |
import sublime_plugin | |
def get_cursors(view): | |
# can't use `view.sel()[:]` because it gives an error `TypeError: an integer is required` | |
return [cursor for cursor in view.sel()] |
This file contains 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 functools import wraps | |
def side_effect(callback, before=True, after=False): | |
"""A decorator. | |
Wraps the decorated function. The callback will be called before and after each | |
call of the decorated function according to the parameters. | |
Args: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
ctnrs=(nginx); fswatch -e '.*/\..*' `grep context docker-compose.yml|awk -F':' '{print $2}'`|while read; do kill -0 "$p" &>/dev/null && kill "$p" && p=; sleep 0.2; docker-compose rm -f -v $ctnrs && docker-compose up --build $ctnrs &; p=$!; done |
This file contains 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
import threading | |
from queue import Empty, Full | |
class QueueClosed(Exception): | |
pass | |
class MyQueue(): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import typing | |
from collections import OrderedDict | |
def lru_cache2(size=128): | |
cache = OrderedDict() | |
def make_key(x): | |
if isinstance(x, typing.Mapping): |