Skip to content

Instantly share code, notes, and snippets.

@haoliplus
haoliplus / SSH Setting.sh
Last active March 6, 2016 09:15
Add file extension
# generate pub key
ssh-keygen -t rsa
# create folder for key
ssh user@host mkdir -p .ssh
# append pub key
cat .ssh/id_rsa.pub | ssh user@host 'cat >> .ssh/authorized_keys'
@haoliplus
haoliplus / get-filepath.sh
Created March 9, 2016 07:27
get the path of current script.
export FILEPATH=$(cd `dirname $0`; pwd)
@haoliplus
haoliplus / str_cut.sh
Created March 14, 2016 02:27
cut str using shell ${}
var=/path/to/file.tar.gz
${var##*/} # file.tar.gz
${var##*.} # gz
${var#*.} # tar.gz
${var%/*} # /path/to
${var%%.*} #path/to/file.tar
@haoliplus
haoliplus / filepath.sh
Created March 14, 2016 02:28
get file path or dir path using dirname and basename
var=/path/to/file.postfix
$(basename $var) # file.postfix
$(basename $var .postfix) # file
$(dirname $var) /path/to
@haoliplus
haoliplus / get-filepath.sh
Created March 14, 2016 02:28
get dir path in a script
export FILEPATH=$(cd `dirname $0`; pwd)
@haoliplus
haoliplus / hex-bin-dec-oct.py
Created April 6, 2016 14:58
hex, bin, oct, dec convert to each other
a = 0b101 # a = 5
a = 0xf # a = 15
a = 010 # a = 9
# to dec
int('0xf', 16) # 15
int('1011', 2) # 11
int('17', 8) # 15
# to hex
@haoliplus
haoliplus / plot.py
Created May 13, 2016 07:00
Using matplotllib to plot
import matplotlib
# if your environment has no desktop.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# A scatter map.
plt.figure(figsize=(width,height))
plt.scatter(x,y)
plt.show
plt.savefig('scatter.png')
@haoliplus
haoliplus / CaffeModel.py
Created May 13, 2016 07:01
Using Caffe model to predict
#! /usr/bin/env python
#################################################################################
# File Name : test-one.py
# Created By : Hao Li
# Creation Date : [2016-04-08 13:44]
# Last Modified : [2016-04-26 22:24]
# Description :
#################################################################################
import os
@haoliplus
haoliplus / MxNetModel.py
Created May 13, 2016 07:01
Using Mxnet model to predict
#! /usr/bin/env python
#################################################################################
# File Name : test-one.py
# Created By : Hao Li
# Creation Date : [2016-04-08 13:44]
# Last Modified : [2016-04-26 13:49]
# Description :
#################################################################################
import os
@haoliplus
haoliplus / PurineModel.py
Created May 13, 2016 07:02
Using Purine model to predict
#! /usr/bin/env python
#################################################################################
# File Name : PlateModel.py
# Created By : Hao Li
# Creation Date : [2016-04-19 16:27]
# Last Modified : [2016-04-23 15:17]
# Description :
#################################################################################
from pymongo import MongoClient
import os