dockerでMySqlを起動
とりあえず、localにDBが欲しい場合のメモ
$ docker pull mysql # 起動 $ docker run --name mysql -e MYSQL_ROOT_PASSWORD=<任意password> -d -p 3306:3306 mysql # 接続 $ mysql -h 127.0.0.1 -u root -p Enter password: <任意password>
shellで日時をprintする
日時分までの文字列が必要だったので、メモ
$ date '+%Y%m%d%R' | tr -d : 202001211357
gitのtagで使いたかった。
trコマンドについて
tr -d <stringA>
stringAを削除してくれる
tr <stringA> <stringB>
stringAをstringBに置き換える
terminalでhit countを表示したい
$ grep -c
で可能
docker imagesのcountを調べる場合は
$ docker images -q | grep -c ''
-q, --quiet Only show numeric IDs
ファイル選択させて画像表示する
参考リンク
概要
- ファイル選択ボタン, 画像表示エリアを用意
- ファイル選択アクションで画像を表示する
React Appの新規作成
$ npx create-react-app my-react-app
表示するComponentを作成
FileUpload.js
import React, { Component } from 'react'; class FileUpload extends Component { constructor(props) { super(props); this.state = { blobURL: null }; this.fileInput = React.createRef(); } onAccessFile() { const file = this.fileInput.current.files[0]; console.log(file); if (file === null || file === undefined) { this.setState({ blobURL: null }); return; } const blobURL = (window.URL || window.webkitURL).createObjectURL(file); console.log(blobURL); this.setState({ blobURL }); } render() { const blobURL = this.state.blobURL; console.log(blobURL); return ( <div> <input type="file" accept="image/bmp,image/gif,image/jpeg,image/png" onChange={() => this.onAccessFile()} ref={this.fileInput} /> <br /> {blobURL && <img src={blobURL} alt="画像" width={300} height={200} /> } </div> ) } } export default FileUpload;
App.js
import React from 'react'; import './App.css'; import FileUpload from './FileUpload'; function App() { return ( <div className="App"> <header className="App-header"> <FileUpload /> </header> </div> ); } export default App;
Translating SQLException with SQL state '42000', error code '1064', message [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,
予約語をcolumnに使った場合はバッククウォートで囲わないとダメ
### Translating SQLException with SQL state '42000', error code '1064' ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, .......
MySQL 予約後
docker のnoneイメージを一括で削除するコマンド
$ docker image rm $(docker images -a | grep none | awk '{print$3}')