2020/11/16

Webpacker can't find application.js

 

これはwebpackerがコンパイル*されていないことが原因です。

なので下記のコマンドで解決しました。


rails webpacker:install

rails webpacker:compile

2020/10/21

GitHub 二段階認証 token

毎回やりかを忘れ。。 

Personal access tokens

-->https://github.com/settings/tokens

$ git clone https://github.com/private-organization/repository.git
Cloning into 'repository'...
Username for 'https://github.com': xxx
Password for 'https://xxx@github.com': {ここでGitHubのパスワードでなくtokenを入力する}

2020/10/17

fatal error: 'libpq-fe.h' file not found

 libpq-fe.h が見当たらないらしい。

次のコマンドで postgresql をインストールすることで解決。

libpqはpostgresqlのことだね

brew install postgresql

2020/10/16

golang sha256

 package main

import (

"fmt"
        "crypto/sha256"
)


func main() {

        //saltで値変わるね

       salt:="test"
       hash := hmac.New(sha256.New, []byte("1"))

hash.Write([]byte(salt))
        fmt.Printf("%x\n", hash.Sum(nil))

}


mac のshasumで無理かな?
goplaygroud でやりました。

2020/10/13

rbenv nodenv

// 1.初期化設定
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
// 2.初期化設定の反映(既存のRubyはこれで無視される)
$ source ~/.bash_profile
// 3.rbenvのインストール:
$ brew install rbenv ruby-build
// 4.インストール可能なRubyのバージョン一覧の表示
$ rbenv install -l
// 5.指定したRubyのバージョンをインストール
$ rbenv install 2.3.5
// 6.インストールしたRubyを使用可能な状態にする⇒shimsへの反映
$ rbenv rehash


全く同じ手順で nodenvをインストールできる

2020/09/28

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