mozyのかきおき

mozyの読書感想文や思考置き場

Go言語の実装を読んでいく【第0回目】

きっかけ

Go言語の実装は読みやすく、理解もしやすいと風の噂で聞いた。
そのため、毎週くらいのペースで徐々にソースコードリーディングをしていこうと思い立った。
どうせならブログで連載すればいいなと思って今回が0回目です。

やったこと

初回はソースコードとバイナリをダウンロードしてきて、コンパイルするところまで。
go1.10.1.darwin-amd64.tar.gzと、go1.10.1.src.tar.gzをダウンロードしてきた。
そして実行

$ ./all.bash 
Building Go cmd/dist using /usr/local/Cellar/go/1.9.4/libexec.
(以下略)

参考サイト

Golangのソースコードを研究する(一) Golangのコンパイルとデバッグ - Qiita

Mac Homebrewで入れたMySQLがstopしても、自動で起動し復活するゾンビモードを解消

起きたこと

何度、 mysql.server stop をしても、kill PIDをしても数分後にはmysqldが復活してしまっていた。

原因

どうやら、mysqlのplistの設定で、死なないようになってるっぽい(?)
そのため、~/Library/LaunchAgents/homebrew.mxcl.mysql@5.6.plist 内のKeepAliveの設定を、以下のようにfalse/に変更し、設定を反映することで解決した。

<dict>
    <key>KeepAlive</key>
    <false/>

参考サイト

Homebrewで入れたMySQL5.1を停止できない件の対策 - かせいさんとこ

多分関連

以下の現象、mysql.server start すると、mysqld_safe A mysqld process already existsが次に行に渡される問題もこれで解決したようだ。

$ mysql.server start
Starting MySQL
 SUCCESS! 
$ 2018-04-10T06:46:46.6NZ mysqld_safe A mysqld process already exists

【Rails】Problem loading '.overcommit_gems.rb' エラー 【解決済】

vscodeのソース管理機能を使って、Gitコミットしようと思ったら、以下のようなエラーがでた。

Problem loading '.overcommit_gems.rb': Could not find parallel-1.11.2 in any of the sources

試しに、同じようにターミナルでコミットしてみたら、以下のようにエラーメッセージで解決策を指摘してくれた。

Problem loading '.overcommit_gems.rb': Could not find parallel-1.11.2 in any of the sources
Try running:
bundle install --gemfile=.overcommit_gems.rb

エラーメッセージの通り、
$ bundle install --gemfile=.overcommit_gems.rb
で解決した。やったね。

$ bundle install --gemfile=.overcommit_gems.rb
Fetching gem metadata from https://rubygems.org/...........
Using rake 12.0.0
Using ast 2.3.0
Using bundler 1.16.1
Using ffi 1.9.18
Using childprocess 0.6.3
Using iniparse 1.4.3
Using overcommit 0.39.1
Fetching parallel 1.11.2
Installing parallel 1.11.2
Using parser 2.4.0.0
Using powerpack 0.1.1
Using rainbow 2.2.2
Using ruby-progressbar 1.8.1
Using unicode-display_width 1.2.1
Fetching rubocop 0.49.1
Installing rubocop 0.49.1
Using sass 3.4.24
Fetching scss_lint 0.53.0
Installing scss_lint 0.53.0
Bundle complete! 4 Gemfile dependencies, 16 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Zettajs はnodeのバージョンが9だと動かない

Hello World Zetta
を試していたところ、以下のようなエラーでコケた。 

util.js:948
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'superCtor', 'Function');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor" argument must be of type Function
    at Object.inherits (util.js:948:11)
    at Object.<anonymous> (/Users/moyz/Test/zettajs-test/node_modules/spdy/lib/spdy/connection.js:86:6)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/mozy/Test/zettajs-test/node_modules/spdy/lib/spdy.js:20:19)

あーコレはnodeのバージョンの問題だなと思ったので
nodebrew list でインストールしているnodeのバージョンを確認した。
今回は、 運よくv6.11.0がインストールしてあったのでこちらを使用した。

direnvを使ってディレクトリごとに環境を変えているので、今回も、
direnv edit ..envrcファイル内に PATH_add ~/.nodebrew/node/v6.11.0/bin と記載して解決。

動作確認

$ node server.js 
(node:6554) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.
Mar-21-2018 12:47:23 [server] Server (mozy) mozy listening on http://127.0.0.1:1337
Zetta is running at http://127.0.0.1:1337
$curl http://127.0.0.1:1337
{"class":["root"],"links":[{"rel":["self"],"href":"http://127.0.0.1:1337/"},{"title":"mozy","rel":["http://rels.zettajs.io/server"],"href":"http://127.0.0.1:1337/servers/mozy"},{"rel":["http://rels.zettajs.io/events"],"href":"ws://127.0.0.1:1337/events"},{"rel":["http://rels.zettajs.io/peer-management"],"href":"http://127.0.0.1:1337/peer-management"}],"actions":[{"name":"query-devices","method":"GET","href":"http://127.0.0.1:1337/","type":"application/x-www-form-urlencoded","fields":[{"name":"server","type":"text"},{"name":"ql","type":"text"}]}]}% 

いい感じ。実験完了。動いてよかった。❤︎ 

【解決済み】React Nativeで、run-androidしたときにNo connected devices って怒られる

React Nativeでandroidアプリをrunしようとしたら、
以下のようなエラーが出て止まった。

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

以下のページを参考にして、あらかじめエミュレータを起動しておいてから 実行したらうまく動作した。
Failed run android simulator : No connected devices! · Issue #3091 · facebook/react-native · GitHub