Skip to content

Instantly share code, notes, and snippets.

View dongkwan-kim's full-sized avatar
🎯
Focusing

Dongkwan Kim dongkwan-kim

🎯
Focusing
View GitHub Profile
@dongkwan-kim
dongkwan-kim / ordinal.py
Created November 20, 2017 05:53
Make cardinal number to ordinal number in python3
import math
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4])
# source: https://stackoverflow.com/questions/9647202/ordinal-numbers-replacement
from selenium import webdriver
from time import sleep
import csv
def run_driver(path):
driver = webdriver.Chrome(path)
driver.implicitly_wait(3)
return driver
def get_site(driver, url):
function getArray(s) {
var arr = s.split(/(\s+)/).filter((e) => {
return e.trim().length > 0;
});
return arr;
}
@dongkwan-kim
dongkwan-kim / moreThan800.js
Last active October 5, 2018 15:41
More than 800
$(function(){
$(".textarea").off("keyup");
$('.textarea').keyup(function () {
// 입력한 값을 구합니다.
var input = $(this).val();
// 남은 글자 수를 구합니다.
var inputlength = $(this).val().length;
// 문서 객체에 입력합니다.
$('.length').html(inputlength);
});
@dongkwan-kim
dongkwan-kim / nvidia_docker_setup.sh
Last active August 7, 2024 03:40
nvidia docker setup in remote server accessible by ssh
# In the server, (images what I mostly used)
docker pull nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04
# cuda 10.0 multiple ports volume binding
docker run -ti --runtime=nvidia --name dongkwan -p 8082:22 -p 8083:6006 --ipc=host -v /mnt/nas2:/mnt/nas2 -d nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04 /bin/bash
# Unknown runtime specified nvidia
docker run -ti --gpus '"device=0,1,2,3"' --name dongkwan -p 8070:22 --ipc=host -d nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04 /bin/bash
# For volume
docker volume create volume_name
from utils import *
params = {}
def create_variable(scope, name, shape, trainable=True, on_cpu=True, **kwargs) -> tf.Variable:
def _create_variable():
with tf.variable_scope(scope):
_w = tf.get_variable(name, shape, trainable=trainable, **kwargs)
params[_w.name] = _w
# https://github.com/golbin/TensorFlow-Tutorials/blob/master/06%20-%20MNIST/01%20-%20MNIST.py
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("./mnist/data/", one_hot=True)
X = tf.placeholder(tf.float32, [None, 784])
Y = tf.placeholder(tf.float32, [None, 10])
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv
ps all --sort=-time | grep python
python -u analysis.py | tee log.txt
ps aux | grep -ie "query" | awk '{print $2}' | xargs kill -9
%%%%% NEW MATH DEFINITIONS %%%%%
\usepackage{amsmath,amsfonts,bm}
% Mark sections of captions for referring to divisions of figures
\newcommand{\figleft}{{\em (Left)}}
\newcommand{\figcenter}{{\em (Center)}}
\newcommand{\figright}{{\em (Right)}}
\newcommand{\figtop}{{\em (Top)}}
\newcommand{\figbottom}{{\em (Bottom)}}