Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-includes/theme.php on line 623

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/custom_posts/custom_posts.php on line 22

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/pukiwiki.php on line 46

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/pukiwiki.php on line 67

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/pukiwiki.php on line 75

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/pukiwiki.php on line 92

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/modPukiWiki/class/PukiWikiRender.php on line 70

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/modPukiWiki/class/PukiWikiElement.php on line 181

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/modPukiWiki/class/PukiWikiElement.php on line 538

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/modPukiWiki/class/PukiWikiElement.php on line 695

Deprecated: Assigning the return value of new by reference is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/modPukiWiki/class/PukiWikiElement.php on line 1087

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112

Deprecated: Function ereg() is deprecated in /home/users/1/fool.jp-ichi/web/blog/wp-content/plugins/wp-ban/wp-ban.php on line 112
おれせか

おれせか

なんかそれっぽいのをうにうに。

先代のMBP(OSはSnow Leopard)が死亡なされたので新しいMBP(OSはLion)購入。

spotlightとめる

とりあえず使わないのでspotlightをとめる。
参考:http://osxdaily.com/2011/12/10/disable-or-enable-spotlight-in-mac-os-x-lion/

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

メニューバーからも追放
参考:http://osxdaily.com/2011/12/12/hide-spotlight-menu-icon-mac-os-x-lion/

sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search && killall SystemUIServer

とりあえずなソフトをもろもろ入れる

  • Google日本語入力
    IME。これがないとはじまらない。
  • google chrome
    ブラウザ。
  • firefox
    ブラウザその2。
  • ClipMenu
    クリップボード拡張。ないと死ぬ。
  • TotalFinder
    Finderのタブ化&バイザー機能(どの画面上でもキーで最前面に呼び出せるようになる)付与。Spacesもりもりな僕はバイザー機能ないと死んじゃう。
  • TotalTerminal
    Terminalにバイザー機能。これもないと死んじゃう。
  • Asepsis
    しねぇ!.DS_Store!!
  • Echofon
    twitterクライアント。愚痴るためにも。
  • LimeChat
    IRCクライアント。愚痴るためにも。
  • Gyazo
    スクリーンショット共有。仕事なんかで文字で伝えるよりこっちのほうが早いほうが多々あるので必須。
  • Skype
    仕事でも使うので外せない。が、最新verはいろいろあれなのでお好みで旧バージョンなどでも。
  • DropBox
    ファイル共有ソフト。仕事でも使うのでマスト。
  • Transmit
    FTP/SFTPそのたもろもろクライアント。まだFTPなとこも多々あるのよ。
  • MailPlane
    Gmail用クライアント。複数アカウントの切り替えができるので便利。

あと開発関連のエディタやらなんやらも入れたり

  • Xcode
    iOSの開発に必須。いれるしかない。
  • CotEditor
    テキストエディタ。
  • Sublime Text 2
    テキストエディタその2。
  • Sequel Pro
    GUIのMySQLクライアント。
  • Dash
    documentとかsnipettのビューワ。HUD表示が便利。

homebrewいれる

パッケージ管理はhomebrewにする。
http://mxcl.github.com/homebrew/

まずはここにかいてあるRequirementsにしたがってCommand Line Tools for XcodeやらJava Developer Update 4を突っ込む。

で、インストールのコマンドをどっこいしょー。

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

インストールがすんだらいちおうupdateもしてみとく。

brew update

/etc/pathsで下記のように/usr/localを優先させるように変更

/usr/local/bin
/usr/bin
/bin
/usr/local/sbin
/usr/sbin
/sbin

gitやらemacsやらいれるぜー

brewでもりもり

brew install git
brew install git-flow
brew install emacs
brew install nkf

シェルをzshにするぜー

brewでいんすこ

brew install zsh

/etc/shellsにzshのパス追加

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/usr/local/bin/zsh

そしたら下記コマンドでログインシェル変更

