Author: jpuyy

  • vim window横竖切换

    当 vim 将屏分割开之后,有时想将当前 window 横竖切换

    按 ctrl + w + ( h j k l ) 定位到需要复制的 window

    当前 window 扩展到最宽

    ctrl + w + K 

    当前 window 扩展到最高

    ctrl + w + H 

    参考:
    https://stackoverflow.com/a/1269631

  • windows change caps lock to control

    新建文件 caps_lock_to_control.reg

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
    "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 
    

    直接下载:http://johnhaller.com/sites/default/files/downloads/reg/caps_lock_to_control.reg

    双击执行caps_lock_to_control.reg,之后重启

  • go list找到所有的 imports

    go 找到所有的 imports , 先找到所有的目录

    find . -type dir | grep -v vendor | grep -v .git | xargs
    . ./handlers ./logger ./router ./routes ./static

    上面就是所有的目录了,执行 go list 找到所有的 imports

    go list -f '{{ join .Imports "\n" }}' . ./handlers ./logger ./router ./routes ./static | sort | uniq
    
  • git 分支重命名 rename branch

    本地 branch 重命名 foo => bar

    1. 本地重命名,切到分支 foo

    git branch -m bar

    或者直接重命名

    git branch -m foo bar

    2. 如果分支已经在远端,查看远端 origin

    git remote show origin
    
      Remote branches:
        foo    tracked
        master tracked
      Local branch configured for 'git pull':
        master merges with remote master
      Local refs configured for 'git push':
        foo    pushes to foo    (up to date)
        master pushes to master (up to date)
    

    这就需要把本地分支 bar push 上去,把 foo 分支删掉

    git push origin :foo bar
     - [deleted]         foo
     * [new branch]      bar -> bar
    

    最后在本地的 bar 分支下把 upstream 设置好

    git push origin -u bar
    Branch bar set up to track remote branch bar from origin.
    

    查看远端 origin

    git remote show origin
    
      Remote branches:
        bar    tracked
        master tracked
      Local branches configured for 'git pull':
        bar    merges with remote bar
        master merges with remote master
      Local refs configured for 'git push':
        bar    pushes to bar    (up to date)
        master pushes to master (up to date)
    

    删除远端分支

     git push origin :feature/upgrade-gke                                                                                                                    master * ] 12:02 PM
    To github.com:xxx/yyy.git
     - [deleted]         feature/upgrade-gke
  • kafka topic 创建和删除

    创建

    bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic api-gateway --partitions 1 --replication-factor 3
    

    删除

    bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic api-gateway
    

    查看

    /kafka-topics.sh --list --zookeeper localhost:2181
    
  • etcdctl

    检测 etcd 状态

    etcdctl --endpoints http://127.0.0.1:4001 cluster-health
    
    etcdctl member list
    996585598035175a, started, etcd-0, http://etcd-0.etcd:2380, http://etcd-0.etcd:2379
    9a7f19668a394adb, started, etcd-1, http://etcd-1.etcd:2380, http://etcd-1.etcd:2379
    92dc397d93504108, started, etcd-2, http://etcd-2.etcd:2380, http://etcd-2.etcd:2379
    
    # etcdctl --endpoints=[etcd-0.etcd:2379,etcd-1.etcd:2379,etcd-2.etcd:2379] endpoint health
    etcd-0.etcd:2379 is healthy: successfully committed proposal: took = 4.658206ms
    etcd-2.etcd:2379 is healthy: successfully committed proposal: took = 5.670776ms
    etcd-1.etcd:2379 is healthy: successfully committed proposal: took = 5.608339ms
    

    查看所有 a 开头的 key

    etcdctl-3.2.26 get a --prefix --keys-only
    

    查看所有 key

    ETCDCTL_API=3 etcdctl get "" --prefix --keys-only
    

    备份

    etcdctl --endpoints=[etcd-0.etcd:2379,etcd-1.etcd:2379,etcd-2.etcd:2379]  snapshot save snapshot.db