Blog

  • 《荒野求生》金句

    荒野虽险,身体+头脑依然能够生存,在社会上行走,也是行走在荒野

    Survival can be summed up in three words – never give up. That’s the heart of it really. Just keep trying.
    The line between life or death is determined by what we are willing to do.
    If you risk nothing you gain nothing
    If you can find a path with no obstacles, it probably doesn’t lead anywhere.
    There is little faith involved in setting out on a journey where the destination is certain and every step in between has been mapped in detail. Bravery, trust, is about leaving camp in the dark, when we do not know the route ahead and cannot be certain we will ever return.
    When you find yourself thinking about someone or something in the same old negative way, just stop yourself. Think. Check. Change. Refresh. Job done. Smile. Move on. Do this enough times and you will change. For the better; for the stronger.
    And if you give your heart to a goal, it will repay you. It’s the law of the universe.
    Stick to the fight when you’re hardest hit, It’s when things seem worst that you must not quit.
    There is no education like adversity.
    Tentative is no power.

  • git diff 换行

    git --no-pager diff

    or

    git diff --color | less -R

    显示改动过的文件

    git diff --staged --name-only  | cat
    

    比较 feature 分支和 master 分支具体一个文件的变动

    git diff feature/sftp-server master -- .gitlab-ci.yml
    

    https://stackoverflow.com/questions/4099742/how-to-compare-files-from-two-different-branches

  • 更改 mysql 慢查询时间阈值

    默认是 10s ,改为 200ms

    mysql> show global variables like 'long_query_time%';
    +-----------------+-----------+
    | Variable_name   | Value     |
    +-----------------+-----------+
    | long_query_time | 10.000000 |
    +-----------------+-----------+
    1 row in set (0.01 sec)
    
    mysql> set global long_query_time=0.2;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> show global variables like 'long_query_time%';
    +-----------------+----------+
    | Variable_name   | Value    |
    +-----------------+----------+
    | long_query_time | 0.200000 |
    +-----------------+----------+
    1 row in set (0.00 sec)
    
  • 防止在 slave 上执行sql 误操作

    防止在 slave 上执行sql 误操作最主要的还是知道自己执行的机器是否正确。

    要知道自己在哪台机器上

    select @@hostname

    查看 master status

    show master status\G

    查看 slave status (主库不应看到信息)

    show slave status

    查看 slave 有哪些 (从库不应看到信息)

    show slave hosts\G
  • rabbitmq从集群中拆除节点并初始化

    node1,node2,node3 想要拆掉 node3 做为单独和 node1,node2 相同配置的集群

    保存当前 definitions

    GET $host:15672/api/definitions 保存为 json文件

    node3 上执行

    rabbitmqctl stop_app

    node1上执行

    rabbitmqctl forget_cluster_node rabbit@node3

    node3 上删除 /var/lib/rabbitmq/mnesia 数据库下所有文件, 重启

    之后 node3 初始化

    rabbitmqctl add_user admin admin
    rabbitmqctl set_user_tags admin administrator
    rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

    登录到管理台导入json文件

  • macOS iCloud Drive path

    The path of iCloud Drive is

    ~/Library/Mobile\ Documents/com~apple~CloudDocs

    How to find this path
    Finder => View => Show Path Bar => Open iCloud Drive, in the bottom, right click, we can Copy “iCloud Drive” as Pathname

    We can create a symbolic link for the path

    ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs icloud

    Or an alias, cdi equals change directory to iCloud Drive

    alias cdi='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs'