2020/05/29

golang var is nil

package main

import (
"fmt"
)

func main() {
var stringArr []string

       //true
fmt.Println(stringArr==nil)

// zero
fmt.Println(len(stringArr)) 
}

make([]string,0) is not nil, len is zero

2020/04/08

Vue.js Upload file using axios

<input type="file" @change="onFileChanged">
<button @click="onUpload">Upload!</button>
We now need the two handler methods in our Vue component:

methods: {
  onFileChanged (event) {
    const file = event.target.files[0]
  },
  onUpload() {
    // upload file
  }

Send as binary data
onUpload() {
  axios.post('my-domain.com/file-upload', this.selectedFile)
}
Send as FormData
onUpload() {
  const formData = new FormData()
  formData.append('myFile', this.selectedFile, this.selectedFile.name)
  axios.post('my-domain.com/file-upload', formData)
}
Show upload progress
In both cases, you can also output the upload progress if you want to.
uploadHandler = () => {
  ...
  axios.post('my-domain.com/file-upload', formData, {
    onUploadProgress: progressEvent => {
      console.log(progressEvent.loaded / progressEvent.total)
    }
  })
}

2020/04/07

mac node version nodebrew

Usage:
    nodebrew help                         Show this message
    nodebrew install <version>            Download and install <version> (from binary)
    nodebrew compile <version>            Download and install <version> (from source)
    nodebrew install-binary <version>     Alias of `install` (For backword compatibility)
    nodebrew uninstall <version>          Uninstall <version>
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for `list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias <key> <value>          Set alias
    nodebrew unalias <key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
    nodebrew exec <version> -- <command>  Execute <command> using specified <version>

2020/01/18

rails string

"test".length
=>4

"t  est".strip
=>test

"test".slice(1..2)
=>es


2020/01/11

rails ||=

@user
=>nil
@user = @user || "user1"
=>user1
@user = @user || "user2"
=>user2

2020/01/05

2019/12/27

wechat subscribe message 订阅消息

1. 选择权回到用户手中。需要用户主动点击授权之后,小程序才能向其推送服务通知,
2、时长不受限制。「订阅消息」取消了7天内推送消息的时间限制,只要用户没有主动拒收消息推送,开发者就可以随时推送服务通知。



2019/12/25

docker image build Dockerfile

docker-compse.yml 内で定義  go のimage
image:xxx/xxx ->直接pull して使う

imageを調査する
 履歴調査 docker image history image_name
 構成調査 docker image inspect image_name

build a image from dockerfile
 docker build --help 

Dockerfile 原則
 1. container from Dockerfile  is ephemeral
 2. one container one process (easy to scale  horizontally)
 3. minimize container layer ( use one-line command. one command one layer)

   RUN apt-get update && apt-get install -y \
  bzr \
  cvs \
  git \
  mercurial \
  subversion

 4. docker build dockerfile_path (---no-cache=true)
     run commands in dockerfile to create layer.
     but first to search cache (sha256のchecksumがあり)あれば、使う。 

2019/12/24

ninson ignore

-ignore='Path .git' 
-ignore='Path .github' 
-ignore='Path docker-compose' 
-ignore='Path .idea' 
-ignore='Name *.gitignore'

docker mac performance

docker use linux kernel almost as native, so performance is well.
in mac or windows, things are different. there is no linux kernel.
so some helper needed.

docker-machine:   a tool to install docker in virtual machine. Dockerized hosts (hosts with Docker Engine on them).

docker for Mac/Windows:  even still run a virtual machine (super hidden ).with its own hypervisor “hyperkit” and shared file system “osxfs”. Unfortunately, “osxfs” wasn’t very fast.

but in many cases, realtime host-virtual consistence is not necessary.
So options come
 host first docker run -v hostDir1:/virtualDir1:cached  
 virtual first docker run -v hostDir1:/virtualDir1:delegated
 realTime run -v hostDir1:/virtualDir1:consistent