zzp's blog


  • 首页

  • 分类

  • 归档

  • 搜索

grafana-monitoring

发表于 2018-12-13 | 分类于 linux | 阅读次数

https://grafana.com/

http://docs.grafana.org/installation/debian/

1
2
sudo service grafana-server start
# localhost:3000/

linux利用split命令分割压缩文件

发表于 2018-10-11 | 分类于 linux | 阅读次数

分割压缩文件

1
2
# 以10M大小分割文件
split -b 10m filename.tar.gz filename.tar.gz.

会生成子文件如下

  • filename.tar.gz.aa
  • filename.tar.gz.ab
  • filename.tar.gz.ac
    …

合并压缩文件

1
2
cat filename.tar.gz.a* > filename.tar.gz
cat filename.tar.gz.a* | tar zxvf

pyexcel处理excel文件

发表于 2018-09-19 | 分类于 python | 阅读次数

GitHub - pyexcel/pyexcel: Single API for reading, manipulating and writing data in csv, ods, xls, xlsx and xlsm files

install

1
pip install pyexcel pyexcel-xlsx

merge csv into xlsx

1
2
3
4
from pyexcel.cookbook import merge_all_to_a_book
import glob

merge_all_to_a_book(glob.glob("your_csv_directory/*.csv"), "output.xlsx")

ubuntu-dev-usb-mount

发表于 2018-09-16 | 分类于 linux | 阅读次数

检查挂载硬盘信息

1
cat /proc/partitions

检查硬盘的文件系统格式

1
fdisk -l /dev/sdb

挂载位置

1
mount -t ?? /dev/sdb /media

ntfs 修复

1
2
sudo apt-get install ntfs-3g
ntfsfix /dev/sdd3

开机自动挂载

配合”磁盘”软件,设置

1
/etc/fstab

分区

1
2
/dev/sda1 /boot 1G
/dev/sda3 /home 500G

PyQt5-eric6-ubuntu

发表于 2018-09-16 | 分类于 python | 阅读次数

安装环境

install qt5

ubuntu默认已经装了qt5, 但是缺少组件(designer等)

1
2
# (全平台完整下载链接) http://download.qt.io/archive/qt/
sudo apt install qttools5-dev-tools

install QScintilla and PyQt5

1
sudo pip3 install QScintilla PyQt5 PyQt5-sip

install eric6

eric-ide installer

1
2
cd eric6-18.12/
sudo python3 install.py

教程,例子

PyQt5 Reference Guide — PyQt 5.11.1 Reference Guide

用 eric6 与 PyQt5 实现python的极速GUI编程(系列01)–Hello world! - 罗兵 - 博客园

linux: sed

发表于 2018-09-11 | 分类于 linux | 阅读次数

sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。

阅读全文 »

sys.platform python运行平台

发表于 2018-09-10 | 分类于 python | 阅读次数
平台 值
Linux (2.x and 3.x) ‘linux2’
Windows ‘win32’
Windows/Cygwin ‘cygwin’
Mac OS X ‘darwin’
OS/2 ‘os2’
OS/2 EMX ‘os2emx’
RiscOS ‘riscos’
AtheOS ‘atheos’
阅读全文 »

scipy tricks

发表于 2018-09-10 | 分类于 python | 阅读次数

排列组合数

1
2
from scipy.misc import comb
comb(N, k, exact=False, repetition=False)

最优化相关

Optimization and root finding (scipy.optimize) — SciPy v0.18.1 Reference Guide

from scipy.optimize import leastsq

Minimize the sum of squares of a set of equations.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
###最小二乘法试验###
import numpy as np
from scipy.optimize import leastsq

###采样点(Xi,Yi)###
Xi=np.array([8.19,2.72,6.39,8.71,4.7,2.66,3.78])
Yi=np.array([7.01,2.78,6.47,6.71,4.1,4.23,4.05])

###需要拟合的函数func及误差error###
def func(p,x):
k,b=p
return k*x+b

def error(p,x,y,s):
print s
return func(p,x)-y #x、y都是列表,故返回值也是个列表

#TEST
p0=[100,2]
#print( error(p0,Xi,Yi) )

###主函数从此开始###
s="Test the number of iteration" #试验最小二乘法函数leastsq得调用几次error函数才能找到使得均方误差之和最小的k、b
Para=leastsq(error,p0,args=(Xi,Yi,s)) #把error函数中除了p以外的参数打包到args中
k,b=Para[0]
print"k=",k,'\n',"b=",b

###绘图,看拟合效果###
import matplotlib.pyplot as plt

plt.figure(figsize=(8,6))
plt.scatter(Xi,Yi,color="red",label="Sample Point",linewidth=3) #画样本点
x=np.linspace(0,10,1000)
y=k*x+b
plt.plot(x,y,color="orange",label="Fitting Line",linewidth=2) #画拟合直线
plt.legend()
plt.show()

from scipy.optimize import linprog

1
2
3
4
5
6
7
8
Minimize a linear objective function subject to linear equality and inequality constraints.

Linear Programming is intended to solve the following problem form:
Minimize:
c^T * x
Subject to:
A_ub * x <= b_ub
A_eq * x == b_eq

from scipy.optimize import minimize

Minimization of scalar function of one or more variables.

In general, the optimization problems are of the form:

minimize f(x) subject to

1
2
g_i(x) >= 0,  i = 1,...,m
h_j(x) = 0, j = 1,...,p

where x is a vector of one or more variables. g_i(x) are the inequality constraints. h_j(x) are the equality constrains.

Optionally, the lower and upper bounds for each element in x can also be specified using the bounds argument.

hexo-scripts

发表于 2018-09-08 | 分类于 trick | 阅读次数

针对hexo-next搭建的博客,写了几个方便操作的脚本:

  • new.sh: 任意目录新建带模板的md文件
  • post.sh: 任意目录post+deploy
  • backup.sh: 备份博客,以便日后迁移
阅读全文 »

wget 递归爬取网页

发表于 2018-09-07 | 分类于 linux | 阅读次数

wget 递归爬取网站并存在本地

1
2
3
4
5
6
7
8
wget -L 仅跟踪相对链接
wget -r -p -np -k

# exclude directories
wget -c -r -p -np -k -X /class/cs224n/reports,/class/cs224n/archive http://web.stanford.edu/class/cs224n/syllabus.html

# reject-regex
wget -c -r -p -np -k --reject-regex="/proj*" http://cs229.stanford.edu/syllabus.html
1234…9
ningning

ningning

86 日志
9 分类
GitHub
© 2018 - 2020 ningning
本站访客数 人次