Author: jpuyy

  • bash debug line number

    当遇到很长 bash 脚本,尤其包含很多逻辑的时候,需要用 bash 行号进行debug,方法是设置 PS4 变量。

    [vagrant@centos7-work ~]$ sh foobar.sh 
    foobar
    [vagrant@centos7-work ~]$ export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ '
    [vagrant@centos7-work ~]$ sh -x foobar.sh 
    (foobar.sh:2) $ echo foobar
    foobar
    

    参考:
    https://coderwall.com/p/wil8da/debug-bash-scripts-with-line-numbers-more-info

  • k8s 停用一个 deployment statefulset

    将 节点 “扩”成 0

    kubectl scale --replicas=0 deployment contract-service -n dev  只能把节点扩成 0
    

    statefulset

    kubectl scale --replicas=0 statefulset kafka -n dev
    
  • 2019读书清单

    目标30本书

    月份 技术书 非技术书
    2019-04-10 jenkins权威指南 挪威的森林
    2019-04-22 kubernetes in action 中文版 了不起的盖茨比
    2019-05-22 房思琪的初恋乐园
    2019-06-30 人类简史
    2019-09-30 The go programming language 英文版
  • mysql ELT 替换返回的列

    统计数量的时候,select 返回值是

    1 | 138
    2 | 234
    3 | 22
    4 | 348
    

    想要把最前面的代号换成有意义的字符串

    select
      ELT(app_code, "dev", "demo", "demo1", "prod") as env,
      count(*)
    from
      app_overview
    where
      last_deployed_tag != ""
    group by
      app_code;
    

    结果为

    dev   | 138
    demo  | 234
    demo1 | 22
    prod  | 348
    
  • reset mac usb

    This is how to reset SMC on most modern Mac laptops, none of which have a removable battery:

    Shutdown your MacBook Air / MacBook Pro
    Connect the power adapter to the Mac
    On the MacBook / Pro’s keyboard, hold down the Shift+Control+Option keys and the Power button at the same time
    Release all keys and the power button at the same time – the little light on the MagSafe adapter may change colors briefly to indicate the SMC has reset
    Boot your Mac as usual

    When and How to Reset Mac SMC (System Management Controller)

    https://support.apple.com/zh-cn/HT201295