start new:
tmux
start new with session name:
tmux new -s myname
| import eidos | |
| from toolz import partition | |
| import spacy | |
| nlp = spacy.load('en') | |
| def parse(nlp, input_, n_threads, batch_size): | |
| nlp.matcher = None | |
| out = [] | |
| for doc in nlp.pipe(input_, batch_size=batch_size, n_threads=n_threads): |
| def matprint(mat, fmt="g"): | |
| col_maxes = [max([len(("{:"+fmt+"}").format(x)) for x in col]) for col in mat.T] | |
| for x in mat: | |
| for i, y in enumerate(x): | |
| print(("{:"+str(col_maxes[i])+fmt+"}").format(y), end=" ") | |
| print("") | |
| # Try it! | |
| import numpy as np |
| def describe_recursively(datum, level=0, level_increment=2): | |
| indent = lambda i: "|"+"."*i+"|" | |
| info_str = "L{} - TYPE: {:^6} - LEN: {:^5}" | |
| if isinstance(datum, list): | |
| print(indent(level) + info_str.format(level, 'list', len(datum))) | |
| for i, child in enumerate(datum): | |
| describe_recursively(child, level+level_increment, level_increment) | |
| if i>5 and len(datum)>10: | |
| print(indent(level+level_increment)+" ..... ") | |
| describe_recursively(datum[-1], level+level_increment, level_increment) |
| def pad1d(tensor, pad): | |
| # tensor should be in shape (batch, time, feat) | |
| # pad should be in shape (left, right) | |
| tensor = tensor.permute(0, 2, 1).contiguous() # get features on first dim since we are padding time | |
| original_size = tensor.size() # (batch, feat, time) | |
| final_new_size = (original_size[0], original_size[1], original_size[2] + pad[0] + pad[1]) | |
| temp_new_size = original_size[:2] + (1,) + original_size[2:] | |
| assert len(temp_new_size) == 4 | |
| tensor = tensor.view(*temp_new_size) | |
| pad = pad + (0, 0) |
| import requests | |
| import argparse | |
| def download_file_from_google_drive(id, destination): | |
| URL = "https://docs.google.com/uc?export=download" | |
| session = requests.Session() | |
| response = session.get(URL, params = { 'id' : id }, stream = True) | |
| token = get_confirm_token(response) |
| SSH agent forwarding is great. It allows you to ssh from one server to | |
| another all the while using the ssh-agent running on your local | |
| workstation. The benefit is you don't need to generate ssh key pairs | |
| on the servers you are connecting to in order to hop around. | |
| When you ssh to a remote machine the remote machine talks to your | |
| local ssh-agent through the socket referenced by the SSH_AUTH_SOCK | |
| environment variable. | |
| So you the remote server you can do something like: |