Skip to content

Instantly share code, notes, and snippets.

View GoingMyWay's full-sized avatar
🎯
Focusing

GoingMyWay

🎯
Focusing
View GitHub Profile
class Solution:
def __init__(self) -> None:
# count: 3
grid1 = [
[0, 0, 1, 1, 0],
[0, 1, 1, 1, 1],
[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[0, 0, 0, 0, 0],
@GoingMyWay
GoingMyWay / ray_multi.py
Created May 27, 2022 11:42
A simple example to create an Ray actor to run in a loop
import time
import ray
@ray.remote(num_cpus=2)
class C(object):
def __init__(self) -> None:
self.stop = 0
@GoingMyWay
GoingMyWay / install_sc2.sh
Last active October 14, 2021 05:24
install StarCraft II on Linux
if [ -z "$EXP_DIR" ]
then
EXP_DIR=/home/docker/
fi
echo "EXP_DIR: $EXP_DIR"
cd $EXP_DIR
# mkdir 3rdparty
# cd 3rdparty
#!/bin/bash
echo "task: ${1}, to be killed"
ps -ef | grep $1
echo "killing task: ${1}"
for id in `ps -ef | grep $1 | awk ' { print $2 } '`; do kill -9 $id; done
@GoingMyWay
GoingMyWay / dl_iclr_paper.sh
Created January 29, 2021 02:47
Download ICLR 2021 papers
secondString="pdf";
sec="";
while IFS="," read title url; do
nurl=${url/forum/$secondString};
ntitle=${title//[:?^]/_};
wget -O ./papers/21-"${ntitle}".pdf $(echo $nurl | tr -d '\r';) &
done < iclr_papers.csv
@GoingMyWay
GoingMyWay / tb_run
Last active July 26, 2021 03:02
TensorBoard helpful commands
#!/bin/bash
echo "[INFO] Starting running tensorboard from logpath $1"
tensorboard --logdir $1 --host 0.0.0.0
@GoingMyWay
GoingMyWay / showPerUserCPU.sh
Created January 3, 2021 12:22
show per user CPU usage
#!/bin/sh
#
# print total CPU usage in percent of all available users
# but skips the ones with a CPU usage of zero
#
# 1st column: user
# 2nd column: aggregated CPU usage
# 3rd column: normalized CPU usage according to the number of cores
#
# to sort by CPU usage, pipe the output to 'sort -k2 -nr'
@GoingMyWay
GoingMyWay / finding_median.py
Created December 23, 2020 02:59
Median quantile finder
import numpy as np
import torch as th
import torch.nn as nn
import matplotlib.pyplot as plt
from torch.optim import Adam
arr = np.arange(100)
@GoingMyWay
GoingMyWay / iclr_list.py
Last active November 11, 2021 14:07
Get ICLR paper list including titile, url, scores, avg_score and keywords
import argparse
import multiprocessing
import tqdm
import openreview
import pandas as pd
def worker(reviews):
client = openreview.Client(baseurl='https://api.openreview.net', username='', password='')