MacOS Sierra を中国製 Arduino Nano につなぐと強制終了する

書いて字の如く、中国製の Arduino Nano を買って遊ぼうとしたところ、 OS 自体がシャットダウンするとかいうことが起きてた。 これは FTDI の代わりにCH340G とかいう ISP 用のチップを積んでいるおかげで、安価ではあるものの、ドライバーがバグ起こしてしまうため、らしい。

そこで以下のことをする: 1. ドライバ消す

sudo rm -rf /Library/Extensions/usbserial.kext

上記、OS によっては /System/Library/Extensions/usb.kext かも)

  1. 再起動

  2. ドライバ入れる

brew tap mengbo/ch340g-ch34g-ch34x-mac-os-x-driver https://github.com/mengbo/ch340g-ch34g-ch34x-mac-os-x-driver
brew cask install wch-ch34x-usb-serial-driver
  1. 再起動

  2. 差してみる

参考:

製造会社のドライバダウンロードページ

GitHub - adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver: CH340G CH34G CH34X Mac OS X driver

NodeJS で Postgres を使う

とりあえずインストール

brew install postgresql
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

zshrcに、

alias pg-start="brew services start postgresql"
alias pg-stop="brew services stop postgresql"
alias pg-restart="brew services restart postgresql"

brew services 便利)

その上で、

source ~/.zshrc
pg-start
createdb `dbname`
psql -l // list all databases
psql -d dbname

で接続される。

接続後は普通にDBのコマンドを打つ。

参考:
Installing Postgres via Brew (OSX) · GitHub
http://www.postgresonline.com/downloads/special_feature/postgresql83_psql_cheatsheet.pdf
Heroku Postgres | Heroku Dev Center

oh-my-zsh を zplug に置き換えた話

oh-my-zsh 使ってたけれど、初期読み込みが重くなってきたので、zplug で必要最低限モニタする方向に移行した。

cp -r ~/.zshrc ~/.zshrc.old
brew install zplug

インストール後、.zshrc に以下の記述を追加:

  export ZPLUG_HOME=/usr/local/opt/zplug
  source $ZPLUG_HOME/init.zsh

そしてほしいプラグインを追加。。。

# zplug
zplug 'zplug/zplug', hook-build:'zplug --self-manage'

# theme (https://github.com/sindresorhus/pure#zplug)
zplug "mafredri/zsh-async"
zplug "sindresorhus/pure"

# Syntax highlighting (https://github.com/zsh-users/zsh-syntax-highlighting)
zplug "zsh-users/zsh-syntax-highlighting", nice:10

# history
zplug "zsh-users/zsh-history-substring-search"

# autocomplete
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "chrissicool/zsh-256color"
zstyle ':completion:*' menu select

# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
  printf "Install? [y/N]: "
  if read -q; then
    echo; zplug install
  fi
fi

# Then, source plugins and add commands to $PATH
zplug load --verbose

参考文献

zplugの導入 oh-my-zshのような設定にするまで。 - Qiita
もっと便利になれる zsh プラグインによる CLI ライフ - Qiita