• Nginx Different Proxy Depend On Method

    https://stackoverflow.com/questions/8591600/nginx-proxy-pass-based-on-whether-request-method-is-post-put-or-delete

    location ~* "(ngx.HTTP_POST|ngx.HTTP_DELETE|ngx.HTTP_PUT)" {
        proxy_pass http://127.0.0.1:8080;
    
        server {
      location / {
        # This proxy_pass is used for requests that don't
        # match the limit_except
        proxy_pass http://127.0.0.1:8080;
    
        limit_except PUT POST DELETE {
          # For requests that *aren't* a PUT, POST, or DELETE,
          # pass to :9080
          proxy_pass http://127.0.0.1:9080;
        }
      }
    }
    

    If is Evil… when used in location context

    location / {
        error_page 418 = @other;
        recursive_error_pages on;
    
        if ($something) {
            return 418;
        }
    
        # some configuration
        ...
    }
    
    location @other {
        # some other configuration
        ...
    }
    
  • Curl W

    curl -s -w '{\n"time_namelookup": %{time_namelookup},\n"time_connect": %{time_connect},\n"time_appconnect": %{time_appconnect},\n"time_pretransfer": %{time_pretransfer},\n"time_redirect": %{time_redirect},\n"time_starttransfer": %{time_starttransfer},\n"time_total": %{time_total},\n"speed_download": %{speed_download},\n"speed_upload": %{speed_upload},\n"remote_ip": "%{remote_ip}",\n"remote_port": "%{remote_port}",\n"local_ip": "%{local_ip}",\n"local_port": "%{local_port}"\n}' baidu.com -o /dev/null
    
  • Jq Example

    cat cm.json | jq '.data.results[] | select(.azone | test("^SHANGHAI")) | .ip'
    
  • Write Settings With Version Info

    写文档的时候,新加的参数要注明版本信息,说清楚是从哪个版本开始提供此参数的。

  • 对一段代码的疑惑

    conn := db.freeConn[0]
    copy(db.freeConn, db.freeConn[1:])
    db.freeConn = db.freeConn[:numFree-1]
    

    为什么不用 freeConn = freeConn[1:]

  • Saisai

    都两点了,赛赛还不睡觉,在床上疯。

    爷爷强抱起来他去奶奶屋里,要哄他去睡觉。抱他去的路上,赛赛嘴里一直说,“抓走啦,抓走啦”。

  • Openssl Check Https Server Cert

    echo | openssl s_client -servername www.example.com -connect www.example.com:443 2>/dev/null | openssl x509 -text
    
  • Saisai

    今天去逛了野生动物园,看完大象,差不多逛到一半的时候,赛赛终于在撑不住了,在电动车上睡着了。

  • Saisai

    今天妈妈哄睡的时候,听见赛赛在房间里面大哭了起来,我打开门进去看,赛赛自己爬下床,然后噔噔噔噔跑出去,跑去爷爷房间自己伸手把门开开找爷爷去了。

  • Golang Mod Replace

    golang mod 里面的 replace 语法和应用简单学习一下。

    语法

    replace module-path [module-version] => replacement-path [replacement-version]

    module-version: 可以用来指定特定的版本,如果不指定,则所有版本都替换

    例子

    例1 换成自己的 fork

    require example.com/othermodule v1.2.3
    
    replace example.com/othermodule => example.com/myfork/othermodule v1.2.3-fixed
    

    例2 换成其他版本

    require example.com/othermodule v1.2.2
    
    replace example.com/othermodule => example.com/othermodule v1.2.3
    

    例3 换成本地代码

    require example.com/othermodule v1.2.3
    
    replace example.com/othermodule => ../othermodule
    
    require example.com/othermodule v1.2.5
    
    replace example.com/othermodule v1.2.5 => ../othermodule