Skip to content

Instantly share code, notes, and snippets.

View leimingyu's full-sized avatar

Leiming Yu leimingyu

View GitHub Profile
@leimingyu
leimingyu / min-char-rnn.py
Created March 8, 2017 20:15 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@leimingyu
leimingyu / user_home_usage.sh
Last active May 7, 2017 00:38
Find out the disk usage for each Linux user
#!/bin/bash
if [ -f /tmp/user_log ]; then
rm -rf /tmp/user_log
fi
touch /tmp/user_log
for user in `ls /home`; do
link=/home/$user
@leimingyu
leimingyu / knn_sklearn.py
Created May 8, 2017 03:36
select the nearest neighbor using knn in sklearn
# http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
from sklearn.neighbors import KNeighborsClassifier
# We could use knn to select the best kernel configuration from the kernel pool (training kernels)
# the input X are metrics from the training kernels
X= [[0.841509434,0.699166,0.845695,0,0.1,0.156,0.967049],
[0.749356223,1.611461,0.736916,0,0.2,0.3741,2.693249],
[0.263510732,0.433383,0.130578,0,0.05,0.0897,0.451053],
@leimingyu
leimingyu / gpu_opt_tricks.md
Last active November 6, 2018 12:22
gpu optimization tricks
@leimingyu
leimingyu / iterate_dir_in_bash
Created October 3, 2017 18:48
iterate_dir_in_bash.sh
#!/bin/bash
cd apps
for currDir in *
do
#echo $currDir
if [ -d $currDir ]; then
# check whether it is the targeted folder
if [ "$currDir" != "bfs" ] && \
[ "$currDir" != "pta" ] && \
@leimingyu
leimingyu / update_forked_repo.md
Last active November 12, 2017 00:36
Update a forked repo with remote upstream
@leimingyu
leimingyu / gist:f465795f3b8ec232295c2b4f9eac78d2
Created October 28, 2017 01:33 — forked from rygorous/gist:2156668
float->half variants
// float->half variants.
// by Fabian "ryg" Giesen.
//
// I hereby place this code in the public domain, as per the terms of the
// CC0 license:
//
// https://creativecommons.org/publicdomain/zero/1.0/
//
// float_to_half_full: This is basically the ISPC stdlib code, except
// I preserve the sign of NaNs (any good reason not to?)
@leimingyu
leimingyu / makefile_notes.md
Last active November 24, 2017 15:30
makefile note

print hostname in makefile

host_name := $(shell hostname -s)                                               
$(info Host Name $(host_name)) 

set up env variable using if-else

ifeq ($(host_name),mcx1)                                                        
CUDA_PATH ?= /pub/cuda-8.0 
@leimingyu
leimingyu / kill_target_ps.md
Last active November 29, 2017 17:11
list process and kill the target pid
ps aux | grep rCUDA  | tee -a rcuda_ps
pids=`awk -F " " '{print $2}' rcuda_ps`
for i in "${pids[@]}"; do kill -9 $i; done
@leimingyu
leimingyu / client.py
Created December 11, 2017 02:08 — forked from micktwomey/client.py
python multiprocessing socket server example
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()