• How Can I Center The Window On Each Search Result

    https://vi.stackexchange.com/questions/13641/how-can-i-center-the-window-on-each-search-result

    https://stackoverflow.com/questions/45866451/put-the-search-results-at-the-top-of-the-screen-in-vi

    If you :set scrolloff=999 (or other arbitrarily high number) you will get the effect you are looking for but it doesn’t turn off. In other words, the cursor line will be midway between the top and bottom of the window whether you’re searching, editing, moving around in Normal mode, etc.

    From :help scrolloff:

    Minimal number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. If you set it to a very large value (999) the cursor line will always be in the middle of the window (except at the start or end of the file or when long lines wrap).

    Try it out. Some people keep this on all the time. Maybe you’ll like it, too. We might also be able to figure out a mapping/script that enables it just while searching, too, but if you don’t want to mess around with a mapping with zz I imagine you don’t want to mess around with a mapping for this either.

  • Stap Find Which Process Send Udp

    systemtap 真好用

    stap -e 'probe netfilter.ip.local_out {
      if (dport == 53) # or parametrize
          printf("%s[%d %d] %s:%d\n", execname(), ppid(), pid(), daddr, dport)
    }'
    
  • Oom Kill

    Chapter 13 Out Of Memory Management

    13.4 Killing the Selected Process

    Once a task is selected, the list is walked again and each process that shares the same mm_struct as the selected process (i.e. they are threads) is sent a signal. If the process has CAP_SYS_RAWIO capabilities, a SIGTERM is sent to give the process a chance of exiting cleanly, otherwise a SIGKILL is sent.

    CAP_SYS_RAWIO 参考 capabilities(7) — Linux manual page

    如何查询一下进程的 capabilities How to find out what linux capabilities a process requires to work?

    $ getpcaps PID: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap+i

  • 国庆七天流水账

    前两天去南京和张家港参加章旭婚礼, 2号晚上回来. 三号下午去看了socket activation, 看了一下午, 还挺满足的. 四号打麻将, 三个人输了luckygirl 1000多 五号本科室友过来吃饭打牌 六号去姨家里, 七号吃过晚饭回来. 和三弟他们喝酒打牌, 三弟输了500多. 8号修车, 和三弟小蒋打牌, 三个人输了小蒋1000多.

  • Moral Kidnapping

    提前打个招呼, 不要道德绑架我, 我是个没有道德的人.

  • Demand For Browser

    在浏览器里面使用新页面打开一个链接后, 希望可以在这个新页面回退到前一个, 并且锚定在那个超链接上.

    有时候啪啪啪打开好多页面, 再看的时候(可能是第二天了)已经想不起来为啥打开这个页面了

  • Leave

    逃避是解决问题的唯一真理

  • Bash_rematch

    Bash Regular Expressions

    #!/bin.bash
    
    if [[ $# -lt 2 ]]; then
        echo "Usage: $0 PATTERN STRINGS..."
        exit 1
    fi
    regex=$1
    shift
    echo "regex: $regex"
    echo
    
    while [[ $1 ]]
    do
        if [[ $1 =~ $regex ]]; then
            echo "$1 matches"
            i=1
            n=${#BASH_REMATCH[*]}
            while [[ $i -lt $n ]]
            do
                echo "  capture[$i]: ${BASH_REMATCH[$i]}"
                let i++
            done
        else
            echo "$1 does not match"
        fi
        shift
    done
    
      # sh bashre.sh 'aa(b{2,3}[xyz])cc' aabbxcc aabbcc
      regex: aa(b{2,3}[xyz])cc
    
      aabbxcc matches
        capture[1]: bbx
      aabbcc does not match
    
  • zsh: no matches found

    经常见这个报错吧.

    zsh 里面有个 NOMATCH 选项, 意思是: 如果 pattern of filename 如果没有匹配任何文件, 会打印上面这个错误.

    如果把这个项目关掉, 就不会打印错误, 而是原封不动的继续执行.

    setopt +o onmatch

  • Get Along Pattern

    : 给我买这件衣服
    不买 生气
    好,买
    后面再说吧

    : 给我换手机
    不换 生气
    好, 换
    我再用用吧, 先不换了

    : 顺我回家吧
    不顺 生气
    好, 顺
    emmm, 我再想想吧