8月 31

rust学习初步

算法还是使用http://www.simonzhang.net/?p=2789。

study.rs

fn check(n:u64) -> bool{
    let ll = n.to_string().len();
    let cc = String::from(n.to_string());
    let mut nn1 = 0;
    let mut nn2 = ll-1;
    while nn1 < ll{
        if cc.chars().nth(nn1) != cc.chars().nth(nn2){
            return false;
        }
        if nn2 == 0{
            break;
        }
        nn1 += 1;
        nn2 -= 1;
    }
    return true;
}

fn main() {
    let x:u64 = 10;
    let y = x.pow(7);
    let mut i = 0;
    while i <= y {
        if check(i){
            if check(i*i){
                println!("{} {}", i, i*i)
            }
        }
        i+=1;
    }
}

cargo.toml

[profile.release]
lto = true
codegen-units = 1

使用UPX -9 压缩后400k,执行1秒以内。

6月 02

echarts 在图片上做标注

主要思路:1、先有背景图,2、有刻度,3、隐藏X、Y轴显示,4、隐藏直线显示,5、进行标注。使用echarts实现,代码如下

var img = new Image(); //新建对象
img.src="http://pic.sc.chinaz.com/files/pic/pic9/201708/zzpic6006.jpg";

option = {
    // 背景
    backgroundColor: {
        type: "pattern",
        repeat: "repeat",
        image: img,
    },
    title: {
        text:"XXXXX"
    },
    xAxis: {
        show : false,
        data: [1,2,3,4,5,6,7,8,9]
    },
    yAxis: {
        show : false,
    },
    series: [{
        type:"line",
        data: [1,2,3,4,5,6,7,8,9],
        //隐藏直线
        showSymbol: false,
        lineStyle: {
            width: 0,
            color: 'rgba(0, 0, 0, 0)'
        },
        // 标注气泡
        markPoint: {
                data: [
                    {name: 'y', value:"嘴", xAxis:3, yAxis: 1.5},
                    {name: 'z', value:"眼睛", xAxis: 1, yAxis: 6},
                ]
            },
        },
    ]
};

随便找了张图片,效果如下:

10月 02

防火墙中”connection state”与“tcp Flags” 理解学习

“connection state”译为链接状态。于协议无关,可以是TCP、UDP、DNS各种协议的连接状态。不同的业务又有相应的协议做支撑。
如TCP协议,发送报文与设备进行协议交互,确认本协议可以完成协议链接、发送命令、传输数据的工作。

“connection state”链接状态

 new:  连接中的第一个包。
 established:  连接已经成功,开始发送命令,传输数据。
 related:  established进行中,需要增加业务的连接包。
 invalid:  没有状态,没有被识别的报文。
 untracked:  无法找到相关报文,未被追踪。

TCP协议

F : FIN - 结束; 结束会话
S : SYN - 同步; 表示开始会话请求
R : RST - 复位;中断一个连接
P : PUSH - 推送; 数据包立即发送
A : ACK - 应答
U : URG - 紧急
E : ECE - 显式拥塞提醒回应
W : CWR - 拥塞窗口减少

参考学习:
http://www.zsythink.net/archives/1597
https://blog.csdn.net/hunanchenxingyu/article/details/26577201

11月 16

vim插件安装

“git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
“vim +PluginInstall +qall

"git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
"vim +PluginInstall +qall
set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'git://git.wincent.com/command-t.git'
Plugin 'file:///home/gmarik/path/to/plugin'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'ascenator/L9', {'name': 'newL9'}
call vundle#end()            " required
filetype plugin indent on    " required
Plugin 'flazz/vim-colorschemes'
Plugin 'vim-scripts/pep8'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Lokaltog/vim-powerline'