Windows设置

more ...

描点画图

等距描点画图

\begin{align} \Delta l&=\sqrt{\Delta x^2+\Delta y^2}=C\\ \Rightarrow \Delta x&=\frac{\Delta l}{\sqrt{1+y'^2}} \end{align}

等角描点画图

\begin{align} \theta&=\arctan\frac{\Delta y}{\Delta x}\\ \delta\theta&=C\\ \Rightarrow \Delta x&=\delta\theta\Big/\frac{y''}{1+y'^2} \end …

more ...

Network Programming

IP(Internet Protocal) Address

  • Generally, it is stored(Big endian) in a struct in_addr rather than a scalar value.

    struct in_addr {
      unsigned int s_addr; /* Network byte order (big-endian) */
    };
    
  • To convert endianess between local machine word and in_addr struct, we need functions

    #include <netinet/in.h>
    //Returns: value in network byte …
more ...


Covariant Linear Fit

Aim

Minimize $$\sum_i \mathrm{distance}^2(\vec r_i, \mathrm{line})=\sum_i (\vec r_i\cdot \hat n-\rho)^2$$ for line $\vec r\cdot \hat n-\rho=0$. It is equivalent to

  • The principle axis with least moment of inertia
  • The eigenvector with largest eigenval for the covariance matrix

When is …

more ...


ipynb2pelican Plugin released!

Yet another Pelican Plugin for blogging with Jupyter Notebooks using MetaCell to store metadata.

Thanks to super cow power of python, we can finally publish ipynb easily! Below is the README.md from the project at this time.

The ipynb2pelican plugin provides markup for Jupyter/IPython notebooks in pelican, so …

more ...

Javascript 学习小记

研究了一下Linux平台做笔记的软件,发现为知笔记半死不活,bug很多。其他的笔记程序尝试了leanote等各种软件都感觉难以使用,要么功能太弱,要么没有linux客户端。总计一下我想要的笔记软件的要求:

  • 支持Markdown
    • 支持嵌入代码块的语法高亮
    • 支持latex输入一些基本的数学公式
  • 电脑上使用起来方便
  • 方便用手机查看
  • 方便分享给其他人
  • 软件稳定,无明显BUG,体积小,依赖少

最终我发现了NBViewer+Jupyter Notebook+Github/Gist的组合。

注:现在更倾向于用Jupyter Notebook+Pelican的组合了,参见Blogging with Jupyter and Pelican

  • 存在的问题:刷新麻烦,需要手动加?flush=true
  • 解决方案:UserScript脚本Refresh NBViewer Button。具体请看描述。

为了写这个脚本,特意学习了一点js

基本知识

  • 获取元素的方法demo …
more ...

Jupyter Notebook的配置

默认目录

jupyter notebook --generate-config
vim /home/zpj/.jupyter/jupyter_notebook_config.py#查找dir设定notebook根目录

找到c.NotebookApp.notebook_dir条目,修改为启动jupyter后打开的目录,如/home/zpj/code

配置pylab, matplotlib默认载入

导入库,内联svg输出,需要运行:

%pylab
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

配置ipython

目的

  • 设置pylab环境自动载入
  • 为notebook设置inline显示,使得图片嵌入在文档中
  • 设置矢量svg格式可以使生成的图像在任何屏幕下获得清晰的显示

步骤

创建配置文件

ipython profile create

编辑ipython_config …

more ...