chpass -s /usr/local/bin/zsh

.zshrcやら.emacs.dやらはまとめてgithubに投げてあるので取ってきて設置。

rbenvでrubyをいれる

まずbrewでrbenvいれる

brew install rbenv
brew install ruby-build

irbやpryで日本語表示したりのためのreadlineといちおうのopensslをオプションにつけてrubyインスコ

brew install readline
brew link readline
brew install openssl
brew link openssl
CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=/usr/local" rbenv install 1.9.3-p327

インスコ完了したらrbenvのデフォルトに設定。

rbenv global 1.9.3-p327

rbenvでなんかやったらとりあえずrehash

rbenv rehash

npmいれる

まずはnode入れる。

brew install nodejs

したら出てくる説明どおりに

curl http://npmjs.org/install.sh | sh

あとインストール後に出るメッセージにNODE_PATHに/usr/local/lib/node_modules設定せえよ的なことかかれてたのでとりあえずzshrcで

export NODE_PATH=/usr/local/lib/node_modules

てしといた。必要なのかわからん。

npmでcoffeeとかいれる

いるもんいれる。

npm install -g coffee-script
npm install -g js2coffee

npm install初回はindex作成がながいので気長に待つ。

あともしかしたら↑はjs2coffeeがcoffee-scriptに依存してるし、js2coffeeのinstallだけでcoffeescriptもはいったのかもしんない。

ローカルにmysqlたちあげる

http://tukaikta.blog135.fc2.com/blog-entry-197.html
このあたりを参考にしつつ。

brew install mysql

だけどたぶんbrewでのinstall時に出てくるメッセージに沿ってやればだいじょうぶ。

/etc/my.cnfを適当に設定かく

[mysqld]
character-set-server = utf8
innodb_buffer_pool_size = 256M
socket = /tmp/mysqld.sock

[mysql]
default-character-set = utf8

[client]
socket = /tmp/mysqld.sock

socketはまぁ好みで。
もちろん書いたらmysql再起動。

railsの仕事やってる最中なのでそのへん

今回のぷろじぇくとで必要そうなものをつっこんどく

brew install imagemagick
brew install memcached

install時に出てくるとおりにして自動起動に設定しておく

cp /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

とりあえずbundlerはふつうにgemでいれとく。

gem install bundler

プロジェクトをgitでcloneしてきて、プロジェクトdirにcd。

pathを指定してbundle

bundle install --path vendor/bundler

あとはbundle exec rails sするなど煮るなり焼くなり

そういえばruby1.9.3だとlogがうっとうしいことになるんでした
http://d.hatena.ne.jp/ria10/20120209/1328757610
というわけで
~/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/webrick/httpresponse.rb
を上記のURLにあるようにちょろっといじっとく。

apache+phpも設定しよう

とりあえずまずapache設定。

httpd.conf編集

sudo chmod u+w /etc/apache2/httpd.conf
sudo emacs /etc/apache2/httpd.conf

DocumentRoot変えたり。

もしシステム環境設定の[共有]->[Web共有]をOFFにしてる場合は http://taichino.com/engineer-life/2935 を参考にDocumentRoot周りの

<IfDefine WEBSHARING_ON>

</IfDefine>

を消すなり、web共有をONにするなりで対応します。

あとphpを有効にするために

LoadModule php5_module libexec/apache2/libphp5.so

の行がコメントアウトされてるのでそれを解除。

設定変更おえたらconfigtestで確認

sudo apachectl configtest

で問題なければ起動

sudo apachectl start

phpの設定もせな

最初php.iniがないので元のをコピって作ってから。

sudo cp /etc/php.ini.default /etc/php.ini
sudo chmod u+w /etc/php.ini
sudo emacs /etc/php.ini

timezoneの設定とかmysqlのsocket設定とかを変える。お好みで。

date.timezone = Asia/Tokyo
mysql.default_socket = /tmp/mysqld.sock

