Skip to content

Instantly share code, notes, and snippets.

View dnnagy's full-sized avatar

Nagy Dániel dnnagy

  • Wigner Research Centre for Physics
  • Budapest
  • 19:32 (UTC +02:00)
View GitHub Profile
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" \
# kill all threads where the full command includes 'experiment-18'
ps -axww | grep experiment-18 | grep -v grep | awk '{print $1}' | xargs kill
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]
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():
from IPython.display import clear_output
import time
for k in range(10):
clear_output(wait=True)
print(k)
time.sleep(1)
from datetime import datetime
ts = 1514766600
datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M') # '2018-01-01 00:30'
noise_files = [f for f in os.listdir('../noises/') if f.endswith('.wav')]
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()
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],
import time
def timestamp():
return time.strftime("%y%m%dd%Hh%Mm%S")