builderscon 2017に参加して来ました

概要

8月3,4,5で開催されたbuildersconに参加してきました。
buildersconとは
公式サイト(https://builderscon.io)より引用

buildersconは「知らなかった、を聞く」をテーマとした技術を愛する全てのギーク達のお祭りです。

セッション感想

1日目は完全オフレコなので、内容については何もかかないですが、ああいう話を聞ける機会はめったにないので、次同じようなものがあったらぜひまた聞きたいと思うぐらいには最高だった。

オンプレ、クラウドを組み合わせて作るビックデータ基盤 -データ基盤の選び方-

  • 普段はオンプレの環境しか触っていないのでクラウド側の知識は新鮮で面白かった
  • MetaデータのDBはすごく便利そう、テーブルの説明のコメントを追加できるのはよさげ

横山三国志に「うむ」は何コマある?〜マンガ全文検索システムの構築

  • うむ
  • 横山三国志は規格が揃っているので処理に適しているとか面白すぎ
  • コマ取得アルゴリズムは聞いてみると以外と単純で驚き
  • python whooshは便利そうなので触ってみたい

OSS開発を仕事にする技術

  • 無理ゲーな目標を立てる
    • コントローラブルとアンコントローラブルをわける
    • コントローラブルに集中する
  • もっとも生産性が高いのは「作らない」こと

Chrome拡張を使って様々なWebサービスをハックする

  • 正規表現置換はよさげ、各言語で作るのいいかも
  • 独自ライブラリ便利そう
  • Chrome拡張から触れるのは基本DOMだけ

Googleが開発したニューラルネット専用LSITensor Processing Unit」

  • DCの温度管理も機械学習でやって、電力効率が15%よくなった
  • スマホのDeepLerningをtensorflowをDSPで動かすと速くて省電力でいける
  • TPU第一世代の話
  • ASIC : アプリケーションスペシックIC (application specific )
  • 15ヶ月でASICを作り終わった
  • 2015年から使ってる
  • 第一世代TPUは学習と推論の推論にしか使ってない
  • 2006年ぐらいから計画してた

OSSで始めるセキュリティログ収集

  • auditログを取ろう、見よう
  • ただauditログは見づらいのでパースしたい
    • osqueryかElastic Beatsが良さそう
  • osqueryはrocksDBのというKVSを内部で持っている
  • osqueryの今のバージョンだとアプリケーションに影響はでてない
  • auditログが見づらいのは思っていたので、osqueryは是非試してみたい
  • 個人的には今回一番ためになったセッション

Factory Class

  • キーボードを作って販売した話
  • ぜひ発送の問題とかも入れて本して欲しいぐらい面白かった

カンファレンス感想

  • 刺激的な3日間だった
  • 普段は聞かない分野の話もきけて最高
  • 試してみたい技術がいっぱい知れた
  • 施設的にしょうがないけど、コーヒーが一つ部屋でしか飲めないは残念
  • 名札にベストスピーカーの投票ページのQRコードがあるソリューションすごい
  • ランチ美味しい
  • 同時通訳の人すごい、ありがとう
  • ペパボラップが頭に残り続ける

denite.nvim の設定 備忘録

denite.nvimはvimでいうところのUnite

インストー

dein.tomlに以下を追加

[[plugins]]
repo = 'Shougo/denite.nvim'

#インストール後にNeoVimで以下を実行して再起動することで有効になる
:UpdateRemotePlugins

設定

まだまだ設定しきれてないが設定したのは下記

  • grepでagを使用する まずはagをインストー
$ brew install the_silver_searcher

neovim側の設定

"grepでagを使用するように設定
call denite#custom#var('grep', 'command', ['ag'])
"カレントディレクトリ内の検索もagを使用する
call denite#custom#var('file_rec', 'command', ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
"その他のgrepの設定
call denite#custom#var('grep', 'default_opts',['-i', '--vimgrep'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
"denite時に使用するキーマップ
"ESCキーでdeniteを終了
call denite#custom#map('insert', '<esc>', '<denite:enter_mode:normal>', 'noremap')
call denite#custom#map('normal', '<esc>', '<denite:quit>', 'noremap')
"C-N,C-Pで上下移動
call denite#custom#map('insert', '<C-n>', '<denite:move_to_next_line>', 'noremap')
call denite#custom#map('insert', '<C-p>', '<denite:move_to_previous_line>', 'noremap')
"C-J,C-Kでsplitで開く
call denite#custom#map('insert', '<C-j>', '<denite:do_action:split>', 'noremap')
call denite#custom#map('insert', '<C-k>', '<denite:do_action:vsplit>', 'noremap')

" 以下はdenite起動時に使用するキーマップ
" バッファ一覧
noremap <C-P> :Denite buffer<CR>
" ファイル一覧
noremap <C-N> :Denite -buffer-name=file file<CR>
" 最近使ったファイルの一覧
noremap <C-Z> :Denite file_old<CR>
" カレントディレクトリ
noremap <C-C> :Denite file_rec<CR>
"バッファ一覧
nnoremap sB :<C-u>Denite buffer -buffer-name=file<CR>

"Denite でバッファ内検索 
nnoremap <silent> <Leader><C-f> :<C-u>Denite line<CR>
nnoremap <silent> <expr><Space>l ":<C-u>DeniteWithCursorWord line<CR>"
  • 表示をカスタマイズ
" プロンプトの左端に表示される文字を指定
call denite#custom#option('default', 'prompt', '>')
" deniteの起動位置をtopに変更
call denite#custom#option('default', 'direction', 'top')

MacのSpotlightからneovimを起動する方法

そもそもSpotlightから起動するのが、しっくり来てない人もいると思いますが、
下のGIFを見て貰えればどういうことかわかると思います。

f:id:replicity:20170602015004g:plain

私は普段、Spotlightから様々なアプリを起動しており、 ちょっとメモが取りたいなーって時とかはターミナルでvimを開かず、ここから起動してました。
なので、neovimもここから起動できるように設定します。

neovimはMacVimのようにアプリケーションとしてMacにインストールされず、GUI版もないのでインストールをしただけだと、Spotlightからは起動できないです。

ではどうするかと言うと、neovimを起動するスクリプトを書いて、それをSpotlightから実行することでSpotlightからneovimを起動するのを実現します。
スクリプトをSpotlightから実行できるようにするには.command拡張子でファイルを書けばいいので、下記のファイルを適当な場所に作成しておきます。

今回はファイル名はneovim_run.commandにしてます。

!#/bin/sh
nvim

ファイルをおいたらもうSpotlightから起動できるはずです。

f:id:replicity:20170602015048g:plain

Neovim 補完設定

すでに前回までの設定が終わっている状態で設定を続けていきます。
neovimで補完を有効にするために設定をする。
neovimではvimで使っていた、neocomplete.vimではなくdeoplete.nvimを使用する。
また、スニペットの補完はvimと同じでneosnippet.vimを使用する

deoplete.nvimとneosnippet.vimのインストー

pluginはTOMLで管理しているのでTOMLに以下を追加

[[plugins]]
repo = 'Shougo/deoplete.nvim'
on_i = 1
[[plugins]]
repo = 'Shougo/neosnippet.vim.git'
on_i = 1
on_ft = 'snipppet'

追加したら、あとは起動時にダウンロードされる

補完用のポップアップが表示された時の設定

補完用のポップアップが表示されている時にで移動できるように設定をplugin毎の設定ファイルに追加
追加した設定は下記

"補完候補選択時は<TAB>で候補移動snipppet時は<TAB>で次の入力先へ
imap <expr><TAB> pumvisible() ? "\<C-N>" : neosnippet#jumpable() ?  "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#jumpable() ?  "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
inoremap <expr><S-TAB>  pumvisible() ? "\<C-p>" : "\<S-TAB>"

まとめ

これでneovimでも補完が表示されるようになったのでほぼvimと同じように使えるようになってきた。
deoplete.nvimは言語ごとに保管用のpluginを入れていくようなので、必要になった言語を都度追加していく予定

alacrittyインストール 備忘録

vimとneovimをiTerm2で使用中にスクロールが遅くなることがあり、調べてたらalacrittyというのが良さげだったのでインストールした
基本的にはこの記事を参考にやれば問題はない : http://qiita.com/zebult/items/0047b72916383a5c0acf
ただ、今回はbrewからインストールするとmakeで失敗してインストールできなかった

エラーメッセージ

$brew install --HEAD mscharley/homebrew/alacritty                                                                                                                                                                                   
==> Installing alacritty from mscharley/homebrew
==> Cloning git@github.com:jwilm/alacritty.git
Updating  ~/Library/Caches/Homebrew/alacritty--git
==> Checking out branch master
==> make app
Last 15 lines from ~/Library/Logs/Homebrew/alacritty/01.make:
   Compiling cgmath v0.7.0
   Compiling walkdir v0.1.8
   Compiling notify v2.6.3
error: custom derive attribute panicked
   --> src/ansi.rs:373:62
    |
373 | #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
    |                                                              ^^^^^^^^^
    |
    = help: message: proc_macro::__internal::with_parse_sess() called before set_parse_sess()!

error: Could not compile `alacritty`.

To learn more, run the command again with --verbose.
make: *** [alacritty] Error 101

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/mscharley/homebrew-homebrew/issues

おそらくこのissuesと同じような問題だと思われる
https://github.com/jwilm/alacritty/issues/413
alacrittyの問題というかrust周りの問題?
brewで入れるのはとりあえず諦めて自分でbuildすることにする

#rustのインストール
#rustはrustupで管理するのがよさげ : http://qiita.com/chikoski/items/b6461367e8c3875bb235
$curl https://sh.rustup.rs -sSf | sh
#zshrcにsource ~/.cargo/env を追加
$echo 'source ~/.cargo/env' >> .zshrc
#alacrittyのインストール
#これは公式の手順を参考に実施 :  https://github.com/jwilm/alacritty
$git clone https://github.com/jwilm/alacritty.git
$cd alacritty
$rustup override set stable
$rustup update stable
$cargo build --release
$sudo cp target/release/alacritty /usr/local/bin #alacrittyコマンドでalacrittyが起動する

とりあえず無事インストールできたので使用しながら設定は直していく

2017/04/24 追記 rustupさえ入れておけばbrewでのmakeに失敗しないようでした
https://github.com/cema-sp/homebrew-tap

$curl https://sh.rustup.rs -sSf | sh
$echo 'source ~/.cargo/env' >> .zshrc
$brew install --HEAD cema-sp/tap/alacritty

Neovim 入門3 plugin

neovimでもvimと同じようにpluginが使える。
vimで使用していたdein.vimはNeovimもサポートしているので、これをそのまま使う。
https://github.com/Shougo/dein.vim

deinのインストール

dein.vimのインストールは公式サイトを参考にinit.vimに追加
なお、pluginはTOMLファイルに記述していく。

let s:dein_cache_path = expand('~/.cache/nvim/dein')
let g:home = expand('~')
let g:nvim_home = g:home .'/.config/nvim'
let s:dein_dir = expand(g:home . '/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'

if &runtimepath !~# '/dein.vim'
    if !isdirectory(s:dein_repo_dir)
        execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
    endif
    execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif

let g:rc_dir   = g:nvim_home . '/rc'
let g:dein#install_max_processes = 16
let g:dein#install_progress_type = 'title'
let g:dein#enable_notification = 1
let s:toml = g:rc_dir .  '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'

if dein#load_state(s:dein_dir)
    call dein#begin(s:dein_dir, [s:toml, s:lazy_toml])
    call dein#load_toml(s:toml, {'lazy' : 0})
    call dein#load_toml(s:lazy_toml, {'lazy' : 1})

    call dein#end()
    call dein#save_state()
endif

if dein#check_install()
    call dein#install()
endif

#plugin毎の設定ロード
for plugin in glob(g:rc_dir . '/plugins/*', 1, 1)
    execute "source " . plugin
endfor

filetype plugin indent on

#plugin毎に設定ファイルを分け、それを読み込む
for plugin in glob(g:rc_dir . '/plugins/*', 1, 1)
    execute "source " . plugin
endfor

neoterm

せっかくなのでNeovimぽいpluginを入れてみる。
Neovimではvimの中のshellを実行できるので(TERMINALモード)、それを便利にするpluginを入れる。
今回入れるのはneotermというplugin。
https://github.com/kassio/neoterm

dein.tomlに下記を追加

[[plugins]]
repo = 'kassio/neoterm'

これでnvimを起動したタイミングでdein.vimがpluginをダウンロードして来てくれる。

neotermの設定を記述(公式サイトのexampleから必要そうなのだけをもってきただけ)

let g:neoterm_position = 'horizontal'

" Useful maps
" hide/close terminal
nnoremap <silent> ,th :call neoterm#close()<cr>
" clear terminal
nnoremap <silent> ,tl :call neoterm#clear()<cr>
" kills the current job (send a <c-c>)
nnoremap <silent> ,tc :call neoterm#kill()<cr>

" Git commands
command! -nargs=+ Tg :T git <args>

まとめ

とりあえずこれで、初期設定とpluginのインストールはできたので、あとは必要なpluginや設定を適宜追加していくだけまではできた。
フォルダ構成としては現状は以下になっている。

nvim
    ├── init.vim
    └── rc
        ├── color.vim
        ├── dein.toml
        ├── dein_lazy.toml
        ├── filetypes.vim
        ├── mapping.vim
        ├── plugins
        │   └── neoterm.vim
        └── settings.vim

neovim 入門2 CheckHealth

neovimには自己判断ツールが入ってるので、それを実行する。
https://github.com/neovim/neovim/wiki/FAQ#my-ctrl-h-mapping-doesnt-work

実行方法

:CheckHealt 

エラーと修正方法

## terminfo
  - ERROR: key_backspace (kbs) entry is ^H (ASCII DELETE): key_backspace=^H,

    - SUGGESTIONS:
      - Set key_backspace to \177 (ASCII BACKSPACE). Run these commands:
          infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
          tic $TERM.ti
      - See https://github.com/neovim/neovim/wiki/FAQ

0.2では解決済みらしいが、今回いれたのが0.1.7なのでまだ問題がある。
SUGGESTIONSに書かれている通りに実行すれば解決。

## tmux
  - SUCCESS: escape-time: 1ms
  - INFO: $TERM: screen
  - ERROR: $TERM should be "screen-256color" or "tmux-256color" when running tmux.
    - SUGGESTIONS:
      - Set default-terminal in ~/.tmux.conf:
          set-option -g default-terminal "screen-256color"

      - See https://github.com/neovim/neovim/wiki/FAQ

これは結構はまった。
tmux起動時の$TERMの設定値がscreen-256colortmux-256colorじゃないと設定通りに色が付かない。
SUGGESTIONSに書かれている書き方はtmuxのバージョンが古かったので、以下を.tmux.confに追加した。

#.tmux.conf
set -g default-terminal "screen-256color"

これで設定自体は問題ないが、tmuxのセッションが一つでも残っていると上記の設定が反映されないようで、
$TERMに設定した値が反映されないと思い15分ほど悩んでた。

##Python 2 provider
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - SUCCESS: pyenv found: "/usr/local/Cellar/pyenv/1.0.10/libexec/pyenv"
  - WARNING: pyenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim using pyenv and use "g:python_host_prog".  This will avoid the need to install Neovim's Python client in each version/virtualenv.
  - INFO: Executable: /usr/local/bin/python2
  - INFO: Python2 version: 2.7.13
  - INFO: python2-neovim version: 0.1.13
  - SUCCESS: Latest python2-neovim is installed: 0.1.13

g:python_host_progの設定を.init.vimに追加すれば問題なし。

## Python 3 provider
  - WARNING: No Python interpreter was found with the neovim module.  Using the first available for diagnostics.
  - WARNING: provider/pythonx: Could not load Python 3:
    /Users/himalia/.pyenv/shims/python3 does not have the neovim module installed. See |provider-python|.
    /Users/himalia/.pyenv/shims/python3.5 does not exist: pyenv: python3.5: command not found
    
    The `python3.5' command exists in these Python versions:
    anaconda3-4.2.0
    
    
    python3.4 not found in search path or not executable.
    python3.3 not found in search path or not executable.
    /Users/himalia/.pyenv/shims/python is Python 2.7 and cannot provide Python 3.
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - SUCCESS: pyenv found: "/usr/local/Cellar/pyenv/1.0.10/libexec/pyenv"
  - WARNING: pyenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim using pyenv and use "g:python3_host_prog".  This will avoid the need to install Neovim's Python client in each version/virtualenv.
  - INFO: Executable: /usr/local/bin/python3
  - ERROR: Command error (8) /usr/local/bin/python3 -c import neovim; print(neovim.__file__): Traceback (most recent call last):  File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'neovim'
  - INFO: Python3 version: 3.6.1
  - INFO: python3-neovim version: unable to find nvim executable
  - ERROR: Neovim Python client is not installed.
    - SUGGESTIONS:
      - Error found was: unable to find nvim executable
      - Use the command `$ pip3 install neovim`
  - WARNING: Latest python3-neovim is NOT installed: 0.1.13

こちらもg:python_host_progの設定を.init.vimに追加。
加えてpip3 install neovimも実行。

## Ruby provider
  - ERROR: Missing Neovim RubyGem
    - SUGGESTIONS:
      - Install or upgrade the neovim RubyGem using `gem install neovim`.
  - INFO: Ruby Version: ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
  - INFO: Host Executable: not found
  - INFO: Host Version: not found

SUGGESTIONSに書かれている通りにsudo gem install neovimを実行

以上の変更でERRORとWARNIGがでなくなったので、次はプラグイン入れていきます