Blog

  • 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
    
  • macOS 屏幕相关

    1. mission control => 触发角 => 启用屏幕保护程序 or 将显示器置入睡眠状态
    2. 安全性与隐私 => 进入睡眠或开始屏幕保护程序 立即 要求输入密码

    接下来使用触发角就可以立即锁屏了

    新版 mac 使用 ctrl + command + q

    Question: how to quick switch between mirror and extended display in macOS
    切换 mirror 和 扩展模式: command + F1
    If you need to temporarily see your Dock or your open windows on both displays, Command-F1 lets you accomplish this. It’s a shortcut to the System Preferences > Displays > Arrangement > Mirror Displays command.

  • bee 自动运行 go 项目

    当源代码有过修改之后,自动 build 重启

    ~/go/bin/bee run logan
    
  • kafka修改 topic retention

    查看所有的 topic

    bin/kafka-topics.sh --list --zookeeper localhost:2181
    

    修改为 60s

    
    # bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-name provider-service --entity-type topics --add-config retention.ms=60000
    

    查看

    # bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-name provider-service --entity-type topics
    Configs for topics:provider-service are retention.ms=60000
    
  • bash countdown

    输入 countdown + 秒数,就开始倒计时了

    gnu date

    function countdown(){  
        local now=$(date +%s)
        local end=$((now + $1))
        while (( now < end )); do   
            printf "%s\r" "$(date -u -d @$((end - now)) +%T)"  
            sleep 0.25  
            now=$(date +%s)
        done  
        echo
    }
    

    osx date

    function countdown(){  
        echo $2
        local now=$(date +%s)
        local end=$((now + $1))
        while (( now < end )); do   
            printf "%s\r" "$(date -u -j -f %s $((end - now)) +%T)"  
            sleep 0.25  
            now=$(date +%s)
        done
    }
    

    参考:https://superuser.com/questions/850368/osx-bash-command-line-countdown-timer?answertab=votes#tab-top