Blog

  • jmap heap dump

    HOW TO CAPTURE HEAP DUMP? – JMAP, – XX:+HEAPDUMPONOUTOFMEMORYERROR

    JHAT – HEAP DUMP ANALYSIS

    切换到跑 java 进程所用的用户

    
    [[email protected] etl] $ jmap -dump:live,file=/tmp/kafka_hdfs_1_minute.bin pid
    [[email protected] etl] $ jmap -dump:live,file=/tmp/kafka_hdfs_15_minute.bin pid
    
    

    类似的工具还有 jps, jstack, jmap, etc.

  • vim + ctags

    用 vim 写 python golang javascript 都需要跳转

    brew install ctags

    查看 ctags 支持的版本

    ctags --list-languages

    cat ~/.ctags

    --langdef=Go
    --langmap=Go:.go
    --regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
    --regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
    --regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/
    --exclude=vendor
    
    --exclude=build
    --exclude=node_modules
    --exclude=dist
    --exclude=venv
    --exclude=*.sql
    
    --langdef=less
    --langmap=less:.less
    --regex-less=/^[ t]*.([A-Za-z0-9_-]+)/1/c,class,classes/
    --regex-less=/^[ t]*#([A-Za-z0-9_-]+)/1/i,id,ids/
    --regex-less=/^[ t]*(([A-Za-z0-9_-]+[ tn,]+)+){/1/t,tag,tags/
    --regex-less=/^[ t]*@medias+([A-Za-z0-9_-]+)/1/m,media,medias/
    
    --langdef=js
    --langmap=js:.js.vue
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*(=|:)[ \t]*function[ \t]*\(/\5/,function/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
    --regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
    --regex-js=/(gulp\.task)/\1/,task/
    
  • go test

    ok   command-line-arguments (cached)

    禁用 cache 进行测试

    go test api/cmdb/client_test.go -count=1
  • mac cleanup

    1. brew cleanup 清理不用的 软件包,可能会只保留最新版,实测释放了 3GB 空间
    2. docker Docker.qcow2 在使用过程中会一直增长,如果你是无状态的 docker ,可以 Preferences => resource => advanced => Disk Image Size 调整大小(所有镜像和 docker 都会被删), 实测释放 14GB 空间
    3. 微信 => 通用 => 存储空间 => 前往清理
    4. 微信 => 备份与恢复 => 管理备份文件
    5. 查找大于 1GB 的单个文件 ( sudo find / -size +1GB )
  • brew 切换 go 版本

    安装

    brew install go

    查看所有版本 方式一

    jpuyy-mba:src jpuyy$ brew info go
    go: stable 1.11.4 (bottled), HEAD
    Open source programming language to build simple/reliable/efficient software
    https://golang.org
    /usr/local/Cellar/go/1.10.3 (8,170 files, 336.8MB)
      Poured from bottle on 2018-07-31 at 17:27:27
    /usr/local/Cellar/go/1.11 (9,273 files, 403.9MB) *
      Poured from bottle on 2018-09-29 at 11:39:50
    

    查看所有版本 方式二

    brew ls --versions | grep go 
    go 1.10.3 1.11 1.11.4
    

    切换

    brew switch go 1.11

     

    清理旧版本

    brew cleanup go
    Removing: /usr/local/Cellar/go/1.10.3... (8,170 files, 336.8MB)
    Removing: /usr/local/Cellar/go/1.11... (9,273 files, 403.9MB)
    Removing: /Users/jpuyy/Library/Caches/Homebrew/go--1.11.sierra.bottle.tar.gz... (140.4MB)
    

    升级新版本

    brew upgrade go
    
  • npm taobao

    设置淘宝源

    npm config set registry https://registry.npm.taobao.org 
    

    检查确认

    cat ~/.npmrc 
    registry=https://registry.npm.taobao.org