• 高效能文本编辑的7个习惯


    zzzhc's Blog


    高效能文本编辑的7个习惯

     

    Dec 10th, 2011

    Seven habits of effective text editing

    编辑单个文件

    1. 快速移动

    • 查找光标下单词在当前文件的其它位置
      1. * 向后查找
      2. # 向前查找
    • 搜索文本, /pattern
    • 使用%跳转到对应块的结尾/开头,安装matchit插件效果更好
    • 使用gd跳转到变量定义

    掌握更多高效编辑命令的三个基本步骤:
    * 留意编辑过程中的重复动作和花时间较多的地方
    * 找出一个可以更快完成这些操作的命令
    * 反复练习,直到形成习惯,不需要思考靠直觉就能敲出命令

    2. 不要重复输入两次

    • 善用.命令重做前一个修改
    • 使用自动补全, 安装supertab后可用tab键补全
    • 录制宏, qa开始录制,q结束宏, @a重放宏

    3. 自动修复拼写错误

    • abbr
    • syntax hightlight

    编辑多个文件

    4. 很少只在单独一个文件上工作

    • ctags, Ctrl+] 跳转到定义处
    • :grep, :cn

    5. 与其它程序协同工作


    1
    
    :!command

    6. Text is structured

    自动化编译,修改过程


    1
    2
    
    :make
    :set errorformat=xxx

    磨快你的矩

    7. 养成习惯

    这一点最重要,花大把时间找到合适的命令但很快就忘掉是很不划算的。

    Crontab Tips

     

    Dec 10th, 2011

    crontab command

     
    1
    2
    3
    4
    5
    6
    7
    8
    
    # 设置编辑器
    $ export EDITOR=vim
    # 编辑
    $ crontab -e [-u user]
    # 列出crontab内容
    $ crontab -l [-u user]
    # 删除crontab文件
    $ crontab -r [-u user]
    

    crontab syntax

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    * * * * *  command
    | | | | |
    | | | | |- day of week(0-6) 0 means sunday
    | | | |--- month(1-12)
    | | |----- day of month(1-31)
    | |------- hour
    |--------- minute(0-59)
    
    * 表示的项可以用,分隔指定多个值(如5,15,25),也可以指定周期,如在minute项上写*/5表示每5分钟执行一次
    

    crontab environment

    cron脚本执行的环境跟正常用户执行的有区别,~/.bashrc不会被执行, 这一点经常会引起问题, 可以在crontab里设置环境变量来减少影响.

     
    1
    2
    3
    4
    5
    6
    
    # PATH, SHELL, MAILTO比较常用, 如
    PATH=/usr/bin:/usr/sbin:/bin:/sbin
    SHELL=/bin/bash
    MAILTO=xxx@xxx.com
    
    1 * * * * find /var/data/upload/ -mtime 30 -exec rm -- {} +
    

    默认情况crontab按OS时区调度, 而不是用户时区,可以通过指定TZ环境变量设实际要用的时区

     
    1
    2
    
    TZ=UTC
    1 * * * * find /var/data/upload/ -mtime 30 -exec rm -- {} +
    

    crontab notification

    如果command有输出(stdout/stderr),crond会发送通知邮件, 具体发送给谁可以通过MAILTO定义,默认发送给当前用户。
    一般情况stdout可以忽略,所以经常会看到crontab里有 command >/dev/null; stderr一定不要忽略,否则cron job有错误无法正常执行都不知道。

    Bash Tips - 0

     

    Dec 9th, 2011

    • 为变量设置缺省值
     
    1
    
    : ${BIND_PORT:=9999}
    
    • 取得前一个在后台运行的进程pid
     
    1
    2
    
    $ sleep 10 &
    $ echo $!
    
    • 当前脚本的绝对路径
     
    1
    
    SCRIPT_PATH=`readlink -f "$0"`
    

    Rvm Global Gems

     

    Dec 9th, 2011

    用rvm安装多了ruby版本后,一些经常用的gem需要在多个版本下都重装一次,很费事。不过还好rvm早有解决方案,可以通过编辑~/.rvm/gemsets/global.gems来添加全局的gemsets, 比如必不可少的bundler


    1
    
    bundler

    也可以指定版本


    1
    
    bundler -v~>1.0.21

    Lucene 3下最快的中文分词器

     

    Jun 19th, 2011

    包包分词器 - 一个基于字典的快速中文分词器

    source code

    features

    • 简单 1000LOC
    • 高效 7M+ chars/second
    • 支持中文,英语,数字
    • 自动识别未登录词
    • 支持OffsetAttribute
    • 支持TypeAttribute
    • 支持PositionIncrementAttribute

    usage

     
    1
    2
    3
    4
    5
    6
    7
    8
    
    Dict dict = new Dict();
    dict.addAllSpecialTypes();
    BufferedReader dictReader = new BufferedReader(new InputStreamReader(
        new FileInputStream("dict.txt"), "UTF-8"));
    dict.load(dictReader);
    dictReader.close();
    dict.optimize();
    DictAnalyzer dictAnalyzer = new DictAnalyzer(dict);
    

    benchmark

    ant benchmark

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
    supported features:
                      CharTerm  Offset  PositionIncrement  Term  Type
          IKAnalyzer         Y       Y                  N     Y     N
       MMSegAnalyzer         Y       Y                  N     Y     Y
     PaodingAnalyzer         Y       Y                  N     Y     Y
    StandardAnalyzer         Y       Y                  Y     Y     Y
      BaoBaoAnalyzer         Y       Y                  Y     Y     Y
    
    test 1, sample length=26265
                name          chars           time         tokens speed(chars/second)
     PaodingAnalyzer          26265          0.610          12542            43036.87
       MMSegAnalyzer          26265          0.314          14007            83566.52
          IKAnalyzer          26265          0.262          16016           100177.91
    StandardAnalyzer          26265          0.141          22366           185727.87
      BaoBaoAnalyzer          26265          0.038          18185           695682.16
    
    test 2, sample length=262650
                name          chars           time         tokens speed(chars/second)
     PaodingAnalyzer         262650          0.187         125420          1402139.61
          IKAnalyzer         262650          0.163         160160          1613693.16
       MMSegAnalyzer         262650          0.158         140070          1664009.53
      BaoBaoAnalyzer         262650          0.041         181850          6362134.44
    StandardAnalyzer         262650          0.020         223660         12905789.80
    
    test 3, sample length=2626500
                name          chars           time         tokens speed(chars/second)
          IKAnalyzer        2626500          2.251        1601600          1166564.72
     PaodingAnalyzer        2626500          1.462        1254200          1796381.55
       MMSegAnalyzer        2626500          1.043        1400700          2519010.94
      BaoBaoAnalyzer        2626500          0.352        1818500          7458959.20
    StandardAnalyzer        2626500          0.202        2236600         13015280.16
  • 相关阅读:
    30分钟掌握ES6/ES2015核心内容(下)
    30分钟掌握ES6/ES2015核心内容(上)
    域名、主机名与URL
    localstorage sessionstorage cookie的区别
    http中post 和 get 请求方法区别
    leetcode33. 搜索旋转排序数组
    leetcode 56. 合并区间
    MySQL EXPLAIN
    array 数组
    判断一个字符串的所有字符是否都在另一个字符串中
  • 原文地址:https://www.cnblogs.com/lexus/p/2402832.html
Copyright © 2020-2023  润新知