MacBookAir Setup Memo

MBAをサラの状態からセットアップしたのでそのメモ

セットアップするのに必須なもの

  • Xcode & CommandLine Tools
App Store からXcodeをインストール
XcodeからCommandLine Toolsをインストール
  • Homebrew
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  • make
$ brew install make

開発環境

pythonオプション付きでインストールしたいので依存関係をクリア

$ brew install python
$ pip-2.7 install docutils
$ brew install mercurial

vim をインストール

$ brew install https://gist.github.com/raw/1027452/7e41f7c5ce2683c3a0ecd2a4ff6cedd7e99a24c5/vim.rb --enable-interp=python,python3,ruby 
  • mosh
$ brew install mosh
  • pwgen
$ brew install pwgen
$ brew install wget

開発用ミドルウェア

$ brew install httpd

To have launchd start httpd at login:
    ln -sfv /usr/local/opt/httpd/*.plist ~/Library/LaunchAgents
Then to load httpd now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
$ brew install mysql

A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To have launchd start mysql at login:
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
    mysql.server start
  • memcached
$ brew install memcached

To have launchd start memcached at login:
    ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
Then to load memcached now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
Or, if you don't want/need launchctl, you can just run:
    /usr/local/opt/memcached/bin/memcached
  • redis
$ brew install redis

To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf
  • mongodb
$ brew install mongodb

To have launchd start mongodb at login:
    ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
    mongod
  • td-agent
$ brew install "http://toolbelt.treasure-data.com/brew/td-agent.rb"

td-agent configuration file and plugin directories were created:

    /usr/local/etc/td-agent/td-agent.conf
    /usr/local/etc/td-agent/plugin

You can invoke td-agent manually via td-agent command without launchctl:

    td-agent --pid /usr/local/var/run/td-agent/td-agent.pid

If you want to know the details of Fluentd, see Fluentd documents at:

    http://docs.fluentd.org/

To have launchd start td-agent at login:
    ln -sfv /usr/local/opt/td-agent/*.plist ~/Library/LaunchAgents
Then to load td-agent now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.td-agent.plist
  • groonga
$ brew install groonga
  • kyoto-cabinet / kyoto-tycoon
$ brew install kyoto-cabinet kyoto-tycoon
  • php53
$ brew tap homebrew/dupes
$ brew tap josegonzalez/php
$ brew install php53 --with-mysql --with-apache

To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php5_module    /usr/local/opt/php53/libexec/apache2/libphp5.so

The php.ini file can be found in:
    /usr/local/etc/php/5.3/php.ini

✩✩✩✩ PEAR ✩✩✩✩

If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
    chmod -R ug+w /usr/local/Cellar/php53/5.3.25/lib/php
    pear config-set php_ini /usr/local/etc/php/5.3/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that this php is
in your PATH:
    PATH="$(brew --prefix josegonzalez/php/php53)/bin:$PATH"
$ brew install php53-memcache

 * /usr/local/etc/php/5.3/conf.d/ext-memcache.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the memcache module.
  * If you see it, you have been successful!
$ brew install php53-mongodb

To finish installing mongo for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-mongo.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the mongo module.
  * If you see it, you have been successful!
$ brew install php53-redis

To finish installing redis for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-redis.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the redis module.
  * If you see it, you have been successful!
$ brew install php53-apc

To finish installing apc for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-apc.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the apc module.
  * If you see it, you have been successful!
==> Summary
$ brew install php53-mcrypt

To finish installing mcrypt for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-mcrypt.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the mcrypt module.
  * If you see it, you have been successful!

Applications

その他

  • DockにRecently Applicationを表示
$ defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'
$ killall Dock
  • 共有サーバへの接続問題
$ sudo sysctl -w net.inet.tcp.delayed_ack=0

$ sudo vi /etc/sysctl.conf

net.inet.tcp.delayed_ack=0

Boxen試すの忘れた

そういえば、GitHub謹製のセットアップツールを試そうと思ってたけど、すっかり忘れてた。

RubyMotionKaigi 2013 に行ってきた #rubymotionjp

RubyMotionKaigi 2013 に行ってきた。
名前を知ってるだけで、触ったこともないRubyMotionは、どんなものなんだろうと気になっていたので、参加してみた。

基調講演でのLaurentさんの話や、talkでの @watson1978 さん id:naoyaさんの話でおおまかな概要や、現在Webアプリを作ってる立場からのRubyMotionへの取り組み方などの話が聞けてとても良かった。

naoyaさんの話の中で、Vimは黒塗りされていたけれど、Keep your editorなのは、素晴らしいとおもう。XCodeを数年前にちょっとだけ触ってみて、心が折れたのは、editorのキーバインドだったし。

エンタプライズ用途にもつかえるというのが分かったし、Objective-CもCocoaTouchも覚えなきゃいけないよりは、RubyとCocoaTouch でいけるというのは、筋として良さそうに思う。

あと、今週の土曜日までは、RubyKaigi開催記念で15% Discountが行われてるので、いい機会だし、購入して勉強してみようかなと思った。
あと、もくもく会はすぐ埋まるらしいんだけど、RubyMotionKaigi内で他の勉強会が2つは開催されそうなので、タイミングが合えば行ってみたい。

会場提供の mixiさん、speakerの皆さん、主催、運営の皆さん、ありがとうございました!

Amazon Linux でカジュアルにyum updateをかけたらmoshが動かなくなったので対応したはなし

Amazon Linux(2012.09)を利用していて、moshをソースからインストールして、快適にサーバに接続していた状態だった。
yum update のアラートがでてて、カジュアルに yum update をかけたら、moshが動かなくなった。
状態としては、libprotobuf.so.6 がロードできなくなっていて、mosh-serverが起動できない。

暫定の解決として、protocol-bufferをrpmでインストールして、moshを入れなおしてみた。
yumで入れていたprotobuf-develをremove

# yum remove protobuf-devel

ソースコンパイルした場所でmoshをuninstall

# make uninstall


protocol-buffer のrpmを適当に検索して入手して、インストール

# wget http://ftp-srv2.kddilabs.jp/Linux/packages/fedora/epel/6/x86_64/protobuf-2.3.0-7.el6.x86_64.rpm
# rpm -ivh protobuf-2.3.0-7.el6.x86_64.rpm

これで、準備が整ったので、yum で mosh を再度インストール

# yum install --enablerepo=epel mosh

ここまででmosh-serverは起動するようになった。
再度、yum update のアラートがでて、yum update かけたら、

---> Package mosh.x86_64 0:1.2.3-1.el6 will be installed
--> Processing Dependency: libprotobuf.so.6()(64bit) for package: mosh-1.2.3-1.el6.x86_64
--> Finished Dependency Resolution
Error: Package: mosh-1.2.3-1.el6.x86_64 (epel)
           Requires: libprotobuf.so.6()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

と出てしまうけど、一旦は、放置することにした。

Twiiter BotをRubyで書いてherokuで動かした

TwitterBotを作ってみた。
実装自体は、つぶやくリストをtextでもっておいて、それをランダムにpostするだけの簡易的なもので、tweetする部分と認証部分は Twitter Gemにお任せした。

twitterの認証用のconsumer_key,consumer_secret,oauth_token,oauth_token_secretは heroku config で設定して、ENVで取得するようにした。

$ heroku config:add TWITTER_CONSUMER_KEY=hogehogehoghe
$ heroku config:add TWITTER_CONSUMER_SECRET=hogehogehoghe
$ heroku config:add TWITTER_OAUTH_TOKEN=hogehogehoghe
$ heroku config:add TWITTER_OAUTH_TOKEN_SECRET=hogehogehoghe

herokuのscheduler addonを使うとEvery10min,Hourly,Dailyで稼働させることができるので、addonを追加して、task設定してみた。

bundle exec ruby bot.rb


https://github.com/sferik/twitter
https://github.com/tknzk/tweet.bot

サーバーサイドエンジニアのためのJavaScript入門に行ってきた

@ginpei_jpさんが主催された、サーバーサイドエンジニアのためのJavaScript入門に行ってきた。
今まで雰囲気でJavaScriptを触っていて、いつまでもこのままじゃまずい感が漂っていたので、調度良い感じの勉強会だったので参加した。
基礎的なところをハッカソン的に手を動かしながら、学べたのでよかった。

やっぱり、基礎をある程度知っているっていうのは、大事だなあと改めて思い直した土曜の午後でした。ありがとうございました!


http://atnd.org/events/38994