Blog

  • brew安装多版本 清理包和 img

    brew 安装多版本

    例子,当前 gradle 5.2.1 ,想将 4.10.2 装上,找到 formula 的 git 目录,切到对应 4.10.2 的 commit,安装,安装完之后再切回 master

    $ brew list gradle --versions
    gradle 5.2.1
    $ cd "$(brew --repo homebrew/core)"
    $ pwd
    /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
    $ git log master -- Formula/gradle.rb 
    ...
    commit 01e0511df2c37b052a9659797f3c09df3f20d533
    Author: Jerome Lapostolet 
    Date:   Thu Sep 20 08:51:53 2018 +0100
    
        gradle 4.10.2
    ...
    
    $ git checkout 01e0511df2c37b052a9659797f3c09df3f20d533
    Note: checking out '01e0511df2c37b052a9659797f3c09df3f20d533'.
    
    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.
    
    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:
    
      git checkout -b 
    
    HEAD is now at 01e0511df2 gradle 4.10.2
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
    Error: gradle 5.2.1 is already installed
    To install 4.10.2, first run `brew unlink gradle`.
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew unlink gradle
    Unlinking /usr/local/Cellar/gradle/5.2.1... 1 symlinks removed
    $ HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle
    ==> Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip
    ==> Downloading from https://downloads.gradle.org/distributions/gradle-4.10.2-all.zip
    ######################################################################## 100.0%
    🍺  /usr/local/Cellar/gradle/4.10.2: 203 files, 83.7MB, built in 5 minutes 56 seconds
    $ git checkout master
    
    $ brew list gradle --versions
    gradle 5.2.1 4.10.2
    
    

    之后可以用 brew swith gradle x.x.x 在不同版本之间切换
    helm 安装 v2.9.1 版本

    https://medium.com/@nehaguptag/installing-older-version-of-helm-downgrading-helm-8f3240592202
    wget https://raw.githubusercontent.com/Homebrew/homebrew-core/78d64252f30a12b6f4b3ce29686ab5e262eea812/Formula/kubernetes-helm.rb
    brew install kubernetes-helm.rb
    

    查看已经安装的包

    brew list

    选择要清理的包

    brew uninstall mariadb

    整体清理

    brew update && brew upgrade && brew cleanup
    
    ==> This operation has freed approximately 427.8M of disk space.
    brew cask cleanup

    https://brew.sh/ 搜索软件和版本

    检查当前 brew 的配置情况

    brew doctor                                                                                               master 187b0c8b0d
    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry or file an issue; just ignore this. Thanks!
    
    Warning: Some installed kegs have no formulae!
    This means they were either deleted or installed with `brew diy`.
    You should find replacements for the following formulae:
      python@2
      ab
      tuntap
      unrar
      sshpass
      php54
    
    Warning: Some installed formulae are deprecated or disabled.
    You should find replacements for the following formulae:
      dep
      docker-machine
      [email protected]
      sshfs
    
    Warning: Unbrewed dylibs were found in /usr/local/lib.
    If you didn't put them there on purpose they could cause problems when
    building Homebrew formulae, and may need to be deleted.
    
    Unexpected dylibs:
      /usr/local/lib/libD4P11_ICBC.dylib
      /usr/local/lib/libD4PinPad_ICBC.dylib
      /usr/local/lib/libD4Token_ICBC.dylib
      /usr/local/lib/libshuttle_p11v220.1.0.0.dylib
    
    Warning: You have unlinked kegs in your Cellar.
    Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
    those kegs to fail to run properly once built. Run `brew link` on these:
      tree
      pandoc
      docker
      python@2
      docker-machine
      ab
      markdown
      tuntap
      aria2
      geoip
      unixodbc
      unrar
      gd
      wireshark
      php54
    
    Warning: Some taps are not on the default git origin branch and may not receive
    updates. If this is a surprise to you, check out the default branch with:
      git -C $(brew --repo homebrew/core) checkout master
    
    Warning: Homebrew's "sbin" was not found in your PATH but you have installed
    formulae that put executables in /usr/local/sbin.
    Consider setting your PATH for example like so:
      echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc
    
    
    

    参考:
    https://www.cnblogs.com/BlackStorm/p/homebrew-install-old-versions-take-node-for-example.html

  • redis bitmaps

    setbit 最大 offset
    python 中 2**32 -1 = 4294967295

    setbit mykey 4294967295 1
  • ansible sed替换

    使用 shell 模块时,有时为了偷懒 lineinfile,用 sed 替换,涉及到使用 sed 自己变量时,会报错

    例:将最后一行注释掉

    ansible all -i 172.28.128.3, -m shell -a "sed -e '$s/^/#/g' /etc/hosts" -u vagrant -s
    172.28.128.3 | FAILED | rc=1 >>
    sed: -e expression #1, char 4: comments don't accept any addresses

    由于 $s 代表最后一行,需要转义一下

    ansible all -i 172.28.128.3, -m shell -a "sed -i '\$s/#//g' /etc/hosts" -u vagrant -s
  • 开车时听的歌list

    1. linda(张学友 粤语)

  • 对日志每分钟数量进行统计

    日志格式

    2016-12-16 07:15:29.055
    

    统计每分钟的量

    uniq -w16 -c access.log
    
  • 客户端time_wait过多,调整服务端tcp_timestamps

    客户端发送大量 http 请求到服务端

    在客户端已经设置了

    net.ipv4.tcp_tw_recycle = 1
    net.ipv4.tcp_tw_reuse = 1

    发现客户端 time_wait 还是过多,后来在服务端设置

    sysctl -w net.ipv4.tcp_timestamps=1