Skip to content

Instantly share code, notes, and snippets.

View frankchen0130's full-sized avatar

Frank Chen frankchen0130

View GitHub Profile
@frankchen0130
frankchen0130 / killwine
Created September 21, 2016 12:42
This script is for killing all the wine exe applications.
#!/bin/sh
#kill all exe proc
ps -A | grep exe > tmp.txt
i=1
while read line
do
echo Killing `echo $line |awk '{printf("%s\n",$4)}'`
kill `echo $line |awk '{printf("%s\n",$1)}'`
done < tmp.txt
@frankchen0130
frankchen0130 / DataFrame过滤不满足条件的元素
Created September 29, 2016 23:37
DataFrame过滤不满足条件的元素
df1 = DataFrame(np.random.randn(10, 4), columns=['a', 'b', 'c', 'd'])
mask = df1.applymap(lambda x: x <-0.7)
df1 = df1[-mask.any(axis=1)]
sLength = len(df1['a'])
e = Series(np.random.randn(sLength))
@frankchen0130
frankchen0130 / .gitignore
Created March 19, 2017 06:42
重复添加.gitignore文件
If you want add to ignore some directories in your local repository (which already exist) after editing .gitignore you want to run this on your root dir
```
git rm --cached -r .
git add .
```
@frankchen0130
frankchen0130 / format_time.py
Last active July 15, 2017 06:43
format time in python
import time
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
# >> '2017-07-15 14:39:54'
@frankchen0130
frankchen0130 / tracker.py
Created August 3, 2017 08:07
tracker if thrift process running in JPS, if not restart it
# -*- coding:utf8 -*-
# Created by frank at 15/07/2017
"""
███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
████╗ ██║██╔═══██╗██╔══██╗██║ ██║██╔════╝
██╔██╗ ██║██║ ██║██████╔╝██║ ██║██║ ███╗
██║╚██╗██║██║ ██║██╔══██╗██║ ██║██║ ██║
██║ ╚████║╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝
╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝
@frankchen0130
frankchen0130 / service.conf
Created August 3, 2017 08:10
supervisord config template
[program:service]
;directory = ~/su/ ; 程序的启动目录
command = /root/miniconda3/bin/python /root/project/service/run.py ; 启动命令,可以看出与手动在命令行启动的命令是一样的,注意这里home不可用~代替
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
user = root ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
@frankchen0130
frankchen0130 / fuck.sh
Created August 7, 2017 07:45
Tar all the .tgz or .tar.gz files of local dir to /usr/local/.
#!/bin/bash
for file in $( ls ); do
echo item: $file
if [[ ( $file == *.tgz ) || ( $file == *.tar.gz ) ]]; then
tar xzvf $file -C /usr/local/
fi
done
@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/
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 / 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))