• go get files recursively using glob?

    golang官方的glob不能支持**代表递归
    https://github.com/golang/go/issues/11862
    https://github.com/driskell/log-courier/issues/285

    mattn给了一个他自己写的第三方库https://github.com/mattn/go-zglob

  • 在mac系统vim中绑定command键

    只能在macvim中, 才能对commnad组合键做映射. 就是command+c

    因为在CLI中, commnad键会被iterm/terminal等终端应用截获. Option也是需要一些额外的办法才能使用, 而且会有负作用.也是需要一些额外的办法才能使用.

    参考http://stackoverflow.com/questions/9450905/how-to-bind-vim-through-tmux-to-cmd-key/9451636#9451636

  • 今日单词

    discrete

    Breaking this down into discrete steps

    /dɪˈskriːt; dɪ`skrit/

    adj eparate; distinct 分离的; 截然分开的

    discrete particles

    a series of discrete events

  • 今日单词

    rapidity

    Things are happening with machine-gun rapidity: Brexit, the Turkish coup, Islamist massacres in France, the surrounding of Aleppo, the nomination of Donald Trump.

    /rəˈpɪdətɪ; rə`pɪdətɪ/

    n[U] 迅速 湍急

    with great rapidity

  • mesos scheduler与master通讯

    用的是http, 但是需要长链接. 服务器返回“200 OK” status code with Transfer-Encoding: chunked.
    所以如果一个Http库只能在链接close之后才解释, 这样的库不能用.

    因为接下来的通讯需要用另外一个链接,我们叫做第二个链接. master收到请求后, 对第二个链接回复202. 然后把真正的响应回复到第一个长链接中.

  • go-unpacking-array-as-arguments

    command := strings.Split("service nginx reload")
    cmd := exec.Command(command[0], command[1:]...)
    err := cmd.Run()
    
  • golang中select是同步的

    	glog.Info(data)
    	select {
    	case zevent := <-watch:
    		glog.Info(zevent)
    	}
    	glog.Info(data)
    

    select 是同步的, 打印出zevent之后, 再打印后面的data

  • nginx中location的匹配规则

    官方资料见 http://nginx.org/en/docs/http/ngx_http_core_module.html#location

    location语法是这样的 location [ = | ~ | ~* | ^~ ] uri { ... } , []里面的东西代表可有可无. 举一个例子

    location = / {
        [ configuration A ]
    }
    
    location / {
        [ configuration B ]
    }
    
    location /documents/ {
        [ configuration C ]
    }
    
    location ^~ /images/ {
        [ configuration D ]
    }
    
    location ~* \.(gif|jpg|jpeg)$ {
        [ configuration E ]
    }
    

    nginx在匹配路径之前, 会首先把uri中%XX这样格式的内容先解码, 然后把. ..转成绝对路径, 以及把多个//合并成一个/

    再说明匹配规则前, 还是先解释一下上面这个语法什么意思. ~ ~这两个代表uri是一个正则表达式, ~是大小写敏感, ~是大小写不敏感. ^~可不是正则的意思,后面会有解释. 其它情况下, uri代表一个路径前缀.

    匹配路径按以下规则进行:

    1. 先序遍历所有路径前缀, 记录下来. 然后按顺序遍历所有正则,选用第一个正则匹配成功的结果. 如果没有正则可以成功匹配, 选用最长长度的前缀路径.

    2. 如果最长的前缀路径有 ^~ 修饰符, 就不再进行正则匹配这一步了.

    3. 如果前缀路径有 = 修饰符, 不再继续寻找

    4. uri前面加一个@, 叫做 named location, 普通的请求不管他, 只用在一些内部的跳转上, 比如下面这样

       location / {
           error_page 404 = @fallback;
       }
      
       location @fallback {
           proxy_pass http://backend;
       }
      
    5. 如果一个前缀路径最后以/结尾, 而且请求被proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, or memcached_pass中的一个处理, 这个情况比较特殊: 请求如果不以/结尾, 会返回一个301的重定向响应, 再最后加上/. 如果不想这样, 就要用 = 修饰符做精确匹配, 像下面这样

       location /user/ {
           proxy_pass http://user.example.com;
       }
       location = /user {
           proxy_pass http://login.example.com;
       }
      
  • elasticsearch在有节点脱离集群时删除索引

    如果节点A先脱离集群了, 这时候删除了某个索引.

    然后节点A又再次加入集群, 会导致一个现象: 这个索引回来了, 但是无法分配到任何节点上.

  • /proc/meminfo

    https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html全文复制

    This is one of the more commonly used files in the /proc/ directory, as it reports a large amount of valuable information about the systems RAM usage.

    The following sample /proc/meminfo virtual file is from a system with 256 MB of RAM and 512 MB of swap space:

    MemTotal:       255908 kB 
    MemFree:         69936 kB 
    Buffers:         15812 kB 
    Cached:         115124 kB 
    SwapCached:          0 kB 
    Active:          92700 kB 
    Inactive:        63792 kB 
    HighTotal:           0 kB 
    HighFree:            0 kB 
    LowTotal:       255908 kB 
    LowFree:         69936 kB 
    SwapTotal:      524280 kB 
    SwapFree:       524280 kB 
    Dirty:               4 kB 
    Writeback:           0 kB 
    Mapped:          42236 kB 
    Slab:            25912 kB 
    Committed_AS:   118680 kB 
    PageTables:       1236 kB 
    VmallocTotal:  3874808 kB 
    VmallocUsed:      1416 kB 
    VmallocChunk:  3872908 kB 
    HugePages_Total:     0 
    HugePages_Free:      0 
    Hugepagesize:     4096 kB
    

    Much of the information here is used by the free, top, and ps commands. In fact, the output of the free command is similar in appearance to the contents and structure of /proc/meminfo. But by looking directly at /proc/meminfo, more details are revealed:

    • MemTotal — Total amount of physical RAM, in kilobytes.
    • MemFree — The amount of physical RAM, in kilobytes, left unused by the system.
    • Buffers — The amount of physical RAM, in kilobytes, used for file buffers.
    • Cached — The amount of physical RAM, in kilobytes, used as cache memory.
    • SwapCached — The amount of swap, in kilobytes, used as cache memory.
    • Active — The total amount of buffer or page cache memory, in kilobytes, that is in active use. This is memory that has been recently used and is usually not reclaimed for other purposes.
    • Inactive — The total amount of buffer or page cache memory, in kilobytes, that are free and available. This is memory that has not been recently used and can be reclaimed for other purposes.
    • HighTotal and HighFree — The total and free amount of memory, in kilobytes, that is not directly mapped into kernel space. The HighTotal value can vary based on the type of kernel used.
    • LowTotal and LowFree — The total and free amount of memory, in kilobytes, that is directly mapped into kernel space. The LowTotal value can vary based on the type of kernel used.
    • SwapTotal — The total amount of swap available, in kilobytes.
    • SwapFree — The total amount of swap free, in kilobytes.
    • Dirty — The total amount of memory, in kilobytes, waiting to be written back to the disk.
    • Writeback — The total amount of memory, in kilobytes, actively being written back to the disk.
    • Mapped — The total amount of memory, in kilobytes, which have been used to map devices, files, or libraries using the mmap command.
    • Slab — The total amount of memory, in kilobytes, used by the kernel to cache data structures for its own use.
    • Committed_AS — The total amount of memory, in kilobytes, estimated to complete the workload. This value represents the worst case scenario value, and also includes swap memory.
    • PageTables — The total amount of memory, in kilobytes, dedicated to the lowest page table level.
    • VMallocTotal — The total amount of memory, in kilobytes, of total allocated virtual address space.
    • VMallocUsed — The total amount of memory, in kilobytes, of used virtual address space.
    • VMallocChunk — The largest contiguous block of memory, in kilobytes, of available virtual address space.
    • HugePages_Total — The total number of hugepages for the system. The number is derived by dividing Hugepagesize by the megabytes set aside for hugepages specified in /proc/sys/vm/hugetlb_pool. This statistic only appears on the x86, Itanium, and AMD64 architectures.
    • HugePages_Free — The total number of hugepages available for the system. This statistic only appears on the x86, Itanium, and AMD64 architectures.
    • Hugepagesize — The size for each hugepages unit in kilobytes. By default, the value is 4096 KB on uniprocessor kernels for 32 bit architectures. For SMP, hugemem kernels, and AMD64, the default is 2048 KB. For Itanium architectures, the default is 262144 KB. This statistic only appears on the x86, Itanium, and AMD64 architectures.

    Note: This documentation is provided {and copyrighted} by Red Hat®, Inc. and is released via the Open Publication License. The copyright holder has added the further requirement that Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. The CentOS project redistributes these original works (in their unmodified form) as a reference for CentOS-5 because CentOS-5 is built from publicly available, open source SRPMS. The documentation is unmodified to be compliant with upstream distribution policy. Neither CentOS-5 nor the CentOS Project are in any way affiliated with or sponsored by Red Hat®, Inc.