さとうようぞうの技術メモ

技術的な内容はこっちに書こうかなぁ、と思ったので。

Ruby2.0.0 の RPM を作成

Virtualbox 上の CentOS 6.4 で作成。全部 root で作業

mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
yum groupinstall 'Development Tools'
yum install  -y readline-devel libyaml-devel gdbm-devel tcl-devel openssl-devel db4-devel libffi-devel wget
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz -P ./rpmbuild/SOURCES/
wget https://raw.github.com/hansode/ruby-2.0.0-rpm/master/ruby200.spec -P ./rpmbuild/SPECS
rpmbuild -bb rpmbuild/SPECS/ruby200.spec
rpm -i --test ./rpmbuild/RPMS/x86_64/ruby-2.0.0p353-2.el6.x86_64.rpm
rpm -i ./rpmbuild/RPMS/x86_64/ruby-2.0.0p353-2.el6.x86_64.rpm

実行環境

[vagrant@vagrant-centos64 ~]$ cat /etc/redhat-release 
CentOS release 6.4 (Final)

作成した RPM をインストールしようとすると、いくつかライブラリが足りないっぽい。

[vagrant@vagrant-centos64 ~]$ sudo rpm -Uvh /tmp/ruby-2.0.0p353-2.el6.x86_64.rpm
error: Failed dependencies:
        libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit) is needed by ruby-2.0.0p353-2.el6.x86_64
        libcrypto.so.10(libcrypto.so.10)(64bit) is needed by ruby-2.0.0p353-2.el6.x86_64
        libssl.so.10(libssl.so.10)(64bit) is needed by ruby-2.0.0p353-2.el6.x86_64
        libyaml-0.so.2()(64bit) is needed by ruby-2.0.0p353-2.el6.x86_64

Clojure を自宅の Ubuntu Linux にもインストール

インストール

clojure 本体

  • Ubuntu Software Center から以下を探す

  • 両方ともあっさり見つかったので、そのままインストール

f:id:yoozoosato:20130701231424p:plain

f:id:yoozoosato:20130701231429p:plain

emacs の拡張とか

  • emacs からいろいろできるように ELPA で必要そうなものをインストール
    • @TODO 他のマシンでも簡単にセットアップできるようにするため、後でインストールしたものを書きだして、 .el ファイルに保存しておく

f:id:yoozoosato:20130701233413p:plain

f:id:yoozoosato:20130701233420p:plain

ターミナルから repl 実行してみる

  • 問題なくうごいた

f:id:yoozoosato:20130701233818p:plain

emacs から実行できるか?

  • 適当なプロジェクトを作成して、そのディレクトリに移動
$ lein new demo
$ cd demo

f:id:yoozoosato:20130701234355p:plain

  • emacs から M-x nrepl-jack-in すると、以下のエラーが出てきてしまう
Exception Unsupported option(s) supplied: :headless  clojure.core/load-libs (core.clj:5266)
  • エラーメッセージでググると、このページがヒット
  • 今日は時間切れなので、原因調べて動かせるようにするのはまた今度。しばらくは repl でなんとかなるだろう。

プログラミングClojure 第2版

プログラミングClojure 第2版

Clojure を動かそうとして nrepl-jack-in が起動できない

Clojure を試しに動かしてみようと思って Mac にインストールしたものの、 Emacs から nrepl-jack-in する所でエラー。

error in process sentinel: Could not start nREPL server: zsh:1: command not found: lein

エラーメッセージでぐぐるとこのページがヒット。

Is Java installed in the same place as lein?

とか書いてあるので、多分、

  • java と lein のインストールパスが違う
    • java は Mac に標準で付いているやつで、 /usr/bin/java にある
    • lein は port でインストールしたので /opt/local/bin/lein にある

というのが問題なのかと思い、

sudo ln -s /opt/local/bin/lein /usr/bin/lein

としてみたら起動できた。

アメリカ用の application.rb

config.time_zone と config.i18n.default_locale を変えてやる。 time_zone に指定する値は rake time:zones:all するとリストが出てくるので、該当するものをセットすればいいらしい。

bundle exec rake time:zones:all

* UTC -11:00 *
American Samoa
International Date Line West
Midway Island

* UTC -10:00 *
Hawaii

* UTC -09:00 *
Alaska

* UTC -08:00 *
Pacific Time (US & Canada)
Tijuana

* UTC -07:00 *
Arizona
Chihuahua
Mazatlan
Mountain Time (US & Canada)

* UTC -06:00 *
Central America
Central Time (US & Canada)
Guadalajara
Mexico City
Monterrey
Saskatchewan
(以下略)

西海岸なので、 Pacific Time (US & Canada) を指定すれば大丈夫そう。 後は locale を :en とかにしておけば、英語で表示されるはず。

rvmsudo rails s -p 80 しようとしてエラー

rails を port 80 で起動しようと rvmsudo を使ったら以下のエラーが出た.

rvmsudo rails server -p 80
Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning.Password:
/Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': dlopen(/Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `each'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `block in require'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler.rb:119:in `require'
        from /Users/yz/Documents/work/gamepot/AeriaGames/DG/repo/dg2_code/dg2-server/config/application.rb:7:in `<top (required)>'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/railties-3.2.11/lib/rails/commands.rb:53:in `require'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/railties-3.2.11/lib/rails/commands.rb:53:in `block in <top (required)>'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
        from /Users/yz/.rvm/gems/ruby-1.9.3-p194@dg2/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

ぐぐったら Stack Overflow に解決策が書いてあったので、その通りに実行。

 

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib


再度実行。

rvmsudo rails server -p 80
Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning.WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.3
=> Booting WEBrick
=> Rails 3.2.11 application starting in development on http://0.0.0.0:80
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-03-19 11:05:23] INFO  WEBrick 1.3.1
[2013-03-19 11:05:23] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin11.4.0]
[2013-03-19 11:05:23] INFO  WEBrick::HTTPServer#start: pid=13357 port=80

Warning は出るけど、80で起動できた。

MacBook に R をインストールした。

統計とかに便利というアレね。

環境は MacBook Pro '15 + Mac OS X 10.7.5

port でもインストールできるみたいだけど、公式で配布されているバージョンの方が新しそうだったので、日本の適当なミラーサイトから、Mac用のバイナリをダウンロード。

f:id:yoozoosato:20121122141452j:plain

ダウンロードリンクをクリックすると、.pkg形式のファイルが取得できるので、ダブルクリックでインストーラーが開く。

f:id:yoozoosato:20121122141810p:plain

インストラーの指示通りに "Continue" を押して行けば(しばらく待つけど)インストールはあっさりと完了。Applications フォルダに R と R64 ってのがインストールされた。

f:id:yoozoosato:20121122142055j:plain

R64をダブルクリックで起動。

f:id:yoozoosato:20121122142414p:plain

赤い文字で

WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly.

と言われるので、メニューから "Help" → "R For Mac OS X FAQ" の "Internationalization of the R.app" を見る。

f:id:yoozoosato:20121122142957p:plain

f:id:yoozoosato:20121122143003p:plain

force.LANG を使えば、設定を上書きできるよ、と書いてある。

f:id:yoozoosato:20121122143107j:plain

ターミナルから

defaults write org.R-project.R force.LANG en_US.UTF-8

を入力。

f:id:yoozoosato:20121122143246p:plain

警告出なくなった。

Rによるやさしい統計学

Rによるやさしい統計学

The R Tips―データ解析環境Rの基本技・グラフィックス活用集

The R Tips―データ解析環境Rの基本技・グラフィックス活用集