で、もちろんapache再起動

sudo apachectl restart

あいらぶSpaces。あいへいとMissionControl。

SnowLeopardの時にSpaces+Expose多用してた僕にとってはLionのMissionControlが糞に思えて仕方ない。
ので、どうにかなんないかなーと思ってたらめっけた。

  • TotalSpaces
    Spacesのようにデスクトップを複数段での切り替えに対応する。やばい。神すぎる。
    しかもTotalFinderとかと同じ会社じゃないですかー。この会社にお世話になりすぎや俺。

あと↓こんなこともしたり。
ウィンドウを隣りのデスクトップスペースに移動する時の待ち時間を変更する方法 - Macの手書き説明書

しかしあとExposeとかもSL時代のものになんないかなー。あとトラックパッドのジェスチャーも。

メニューバーにいろいろ出すの。

  • iStatMenus
    CPUやメモリや温度やらのグラフ表示。けっこうな高機能。
    ちょろっとメモリやらCPUの状態さえ見えればいいのよって場合は、無料のMenuMetersでもいいかもしらん。

今んとここんなもんかしら。

なんかあればまた追記。

PAGETOP
class Post
  has_many :comments
end

class Comment
  belongs_to :post
end

のときにassociation先のdefault_scopeをはずしたもの取得したい場合に、rails console上で色々試してたら

  Post.unscoped{ Comment.first.post }

はうまくいくのに、

  Comment.unscoped{ Post.first.comments }

はなぜかdefault_scopeはずれなくてウンウンうなってた。

ググってみたらStackOverflowでまさにそのものなコメントみつけた!
http://stackoverflow.com/a/10513528/1441888

For some strange reasons,

Comment.unscoped { Post.last.comments }

includes the default_scope of Comment,

however,

Comment.unscoped { Post.last.comments.to_a }
Comment.unscoped { Post.last.comments.order }

do not include the default_scope of Comment.

I experienced this in a rails console session with Rails 3.2.3.

わあい。まじStackOverflowさまさまやでー。

==追記==

Post.first.unscoped_comments

みたいなこと出来るようなのを雑に書いてみた。

https://gist.github.com/2888183

PAGETOP

carrierwave入れてローカル(development)環境で問題なくできたから、さーてUPするぞーと思ってcapistranoでdeployしたところ、なんか失敗する。

  〜略〜

  * 00:39:11 == Currently executing `bundle:install'
  * executing "ls -x /path/to/app/releases"
    servers: ["hoge.fuga.com"]
    [hoge.fuga.com] executing command
    command finished in 62ms
  * executing "cd /path/to/app/releases/20120605153902 && bundle install --gemfile /path/to/app/releases/20120605153902/Gemfile --path /path/to/app/shared/bundle --deployment --without development test"
    servers: ["hoge.fuga.com"]
    [hoge.fuga.com] executing command
 ** [out :: hoge.fuga.com] Invalid gemspec in [/path/to/app/shared/bundle/ruby/1.9.1/specifications/carrierwave-0.6.2.gemspec]: Illformed requirement ["# 1.1.4"]
 ** [out :: hoge.fuga.com] Fetching source index for http://rubygems.org/

  〜略〜

  * 20:13:12 == Currently executing `deploy:assets:precompile'
  * executing "cd /path/to/app/releases/20120605111227 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile"
    servers: ["hoge.fuga.com"]
    [hoge.fuga.com] executing command
 ** [out :: hoge.fuga.com] Could not find carrierwave-0.6.2 in any of the sources
    command finished in 1265ms
*** [deploy:update_code] rolling back

  〜略〜

教えてぐーぐる先生したりした。

結果、サーバー側で

gem update --system

したら解決した。

わあい。

=追記=
あ、もしapache+passengerとかで動かしてるならgemのupdate後にapache再起動しないとエラーでます。

PAGETOP

Search