Skip to content

Instantly share code, notes, and snippets.

View priancho's full-sized avatar

Han-Cheol Cho priancho

View GitHub Profile
@priancho
priancho / pyrightconfig.json
Last active August 31, 2022 16:52
VSCode: to run code navigation fast, exclude unnecessary directories from pylance
# Create this pyrightconfig.json at the workspace's root directory.
#
# Refer: https://github.com/microsoft/pyright/issues/168
{
"exclude": ["./data/"]
}
@priancho
priancho / convert.py
Created June 4, 2021 16:06
Convert image format from jp2k to jpeg
""" Convert jp2k image to jpeg.
# Install JPEG2k decoder first
sudo yum install -y libjpeg-devel
"""
import os
import argparse
from pathlib import Path
import cv2
@priancho
priancho / .bash_priancho
Last active December 25, 2020 12:11
.bash_priancho file for WSL2
#-------------------------#
#----- WSL2 settings -----#
#-------------------------#
sudo service docker start
#--------------------------#
#----- Basic settings -----#
#--------------------------#
# Define colors
C_DEFAULT="\[\033[m\]"
@priancho
priancho / HowTo_SshDynamicPortForwarding.md
Last active March 16, 2022 02:00
How to do Dynamic Port Forwarding

Purpose

TensorBoard나 Jupyter notebook은 매우 편리한 도구이나, 적절한 세큐리티 (SSL, Authentication, Authorization 등) 방책이 없이는 사용하기 곤란한 경우가 많다.

여기서는 SSH dynamic port forwarding을 통해서 local computer (노트북, 데스크탑 등)으로부터 remote server (작업용 서버, 주로 회사 컴퓨터) 에서 동작중인 웹기반 어플리케이션에 액세스하는 방법을 설명한다. (물론 remote server의 port에 접근하는 것이므로 웹 기반 앱이 아니어도 됨)

@priancho
priancho / rsync-project.sh
Created August 22, 2019 07:24
rsync backup script template
#!/bin/bash
# replace ${} with real names
PROJECT_NAME=[project name]
USER=[user name]
SRC_SERVER=[hostname having the original data]
SRC_DIR=[path to the original data]
DST_DIR=[path to archive data]
LOG=[path to the log file]
@priancho
priancho / multi_gpu_model_checkpoint.py
Last active March 22, 2019 10:25
Keras ModelCheckpoint callback for multi_gpu_model
class MultiGPUModelCheckpoint(ModelCheckpoint):
"""MultiGPU model checkpointing.
Save a template model, not multi_gpu_model instance.
Save the model at the beginning (a random init model) and at the
end of the training.
> https://github.com/keras-team/keras/issues/8463
"""
def __init__(self, *args, **kwargs):
@priancho
priancho / custom_modelcheckpoint.py
Last active March 22, 2019 06:22
Save the model at the beginning/end of training
class CustomModelCheckpoint(ModelCheckpoint):
"""Custom ModelCheckpoint.
Save the model at the beginning (a random init model) and at the
end of the training.
"""
def __init__(self, *args, **kwargs):
super(CustomModelCheckpoint, self).__init__(*args, **kwargs)
self.current_epoch = 0
@priancho
priancho / jupyter_notebook_config.py
Last active December 28, 2020 16:39
Jupyter Lab config file
# Run the following command to create Jupyter-lab config file under
# ~/.jupyter/jupyter_notebook_config.py
# $ jupyter-lab --generate-config
#
############################
### Some custom settings ###
############################
# Make it accessible from localhost only
@priancho
priancho / py3_main
Created December 19, 2017 09:42
Anaconda Python's Conda environment file
name: py3_main
channels:
- anaconda
- conda-forge
- defaults
dependencies:
- _nb_ext_conf=0.4.0=py36_1
- anaconda-client=1.6.3=py36_0
- beautifulsoup4=4.6.0=py36h49b8c8c_1
- bleach=1.5.0=py36_0
@priancho
priancho / get_amazon_product_data_small.py
Last active October 11, 2017 05:47
Download Amazon Product Data (small version) directly into HDFS.
# Download Amazon Product Data (small version).
# For details, see: http://jmcauley.ucsd.edu/data/amazon/
#
# Caution!
# Before running this download script, create a directiory in
# HDFS to save files. Then, set it in BASE_PATH variable.
#
#---
# Downloading using ipython.