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
PORT=$1 | |
PASSWD=$2 | |
mkdir -p ~/.config/code-server | |
printf "bind-addr: 127.0.0.1:$PORT\n\ | |
auth: password\n\ | |
password: $PASSWD\n\ | |
cert: false" > ~/.config/code-server/config.yaml | |
docker container rm code-server | |
docker run -it --name code-server -p 127.0.0.1:$PORT:8080 \ | |
-v "$HOME/.config:/home/coder/.config" \ |
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
# kill all threads where the full command includes 'experiment-18' | |
ps -axww | grep experiment-18 | grep -v grep | awk '{print $1}' | xargs kill |
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
import scipy | |
from scipy.stats import levy, laplace, maxwell, cauchy | |
import multiprocessing as mp | |
from datetime import datetime | |
dists = [levy, laplace, maxwell, cauchy] | |
nums = [50_000, 75_000, 30_000, 1_000] | |
results = [[], [], [], [], []] | |
nums2 = [76_000, 3_000, 2_000, 15_000] |
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
import torch | |
def create_padded_batch_from_tensors(tensors, pad_dim, pad_value=0): | |
""" | |
Input: list of N tensors of shape (*, L_k, *) for k in 1...N | |
Output: tensor of shape (N, *, L_max, *) | |
""" | |
if not all([t.ndim == tensors[0].ndim for t in tensors]): | |
raise ValueError("All tensors must have the same number of dimension") | |
def check_dims(): |
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 IPython.display import clear_output | |
import time | |
for k in range(10): | |
clear_output(wait=True) | |
print(k) | |
time.sleep(1) |
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 datetime import datetime | |
ts = 1514766600 | |
datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M') # '2018-01-01 00:30' |
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
noise_files = [f for f in os.listdir('../noises/') if f.endswith('.wav')] |
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
class A: | |
class B: | |
def __init__(self): | |
print("init B") | |
super(A.B, self).__init__() | |
def __init__(self): | |
print("init A") | |
super(A, self).__init__() | |
self.b = A.B() |
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 chunks(a, n): | |
for i in range(0, len(a), n): | |
yield a[i:i + n] | |
list(chunks(list(range(52)), 6)) | |
""" Output: | |
[[0, 1, 2, 3, 4, 5], | |
[6, 7, 8, 9, 10, 11], | |
[12, 13, 14, 15, 16, 17], |
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
import time | |
def timestamp(): | |
return time.strftime("%y%m%dd%Hh%Mm%S") |
NewerOlder