Skip to content

Instantly share code, notes, and snippets.

View frankchen0130's full-sized avatar

Frank Chen frankchen0130

View GitHub Profile
payload:
- '136.22.64.0/24'
- '136.22.65.0/24'
- '136.22.67.0/24'
- '136.22.76.0/24'
- '136.22.83.0/24'
- '136.22.85.0/24'
- '136.22.86.0/24'
- '136.22.87.0/24'
- '136.22.92.0/24'
@frankchen0130
frankchen0130 / win_mac_path_conversion.sh
Last active December 24, 2021 03:57
windows mac path conversion
# When two people using the windows system and the macos system want to access the location on the same NAS system, they often face the need to convert the windows system path and the macos system path. This gist is made for this function.
# For example
# Mac mount address is
# /Volumes/SERVER/Design/F16/
# The Windows mount address is
# \\Jashen-nas\server\Design\F16\
@frankchen0130
frankchen0130 / pd_pipes.py
Created January 17, 2018 06:05
pandas pipe examples
def pipe_basic_fillna(df=combined):
local_ntrain = ntrain
pre_combined=df.copy()
#print("The input train dimension:\t", pre_combined[0:ntrain].shape)
#print("The input test dimension:\t", pre_combined[ntrain:].drop("SalePrice",axis=1).shape)
num_cols = pre_combined.drop(["Id","SalePrice"],axis=1).select_dtypes(include=[np.number]).columns
cat_cols = pre_combined.select_dtypes(include=[np.object]).columns
@frankchen0130
frankchen0130 / plot_model.py
Created December 18, 2017 11:47
keras: plot model to png image file
from keras.utils import plot_model
plot_model(happyModel, to_file='HappyModel.png')
@frankchen0130
frankchen0130 / calculateRealInterest.py
Created December 11, 2017 06:12
计算分期还款的实际利率
def calculateRealInterest(amount, months, percentPerMonth):
interestAmount = amount * percentPerMonth / 100 * months; #总手续费
amountPermonth = amount / months; #每期占用银行金额
occupyMonths = (1 + months) * (months / 2); #总占用月数
occupyYears = occupyMonths / 12; #占用年数
occupyAmountForOneYear = amountPermonth * occupyYears; #相当于占用了一年的金额
@frankchen0130
frankchen0130 / Cluster.sh
Created October 31, 2017 08:16
One Key Script for Start & Stop Spark on Yarn Cluster
#!/bin/sh
if [ $1 == "start" ]
then
echo "do start"
# hdfs&yarn
/usr/local/hadoop/sbin/start-all.sh
# spark
/usr/local/spark/sbin/start-all.sh
ab \
-p /Users/frank/Desktop/test.json\
-T application/json \
-c 10 \
-n 2000 \
http://datalab:5000/api/GetSimi
@frankchen0130
frankchen0130 / safe_use_local_directory.py
Last active August 18, 2017 07:27
A way to add local directory files, prevent error when import module from other places.
_get_module_path = lambda path: os.path.normpath(os.path.join(os.getcwd(),
os.path.dirname(__file__), path))
vim *.cpp
qx # start recording to register x
:%s/OldString/NewString/g
:wnext
q # stop recording
@x # playback to see if it works correctly
999@x # repeat 999 times to complete the job
@frankchen0130
frankchen0130 / rsync.sh
Last active August 14, 2017 03:07
copy file from remote server exclude come files or directories.
rsync -rav -e ssh --exclude 'word2vec-1/*' --exclude '.git/*' --exclude '*.pyc' --exclude '*nohup.out*' root@datalab2:~/project/service_test/ ./service/