Skip to content

Instantly share code, notes, and snippets.

View Kitsunetic's full-sized avatar

Kitsunetic

View GitHub Profile
@Kitsunetic
Kitsunetic / gist:5a93e55bbb4a8a50b7f5db2f988017a1
Created August 11, 2023 13:27
reinstall vscode python extension
import json
import re
import shutil
import subprocess
from pathlib import Path
ext_dir = Path("/root/.vscode-server/extensions")
patterns = [
r"ms-python\.isort-\d{4}\.\d{1,2}\.\d{1,2}",
@Kitsunetic
Kitsunetic / gaussian kernel n-dim.py
Last active October 30, 2022 08:31
gaussian kernel n-dim
import torch as th
def gaussian_filter_nd(dims, r, sig):
grid = th.linspace(-1, 1, r)
grid = th.stack(th.meshgrid([grid for _ in range(dims)], indexing="xy"), dim=-1)
return th.exp(-grid.square().sum(dim=-1) / 2 / sig**2) / ((2 * th.pi)**0.5 * sig) ** dims
import math
import os
import random
import re
import shutil
import time
from collections import OrderedDict
from datetime import datetime
from pathlib import Path
@Kitsunetic
Kitsunetic / pytorch one-hot.py
Created February 8, 2021 14:13
pytorch one-hot
def one_hot(index, classes):
index = index.view(-1, 1)
mask = torch.zeros(index.size(0), classes)
mask.scatter_(1, index, 1.0)
return mask
@Kitsunetic
Kitsunetic / KFold shuffle.ipynb
Last active January 8, 2021 05:43
Compare kfold shuffle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def seed_everything(seed=1234):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
seed_everything()
find *.zip -exec sh -c 'echo $1 | cut -f 1 -d '.'' _ {} \; | xargs -L 1 sh -c 'mkdir $1; unzip $1.zip -d $1' _
@Kitsunetic
Kitsunetic / 차선,차도.ipynb
Last active October 5, 2020 05:11
차선,차도
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kitsunetic
Kitsunetic / activate rc.local on 18.04.md
Created October 2, 2020 11:12
activate rc.local on 18.04

Edit /etc/rc.local

sudo chmod +x /etc/rc.local

Update /lib/systemd/system/rc-local.service

[Service]
Type=forking
@Kitsunetic
Kitsunetic / 우분투 크롬에서 한영전환이 안될 때.md
Last active October 2, 2020 07:34
우분투 크롬에서 한영전환이 안될 때

일반적으로 IBUS로 키보드를 셋팅했을 때, 한영전환을 ALT_R, 한자 전환을 CONTROL_R 로 하는 경우가 많은데, 크롬에서는 이 ALT_R를 한영전환이 아니라 있는 그대로 ALT_R로 받아들이기 때문에 한영전환이 안 되는 것. 왜 크롬이 그렇게 작동하는지는 잘 모르겠다.

해결 방법은 아래 명령어를 실행하면 된다. ALT_R과 CONTROL_R의 키 맵을 변경하는 것.

xmodmap -e "remove mod1 = Alt_R"
xmodmap -e "keycode 0x6c = Hangul"