Start 2019

© 2018 All rights reserved by liudx .:smile:

==No body can live without H~2~0 and knowledge==

1 Tools

  • MicroSoft® VScode用来写前端代码,推荐安装插件Markdown All in One写文档,Preview用于预览HTML;SublimeText Keymap用于替换vscode的快捷键
  • listary和everything一样,是一个强大的windows快速本地搜索工具
  • ripgrep是windows下的grep命令行工具,使用方法:rg textor rg --maxdepth 1 text
  • systemd:systemctl hostnamectl loginctl ref

2 Python

Python:第三方库:scipy,matplotlib,fabric(remote batch),requests(network)

  • pip upgrade: $Python\Scripts\easy_install.exe pip==8.1.2,修改国内源:新建文件C:\Users\Admin\pip\pip.ini:

    1
    2
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
  • Jupyter notebook:用于交互式编写python脚本,支持markdown语法,安装方法$pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple

  • 启动jupyter notebook --no-browser,访问 http://localhost:8888

  • new python3 notebook,save as *.ipynb file

    • %magic支持魔术命令如 %run script.py=!python script.py
    • 引用系统命令eg:!echo %cd%

3 Hexo^1

A blog system^2, recommand nexT theme, if you want to suppoer letax, modify next/_config.yml:mathjax

4 Typora ♥

The best markdown editor.


  • 修改行宽度_@C:\Users\ADMIN\AppData\Roaming\Typora\themes\newsprint.css ==max-width: 1920px;==}

Draw graph example:

  • flow

    1
    2
    3
    4
    5
    6
    7
    8
    9
    st=>start: 开始框
    op=>operation: 处理框
    cond=>condition: 判断框(是或否?)
    sub1=>subroutine: 子流程
    io=>inputoutput: 输入输出框
    e=>end: 结束框
    st->op->cond
    cond(yes)->io->e
    cond(no)->sub1(right)->op
  • mermaid ^

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    graph TB

    subgraph *开源代码协议*
    open_source[他人修改源码后 <br/> 是否可以闭源?]-- no -->add_with_same_lic[新增代码是否<br/>采用同样许可证?]
    open_source-- yes -->mod_with_lic[每一个修改过的文件<br>是否都必须</br>放置版权说明?]
    add_with_same_lic--no-->mod_need_doc[是否需要对源码的<br>修改之处,</br>提供说明文档?]
    mod_need_doc--no-->LGPL(LGPL许可证)
    mod_need_doc--yes-->Moz(Mozilla许可证)
    add_with_same_lic--yes-->GPL(GPL许可证)
    mod_with_lic--no-->sale_with_ownname[衍生软件的广告是否可以<br/>使用你的名字促销?]
    sale_with_ownname--no-->BSD(BSD许可证)
    sale_with_ownname--yes-->MIT(MIT许可证)
    mod_with_lic--yes-->Apache(Apache许可证)
    end

    %% Notice following class def
    classDef green fill:#9f6,stroke:#333,stroke-width:2px;
    classDef orange fill:#f96,stroke:#333,stroke-width:4px;
    class open_source,add_with_same_lic,mod_with_lic,mod_need_doc,sale_with_ownname green
    class LGPL,Moz,GPL,BSD,MIT,Apache orange
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des2, 7d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :after des3,2d
Add to mermaid :1d

5 $\LaTeX$ Code

1. 二次方程求根公式:

$$
x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
$$

2. 三角和公式:

$$
\sin(\alpha+\beta) = \sin(\alpha)\cdot\cos(\beta)+\cos(\alpha)\cdot\sin(\beta)
$$

​ 简单证明如下:

​ 平面上两个单位向量,与x轴正向夹角分别为$x$和$y$,则这两个向量分别为$\vec{\alpha}(\cos x,\sin x),\quad\vec{\beta}(\cos y,\sin y)$。则这两个向量的点积为$\cos x\cos y+\sin x\sin y$,而点积又可以表示为$|\vec{\alpha}|\cdot|\vec{\beta}|\cdot\cos|x-y|=\cos(x-y)$,于是我们得到了以下公式:

$$
\cos(x-y)=\cos x\cos y+\sin x\sin y \quad\quad (1)
$$
​ 将(1)中的$\boldsymbol{y}$换成$\boldsymbol{-y}$得到:

$$
\cos(x+y)=\cos x\cos y-\sin x\sin y \quad\quad(2)
$$
​ 将(1)中的$\boldsymbol{x}$用$\frac{\pi}{2} -x$代入,得到:

$$
\sin(x+y)=\sin x\cos y+\sin y\cos x\quad\quad(3)
$$
​ 将(3)中的$\boldsymbol{y}$用$\boldsymbol{-y}$代入,得到:

$$
\sin(x-y)=\cos y\sin x-\cos x\sin y\quad\quad(4)
$$

3. 欧拉公式\棣莫弗公式:

$$
z = r\cdot e^{2\pi i},\quad e^{ix}=cosx+isinx \to e^{i\pi}+1=0\\
de\space Moivre’s\space Formula: (cos(x)+isin(x))^n=cos(nx)+isin(nx) = e^{i(nx)},x \in C,n \in R
$$

4. 常用公式:

$$
复数域C;实数域R;有理数域Q \
自然常数:e =\lim_{x\to \infty}(1+1/x)^x,e^x =1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\dots\\
欧拉定理: a^{\psi(n)}\equiv 1\space mod(n),(\psi(n)欧拉函数为小于n的素数个数);特别有a^{p-1}\equiv 1\space mod(p),当p为素数,a>2\\
正太分布(高斯分布,probability\space density\space function):p(x|\mu,\sigma^2)=\frac{1}{\sqrt{2\pi}\sigma}e^{\dfrac{-(x-\mu)^2}{2\sigma^2}}\\
概率分布(或称CDF:累积分布,cumulative\space distribution\space function):F_X(a) = P(x\le a)\\
傅里叶变换:\hat{f}(\xi)=\int_{-\infty}^{\infty}{f(x)e^{-2\pi ix \xi}}dx,\xi \in R\\
fourier逆变换:{f}(x)=\int_{-\infty}^{\infty}{\hat{f}(\xi)e^{2\pi i\xi x}}d\xi, x \in R\\
离散傅里叶变换(DFT):X_k=\sum_{n=0}^{N-1}x_ne^{-i2\pi k\dfrac{n}{N}},k=0,1\dots,N-1,x_n \in C.\\
离散余弦变换(DCT-II):f_m=\sum_{k=0}^{n-1}x_kcos\Big[\dfrac{\pi}{n}m(k+\frac{1}{2})\Big],k=0,1\dots,N-1,x_n \in C.\\
Gamma function:\Gamma (x)=\int_{0}^{\infty}t^{x-1}e^{-t}dt = (x-1)!\\
Beta Function:B(x,y)=\dfrac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}=\int_{0}^{1}{t^x(1-t)^y}dt
$$

5. 积分\求导More Basical Equation

$$
Dirak\space function:\delta(x)=\begin{cases}
0,x=0 \\
\infty,x \neq 0\end{cases} \quad s.t.\int_{-\infty}^{\infty}{\delta(x)}dx = 1 \\
Hooke\space theroy:F=-kx=\dfrac {dx^2}{dt^2}
$$

6. fibonacci若干性质

$$
f(n)=f(n+1)-f(n-1)\\
f(n)=[f(n+1)+f(n-2)]/2\\
\sum_{i=1}^{n}{f^2(i)}=f(n)\cdot f(n-1)\\
\lim_{x\to\infty}\frac{f(n)}{f(n+1)}=\frac{1-\sqrt{5}}{2}\approx 0.618
$$

7.MATRIX

​ 假设单位向量$\overrightarrow{u}坐标为(\sin x,\cos x)$,旋转$\theta$后变为向量$\overrightarrow{u’}坐标为(\sin y,\cos y)$,由内积和外积定义可得:

$$
\overrightarrow{u}\cdot\overrightarrow{u’} = \cos \theta = \cos x \cos y + \sin x \sin y \quad\quad(5)\\
\overrightarrow{u}\times\overrightarrow{u’}=\sin \theta =
\begin{vmatrix}
i & j & k\\
\cos x & \sin x &0\\
\cos y & \sin y &0\\
\end{vmatrix}=
\cos x \sin y - \sin x \cos y \quad\quad(6)
$$
​ 另有

$$
\sin^2 \theta + \cos^2 \theta = 1\quad\quad(7)
$$

​ 由$(5)\cdot \sin x +(6)\cdot \cos x解得\sin y$;由$(5)\cdot \cos x -(6)\cdot \sin x解得\cos y$:
$$
\begin{cases}
\sin y = \sin x\cdot\cos\theta+ \cos x\cdot \sin \theta\\
\cos y = \cos x\cdot\cos\theta-\sin x\cdot\sin\theta
\end{cases}
$$
​ 即2维旋转矩阵(S2):

$$
\begin{pmatrix} \cos y\\ \sin y \end{pmatrix}=\begin{vmatrix}
\cos\theta & -\sin\theta\\
\sin\theta & \cos\theta\\
\end{vmatrix}\cdot
\begin{pmatrix} \cos x\\ \sin x \end{pmatrix}\quad(8)
$$
​ 同理可得三维旋转矩阵(S3)为:

$$
R_x(\omega)=\begin{bmatrix}
1 & 0 & 0\\
0 & cos\omega & -sin\omega\\
0 & sin\omega & cos\omega\\
\end{bmatrix},
R_y(\phi)=\begin{bmatrix}
cos\phi &0 & -sin\phi\\
0 & 1 & 0 \\
sin\phi &0 & cos\phi\\
\end{bmatrix},
R_z(\kappa)=\begin{bmatrix}
cos\kappa & -sin\kappa &0\\
sin\kappa & cos\kappa &0\\
0 &0 &1 \\
\end{bmatrix}\\
R=R_z(\kappa)\cdot R_y(\phi)\cdot R_x(\omega) = \begin{bmatrix}
cosϕ⋅cosκ& −cosϕ⋅sinκ&sinϕ\\
cosω⋅sinκ+sinω⋅sinϕ⋅cosκ & cosω⋅cosκ−sinω⋅sinϕ⋅sinκ &−sinω⋅cosϕ \\
sinω⋅sinκ−cosω⋅sinϕ⋅cosκ & sinω⋅cosκ+cosω⋅sinϕcdotsinκ &cosω⋅cosϕ\end{bmatrix}
$$

8. Riemann Function (Zeta)

$$
\zeta(s) = \sum_0^\infty \frac{1}{n^s}, s \in R\space and\space Real(s) > 1\\
specially,\zeta(2) = \frac{\pi^2}{6}
$$

9.系统可靠性(Realibality)

$$
可靠度R=\begin{cases}R=\prod_i^nR_i,串联系统\\R=\prod_i^n(1-R_i),并联系统\end{cases}
$$
失效率$\lambda$与可靠度R关系为:
$$
R=e^{-\lambda t}
$$

10. Amdahl定律

$$
F = \frac{1}{1-F_e + F_e/S},其中Fe为子系统占比,S为加速倍数,计算整个系统提升百分比
$$



参考markdown文档链接^3,Markdown使用LeTax书写数学公式^4:

其他待办事项: