2011年12月31日土曜日

[Music] 12月購入リスト

nujabes
12月の購入リストを残す。

・Nujabes / spiritual state
これが最後になるのが、本当に残念でならない、遺作となる3rdアルバム。
今作でもその美しいメロディは変わらず、フィーチャーされたアーティストたちとの融合もすばらしい。(Track8: 「Yes」とか最高にカッコいい)

いつ聴いてもリラックスできる大切な一枚。

・Little Dragon / Ritual Union
思い出したように購入。楽しそうに音楽するなぁ。ホントに楽しそう。
ボーカル Yukimi Naganoも精力的にコラボしてるし、一度、生で聴いてみたいものだ。


・Bon Iver / Bon Iver
一聴するだけで、フォークロックの枠にはめられない多彩さを感じる。
ポストロック的なベースラインの上に、丁寧に歌い上げるファルセット・ボイスが印象的。
鳴らすだけで、ゆっくりとした時間が流れる。そんな一枚。


・Teebs / Collections 01
海外でアナログLPのみ発売された、Teebsの新作が日本独自CD化。 新作と言えど、フルアルバムの位置付けではなく、アイディアのコレクションの一部(本人談)とのこと。 確かに曲間の繋がりは感じられないが、十分にその多彩で美しい音世界を堪能できる作品集。

コメント: 12月は見事に癒しアルバムが占めました。

2011年12月20日火曜日

[Python][Mining the Social Web] Graphviz+pygraphvizのインストール

引き続き、「入門ソーシャルデータ」に沿ってデータマイニングに取り組みます。

ソーシャルデータの可視化のために、Graphvizとpygraphvizをインストールします。

Graphviz :DOTという言語出力ファイルを基に、グラフを生成するツールとして有名です。
pygraphviz:pythonを用いて、DOTファイルを生成します。

Mac OSX Lion用のインストールパッケージをダウンロードします。
http://www.graphviz.org/Download_macos.php

パッケージ名:graphviz-2.28.0.pkg

graphviz-2.28.0.pkgをダブルクリックするとインストーラが起動します。
続けるをクリックしていき、インストールを完了します。

次にpygraphvizのインストールです。
例のごとく、easy_installを使用しますが、そのまま実行するとエラーが出ました。

# easy_install pygraphviz
Searching for pygraphviz
Reading http://pypi.python.org/simple/pygraphviz/
Reading http://networkx.lanl.gov/pygraphviz
Reading http://networkx.lanl.gov/download/pygraphviz
Reading http://networkx.lanl.gov/wiki/download
Reading http://networkx.lanl.gov/download
Reading http://sourceforge.net/project/showfiles.php?group_id=122233&package_id=161979
Best match: pygraphviz 1.1
Downloading http://networkx.lanl.gov/download/pygraphviz/pygraphviz-1.1.tar.gz
Processing pygraphviz-1.1.tar.gz
Running pygraphviz-1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-xlJIBD/pygraphviz-1.1/egg-dist-tmp-qS3unp
Trying pkg-config
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
Trying dotneato-config
Failed to find dotneato-config

Your Graphviz installation could not be found.

1) You don't have Graphviz installed:
Install Graphviz (http://graphviz.org)

2) Your Graphviz package might incomplete.
Install the binary development subpackage (e.g. libgraphviz-dev or similar.)

3) You are using Windows
There are no PyGraphviz binary packages for Windows but you might be
able to build it from this source. See
http://networkx.lanl.gov/pygraphviz/reference/faq.html

If you think your installation is correct you will need to manually
change the include_path and library_path variables in setup.py to
point to the correct locations of your graphviz installation.

The current setting of library_path and include_path is:
library_path=None
include_path=None

error: None

パスが通ってないようですが、対処がわかりません。
pipを使用するのはどうかと。

# pip install pygraphviz
Downloading/unpacking pygraphviz
Downloading pygraphviz-1.1.tar.gz (90Kb): 90Kb downloaded
Running setup.py egg_info for package pygraphviz
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
Trying pkg-config
Trying dotneato-config
Failed to find dotneato-config

Your Graphviz installation could not be found.

1) You don't have Graphviz installed:
Install Graphviz (http://graphviz.org)

2) Your Graphviz package might incomplete.
Install the binary development subpackage (e.g. libgraphviz-dev or similar.)

3) You are using Windows
There are no PyGraphviz binary packages for Windows but you might be
able to build it from this source. See
http://networkx.lanl.gov/pygraphviz/reference/faq.html

If you think your installation is correct you will need to manually
change the include_path and library_path variables in setup.py to
point to the correct locations of your graphviz installation.

The current setting of library_path and include_path is:
library_path=None
include_path=None

Traceback (most recent call last):
File "", line 14, in
File "/private/var/root/build/pygraphviz/setup.py", line 89, in
raise OSError,"Error locating graphviz."
OSError: Error locating graphviz.
Complete output from command python setup.py egg_info:
/bin/sh: pkg-config: command not found

/bin/sh: pkg-config: command not found

Trying pkg-config

Trying dotneato-config

Failed to find dotneato-config



Your Graphviz installation could not be found.



1) You don't have Graphviz installed:

Install Graphviz (http://graphviz.org)



2) Your Graphviz package might incomplete.

Install the binary development subpackage (e.g. libgraphviz-dev or similar.)



3) You are using Windows

There are no PyGraphviz binary packages for Windows but you might be

able to build it from this source. See

http://networkx.lanl.gov/pygraphviz/reference/faq.html



If you think your installation is correct you will need to manually

change the include_path and library_path variables in setup.py to

point to the correct locations of your graphviz installation.



The current setting of library_path and include_path is:

library_path=None

include_path=None



Traceback (most recent call last):

File "", line 14, in

File "/private/var/root/build/pygraphviz/setup.py", line 89, in

raise OSError,"Error locating graphviz."

OSError: Error locating graphviz.

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /var/root/.pip/pip.log

include_path、library_path variablesについて、graphvizをインストールした場所にパスを通す必要があるようです。
指示通りsetup.pyを編集します。

# OSX, Linux, alternate location
library_path='/usr/local/lib/graphviz'
include_path='/usr/local/include/graphviz'

再度、インストール実行で無事インストールできました。

2011年11月28日月曜日

[Python][Mining the Social Web]Twitter APIを使用してデータを集める

Twitter APIを使用するためのPythonパッケージを追加し、実際にTwitterデータにアクセスしてみる。

$ sudo easy_install twitter
Searching for twitter
Reading http://pypi.python.org/simple/twitter/
Reading http://mike.verdone.ca/twitter/
Best match: twitter 1.7.2
Downloading http://pypi.python.org/packages/source/t/twitter/twitter-1.7.2.tar.gz#md5=a81b512cc8be5ba278bdaceb6d988fe6
Processing twitter-1.7.2.tar.gz
Running twitter-1.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1iZuPg/twitter-1.7.2/egg-dist-tmp-7cd07T
Adding twitter 1.7.2 to easy-install.pth file
Installing twitter-stream-example script to /usr/local/bin
Installing twitter script to /usr/local/bin
Installing twitterbot script to /usr/local/bin
Installing twitter-log script to /usr/local/bin


Installed /Library/Python/2.7/site-packages/twitter-1.7.2-py2.7.egg
Processing dependencies for twitter
Finished processing dependencies for twitter


パッケージドキュメントを読むためにはpydocを実行する。
*nix : pydoc twitter.Twitter
(Windows : python -mpydoc twitter.Twitter)

TwitterのトレンドAPIを実行してみるが、エラー発生。
$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import twitter
>>> twitter_api = twitter.Twitter(domain="api.twitter.com", api_version='1')
>>> trends = twitter_api.trends()
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.7-intel/egg/twitter/api.py", line 165, in __call__
File "build/bdist.macosx-10.7-intel/egg/twitter/api.py", line 180, in _handle_response
twitter.api.TwitterHTTPError: Twitter sent status 404 for URL: 1/trends.json using parameters: ()
details:

はて、404エラー出てるな。
とりあえず、本文に記載のURL:http://search.twitter.com/1/trends.jsonを入力してみるがこちらもエラー。
よく見ると、このURLってhttp指定してるけど、Twitterってhttps使うように変わったような...

と、いうことでTwitter API のドキュメントを確認してみる。
https://dev.twitter.com/docs/api/1/get/trends/%3Awoeid

やっぱり、API仕様変わってますね。ということで、モジュール修正が必要だな。

[Music] 2011年11月購入リスト


11月の購入リストを残す。

・Derrick May / Heartbeat Presents Mixed By Derrick May×AIR Vol.2

Derrick May/代官山AIRコラボMixの第2弾。
今作も一切手抜きなし。これほどクラブにいる感覚を味合わせてくれるMix作れるのは「Derrick May」だから。


・Surkin / USA

「Action Replay」から4年、待ちに待った作品。
フレンチエレクトロと言えば、「Justice」じゃなくて「Surkin」ですね。個人的には。 カッコいいです。



・DJ Shadow / The Less You Know The Better

ジャケがお茶目です。原点回帰とか言われてるのは、正直わからんですが、いいものはいいと。

Little Dragonとのコラボ曲(Scale It Back)とか嬉しいし、すばらしい作品です。




コメント: 12/2は遂にNujabes新譜発売ですね。

[Python][Mining the Social Web] easy_installでモジュール追加

Mining the Social Web(オライリー刊)を参考に分析を進めていくための準備

Pythonでモジュール管理はeasy_installを使用するのがベター。
Macでも変わらない。

NetworkXモジュールはグラフを作り、分析し、類似する出力を観察するために使用するようだ。
$ sudo easy_install networkx
Searching for networkx
Reading http://pypi.python.org/simple/networkx/
Reading http://networkx.lanl.gov/
Reading http://networkx.lanl.gov/download/networkx
Reading http://sourceforge.net/project/showfiles.php?group_id=122233
Reading https://networkx.lanl.gov
Reading http://networkx.lanl.gov/download
Reading http://networkx.lanl.gov
Best match: networkx 1.6
Downloading http://networkx.lanl.gov/download/networkx/networkx-1.6-py2.7.egg
Processing networkx-1.6-py2.7.egg
creating /Library/Python/2.7/site-packages/networkx-1.6-py2.7.egg
Extracting networkx-1.6-py2.7.egg to /Library/Python/2.7/site-packages
Adding networkx 1.6 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/networkx-1.6-py2.7.egg
Processing dependencies for networkx
Finished processing dependencies for networkx

Numpyは科学計算用ツール。NetworkXが依存関係にある。
$ sudo easy_install numpy
Searching for numpy
Best match: numpy 1.5.1
Adding numpy 1.5.1 to easy-install.pth file

Using /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Processing dependencies for numpy
Finished processing dependencies for numpy

NoseはPythonのテストツール
$ sudo easy_install nose
Searching for nose
Reading http://pypi.python.org/simple/nose/
Reading http://somethingaboutorange.com/mrl/projects/nose/
Reading http://readthedocs.org/docs/nose/
Best match: nose 1.1.2
Downloading http://pypi.python.org/packages/source/n/nose/nose-1.1.2.tar.gz#md5=144f237b615e23f21f6a50b2183aa817
Processing nose-1.1.2.tar.gz
Running nose-1.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UusYYV/nose-1.1.2/egg-dist-tmp-UafvfE
Adding nose 1.1.2 to easy-install.pth file
Installing nosetests script to /usr/local/bin
Installing nosetests-2.7 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg
Processing dependencies for nose
Finished processing dependencies for nose


以上です。

2011年10月27日木曜日

[Music]10月購入リスト

10月度の購入リストを残す。

・Apparat / The Devil's Walk
DJ Kicksなど良質なMixリリースやModeselektorとのコラボModerat名義のリリースを経て、4年ぶりの新作をリリース。
ジャケからは想像つかない、美しく繊細なビート。ボーカルを大きく取り入れたことにより、これまでとひと味違う心地よい作品に仕上がっている。

・Coldplay / Mylo Xyloto
前作以上にポップ感が全面に出ている。今作の一番の魅力も、やはり伸びやかなクリスのボーカル。

・Modeselektor / Monkeytown
今作も独特の不穏な雰囲気、ビートは健在。
Modeselektorってこうだよな、とある意味安心。

・The Field / Looping State Of Mind
相変わらずピークまでの組み立てがうまくてワクワクする。気持ちいい。

コメント: Justiceは様子見。

2011年9月23日金曜日

[Design]Feltron Annual Report

Facebookの新しいタイムラインをデザインした人物が手がけた、私的レポート(年報)があまりに素晴らしかったので、記録しておく。

その人物とは、Nicholas Felton。
彼は、1年に1冊、個人的なトピックをまとめたレポートを公開してきた。

そのコンテンツを構成するビジュアルは簡潔で、直感的で、本当に素晴らしい。
無駄な要素が全くない。その年報を見たFacebookのお偉いさん(いち時期Facebookはデザイン部門の強化に奔走していた)がFeltonを抱え込んだというという話。

そのコンテンツは以下に。こんなデザインセンスを身につけたい。
Feltron Annual Report

Facebookのお偉いさんの話。
デザインとデータの交差点で、Facebookのタイムラインは生まれた

2011年8月15日月曜日

[Emacs]さくらVPSセットアップ

前回、さくらVPSの環境にLAMP環境を構築しました。

今回は開発環境らしくするため、Emacsをインストールします。

■gccをインストール
gccが入っていないとはじまりませんな。
$yum install gcc*

■Emacsをインストール
ソースGet!
$ wget ftp://ftp.ring.gr.jp/pub/GNU/emacs/emacs-23.1.tar.gz
$ wget http://ftp.gnu.org/pub/gnu/emacs/emacs-23.1.tar.gz
$ tar xzf emacs-23.1.tar.gz
$ ls -la

$ ./configure --without-x
$ make
$ make install
$ emacs --version
GNU Emacs 23.1.1
Copyright (C) 2009 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Emacs設定ファイルの配置
私は各種設定ファイルをさまざまな環境で共有できるようにDropboxに保存しています。

今回もDropboxからファイルダウンロードして配置しようかと思いましたが、
以下のページを見つけてこのやり方はまずいかなと、再検討しております。

さくらVPSでDropboxをX11なしで使う
Dropboxを使うな、とまでは言いませんが

とりあえず、".emacs"は作成したけれど、何か良い手はないものか。

2011年8月7日日曜日

[LAMP][CentOS]さくらVPSセットアップ

■概要
さくらVPSにLAMP環境を構築します。

■基本情報
OS   : CentOS 5(2011/8時点の最小構成)
ディスク: 20GB
メモリ : 512MB

■パッケージ確認
Apache、MySQL、PHPそれぞれのインストールパッケージを確認します。
# yum list | grep httpd
httpd.x86_64 2.2.3-45.el5.centos.1 updates
httpd-devel.i386 2.2.3-45.el5.centos.1 updates
httpd-devel.x86_64 2.2.3-45.el5.centos.1 updates
httpd-manual.x86_64 2.2.3-45.el5.centos.1 updates
system-config-httpd.noarch 5:1.3.3.3-1.el5 base

# yum list | grep mysql
apr-util-mysql.x86_64 1.2.7-11.el5_5.2 base
bytefx-data-mysql.x86_64 1.2.4-2.el5.centos extras
freeradius-mysql.x86_64 1.1.3-1.6.el5 base
freeradius2-mysql.x86_64 2.1.7-7.el5 base
libdbi-dbd-mysql.x86_64 0.8.1a-1.2.2 base
mod_auth_mysql.x86_64 1:3.0.0-3.2.el5_3 base
mysql.i386 5.0.77-4.el5_6.6 updates
mysql.x86_64 5.0.77-4.el5_6.6 updates
mysql-bench.x86_64 5.0.77-4.el5_6.6 updates
mysql-connector-odbc.x86_64 3.51.26r1127-1.el5 base
mysql-devel.i386 5.0.77-4.el5_6.6 updates
mysql-devel.x86_64 5.0.77-4.el5_6.6 updates
mysql-server.x86_64 5.0.77-4.el5_6.6 updates
mysql-test.x86_64 5.0.77-4.el5_6.6 updates
pdns-backend-mysql.x86_64 2.9.21-4.el5.centos extras
php-mysql.x86_64 5.1.6-27.el5_5.3 base
php-pear-MDB2-Driver-mysql.noarch 1.4.1-3.el5.centos extras
php53-mysql.x86_64 5.3.3-1.el5_6.1 updates
qt4-mysql.x86_64 4.2.1-1 base
rsyslog-mysql.x86_64 3.22.1-3.el5_6.1 updates

# yum list | grep php
php.x86_64 5.1.6-27.el5_5.3 base
php-bcmath.x86_64 5.1.6-27.el5_5.3 base
php-cli.x86_64 5.1.6-27.el5_5.3 base
php-common.x86_64 5.1.6-27.el5_5.3 base
php-dba.x86_64 5.1.6-27.el5_5.3 base
php-dbase.x86_64 5.1.6-15.el5.centos.1 extras
php-devel.x86_64 5.1.6-27.el5_5.3 base
php-gd.x86_64 5.1.6-27.el5_5.3 base
php-imap.x86_64 5.1.6-27.el5_5.3 base
php-ldap.x86_64 5.1.6-27.el5_5.3 base
php-mbstring.x86_64 5.1.6-27.el5_5.3 base
php-mcrypt.x86_64 5.1.6-15.el5.centos.1 extras
php-mhash.x86_64 5.1.6-15.el5.centos.1 extras
php-mssql.x86_64 5.1.6-15.el5.centos.1 extras
php-mysql.x86_64 5.1.6-27.el5_5.3 base
php-ncurses.x86_64 5.1.6-27.el5_5.3 base
php-odbc.x86_64 5.1.6-27.el5_5.3 base
php-pdo.x86_64 5.1.6-27.el5_5.3 base
php-pear.noarch 1:1.4.9-6.el5 base
php-pear-Auth-SASL.noarch 1.0.2-4.el5.centos extras
php-pear-DB.noarch 1.7.13-1.el5.centos extras
php-pear-Date.noarch 1.4.7-2.el5.centos extras
php-pear-File.noarch 1.2.2-1.el5.centos extras
php-pear-HTTP-Request.noarch 1.4.2-1.el5.centos extras
php-pear-Log.noarch 1.9.13-1.el5.centos extras
php-pear-MDB2.noarch 2.4.1-2.el5.centos extras
php-pear-MDB2-Driver-mysql.noarch 1.4.1-3.el5.centos extras
php-pear-Mail.noarch 1.1.14-1.el5.centos extras
php-pear-Mail-Mime.noarch 1.4.0-1.el5.centos extras
php-pear-Net-SMTP.noarch 1.2.10-1.el5.centos extras
php-pear-Net-Sieve.noarch 1.1.5-2.el5.centos extras
php-pear-Net-Socket.noarch 1.0.8-1.el5.centos extras
php-pear-Net-URL.noarch 1.0.15-1.el5.centos extras
php-pecl-Fileinfo.x86_64 1.0.4-3.el5.centos extras
php-pecl-memcache.x86_64 2.2.3-1.el5_2 extras
php-pgsql.x86_64 5.1.6-27.el5_5.3 base
php-readline.x86_64 5.1.6-15.el5.centos.1 extras
php-snmp.x86_64 5.1.6-27.el5_5.3 base
php-soap.x86_64 5.1.6-27.el5_5.3 base
php-tidy.x86_64 5.1.6-15.el5.centos.1 extras
php-xml.x86_64 5.1.6-27.el5_5.3 base
php-xmlrpc.x86_64 5.1.6-27.el5_5.3 base
php53.x86_64 5.3.3-1.el5_6.1 updates
php53-bcmath.x86_64 5.3.3-1.el5_6.1 updates
php53-cli.x86_64 5.3.3-1.el5_6.1 updates
php53-common.x86_64 5.3.3-1.el5_6.1 updates
php53-dba.x86_64 5.3.3-1.el5_6.1 updates
php53-devel.x86_64 5.3.3-1.el5_6.1 updates
php53-gd.x86_64 5.3.3-1.el5_6.1 updates
php53-imap.x86_64 5.3.3-1.el5_6.1 updates
php53-intl.x86_64 5.3.3-1.el5_6.1 updates
php53-ldap.x86_64 5.3.3-1.el5_6.1 updates
php53-mbstring.x86_64 5.3.3-1.el5_6.1 updates
php53-mysql.x86_64 5.3.3-1.el5_6.1 updates
php53-odbc.x86_64 5.3.3-1.el5_6.1 updates
php53-pdo.x86_64 5.3.3-1.el5_6.1 updates
php53-pgsql.x86_64 5.3.3-1.el5_6.1 updates
php53-process.x86_64 5.3.3-1.el5_6.1 updates
php53-pspell.x86_64 5.3.3-1.el5_6.1 updates
php53-snmp.x86_64 5.3.3-1.el5_6.1 updates
php53-soap.x86_64 5.3.3-1.el5_6.1 updates
php53-xml.x86_64 5.3.3-1.el5_6.1 updates
php53-xmlrpc.x86_64 5.3.3-1.el5_6.1 updates

Apache2.2系、MySQL5.0系、PHP5.1系がインストール可能です。

■Apache
# yum -y install httpd
# httpd -v
Server version: Apache/2.2.3
Server built: May 4 2011 06:51:15

■MySQL

今回、MySQLは5.5系、PHPは5.3系をインストールしたい為、サードパーティのリポジトリを指定してインストールします。

リポジトリの登録
# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# yum --enablerepo=remi install mysql mysql-server

MySQLサーバ起動
# /etc/rc.d/init.d/mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

失敗する。ログを確認してみる。
# cat /var/log/mysqld.log
110807 20:03:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110807 20:03:29 [ERROR] Error message file '/usr/share/mysql/english/errmsg.sys' had only 480 error messages,
but it should contain at least 712 error messages.
Check that the above file is the right version for this program!
110807 20:03:29 [Note] Plugin 'FEDERATED' is disabled.
/usr/libexec/mysqld: Unknown error 1146
110807 20:03:29 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110807 20:03:29 InnoDB: The InnoDB memory heap is disabled
110807 20:03:29 InnoDB: Mutexes and rw_locks use GCC atomic builtins
110807 20:03:29 InnoDB: Compressed tables use zlib 1.2.3
110807 20:03:29 InnoDB: Using Linux native AIO
110807 20:03:29 InnoDB: Initializing buffer pool, size = 128.0M
110807 20:03:29 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
110807 20:03:29 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
110807 20:03:30 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
110807 20:03:30 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
110807 20:03:31 InnoDB: Waiting for the background threads to start
110807 20:03:32 InnoDB: 1.1.8 started; log sequence number 0
110807 20:03:32 [ERROR] Aborting

110807 20:03:32 InnoDB: Starting shutdown...
110807 20:03:33 InnoDB: Shutdown completed; log sequence number 1595675
110807 20:03:33 [Note]
110807 20:03:33 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

メッセージファイル(/usr/share/mysql/english/errmsg.sys)の競合が発生しているようです。

該当ファイルの競合を確認
# rpm -q --whatprovides /usr/share/mysql/english/errmsg.sys
mysql-libs-5.5.15-1.el5.remi
mysql-5.0.77-4.el5_6.6

2つのバージョンが競合していることが分かりました。現状のmysqlをいったん削除します。
# yum -y remove mysql mysql-server mysql-libs

明示的にバージョン指定
# yum --enablerepo=remi install mysql-server.x86_64
# yum --enablerepo=remi install mysql-devel.x86_64

# mysql_install_db

# /etc/rc.d/init.d/mysqld start

因みにMySQL5.5系ではmy.cnfに以下の設定を記述すると起動しない。innodbがデフォルトエンジンだからかも。 
設定内容:skip_innodb

■PHP
# yum install -y --enablerepo=remi php
# php -v
PHP 5.3.6 (cli) (built: May 16 2011 19:18:05)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

以上です。

2011年7月18日月曜日

[Windows][Cygwin]新規ユーザを追加する

■概要
Cygwinではuseradd(UNIXでのユーザ追加コマンド)が存在しません。

■ユーザ登録
ユーザの追加はWindowsのユーザを/etc/passwdファイルに追記します。
mkpasswd -l -u UserName >> /etc/passwd

以上です。

2011年7月10日日曜日

[Linux][CentOS]新規ユーザを追加する

■概要
Linuxで新しくサーバを構築する際に、必ず実行する手順であるユーザの追加方法を
まとめます。

以下CentOSで作業しますが、bashが使える環境であれば同様のコマンドを
使用できます。

■ユーザ登録
セキュリティ上、rootユーザは使用しないポリシーとし、
新規ユーザに適切なsudo権限を付与する運用がベターです。

・新規ユーザ用グループを作成

※rootユーザで作業する

# groupadd appmng

・新規ユーザ作成
# useradd -g appmng appmng
# ls -l /home/
合計 4
drwx------ 2 appmng appmng 4096  7月  1 15:28 2011 appmng
⇒作成されていること

・新規ユーザのパスワードを変更する
# passwd appmng
ユーザー appmng のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。

・新規ユーザにsudo権限を付与します。
# cp -pi /etc/sudoers /etc/sudoers.YYYYMMDD
# vim /etc/sudoers
ppmng  ALL=(ALL)       ALL

・rootユーザでの作業を終了します。
# exit

・新規ユーザのログイン確認
$ ssh appmng@xxx.xxx.xxx.xxx
$ uname -n
⇒ホスト名が表示される
$ id
uid=500(appmng) gid=500(appmng) 所属グループ=500(appmng)


以上です。

2011年5月31日火曜日

[Ruby] gem updateがエラーとなった場合の対応

■概要
gem updateのエラーごとの対応をまとめていく

1.Proxy認証エラー
$ gem update --system
Updating RubyGems
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: 対象のコンピュータによって拒否されたため、接続できませ
んでした。 - connect(2) (http://gems.rubyforge.org/yaml)

Proxy認証を通すコマンドは以下の通り
gem update --system --http-proxy http://User:Passward@Proxy_Server:Port_No

以上です。

2011年5月11日水曜日

[Deploy][Mac] Capistranoコマンド試行

前回、Capistranoをセットアップしました。
[Deploy][Mac] Capistranoセットアップ

今回は実際にコマンドを発行してみます。

まずローカルでCapfileという設定ファイルを作成します。
ファイルはどこで作成しても問題ありません。

$ vim Capfile
set :user, 'app' // 実行ユーザを指定。ここでは前回作成したappユーザを指定します。
task :diskcheck, :hosts => "192.168.251.131" do // タスク名と実行ホストを指定。
run "df -kh" // 実行コマンドを指定。ここではリモートサーバのディスク使用量を確認するコマンドを指定してみます。
end

Capfileを作成したら、実際にコマンドを発行してみます。
$cap diskcheck
* executing `diskcheck'
* executing "df -kh"
servers: ["192.168.251.131"]
[192.168.251.131] executing command
** [out :: 192.168.251.131] Filesystem サイズ 使用 残り 使用% マウント位置
** [out :: 192.168.251.131] /dev/mapper/VolGroup00-LogVol00
** [out :: 192.168.251.131] 18G 5.9G 11G 36% /
** [out :: 192.168.251.131] /dev/sda1 99M 12M 82M 13% /boot
** [out :: 192.168.251.131] tmpfs 506M 0 506M 0% /dev/shm
command finished in 130ms

対応するタスクが実行され、リモートサーバのディスク使用量を確認することができました。

Capistranoにはデプロイ用のタスクが予め多数用意されていて、それを使用することでデプロイを容易に行うことができます。
次回からはデプロイ用タスクを掘り下げて行きます。


以上です。

2011年5月7日土曜日

[Deploy][Mac] Capistranoセットアップ

自宅MacにCapistranoをインストールして、いろいろやってみようという試み。

CapistranoはRubyで動作する有名なデプロイツール。インストールはgemを使用する。

インストール前にgemをアップデート。
$sudo gem update --system
Password:
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.8.4
Updating RubyGems to 1.8.4
Installing RubyGems 1.8.4
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/commands/update_command.rb:153: warning: Insecure world writable dir /usr/local/share in PATH, mode 040777
RubyGems 1.8.4 installed

=== 1.8.4 / 2011-05-25

* 1 minor enhancement:

* Removed default_executable deprecations from Specification.


------------------------------------------------------------------------------

RubyGems installed the following executables:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

次にcapistranoがインストールされていないことを確認する。
$gem list capistrano

*** LOCAL GEMS ***

上記の場合はインストールされていない。
続けてインストールコマンドを実行する。
$sudo gem install capistrano
Password:
Fetching: highline-1.6.2.gem (100%)
Fetching: net-ssh-2.1.4.gem (100%)
Fetching: net-sftp-2.0.5.gem (100%)
Fetching: net-scp-1.0.4.gem (100%)
Fetching: net-ssh-gateway-1.1.0.gem (100%)
Fetching: capistrano-2.6.0.gem (100%)
Successfully installed highline-1.6.2
Successfully installed net-ssh-2.1.4
Successfully installed net-sftp-2.0.5
Successfully installed net-scp-1.0.4
Successfully installed net-ssh-gateway-1.1.0
Successfully installed capistrano-2.6.0
6 gems installed
Installing ri documentation for highline-1.6.2...
Installing ri documentation for net-ssh-2.1.4...
Installing ri documentation for net-sftp-2.0.5...
Installing ri documentation for net-scp-1.0.4...
Installing ri documentation for net-ssh-gateway-1.1.0...
Installing ri documentation for capistrano-2.6.0...
Installing RDoc documentation for highline-1.6.2...
Installing RDoc documentation for net-ssh-2.1.4...
Installing RDoc documentation for net-sftp-2.0.5...
Installing RDoc documentation for net-scp-1.0.4...
Installing RDoc documentation for net-ssh-gateway-1.1.0...
Installing RDoc documentation for capistrano-2.6.0...

capistranoのバージョンを確認する。
以下のようにバージョンが表示されれば正常にインストールされている。
$cap --version
Capistrano v2.6.0

次にsshの準備を行う。
すでに作成済みの公開鍵をデプロイ対象のサーバにアップロードする。
※未作成の場合は$ssh-keygenを実行し鍵を作成する。

今回はVM上に構築したCentOS環境にアップロードします。
$scp -p .ssh/id_rsa.pub radengineer@192.168.251.131:~
radengineer@192.168.251.131's password:
id_rsa.pub 100% 410 0.4KB/s 00:00

公開鍵を配置
$ mkdir -m 700 .ssh
$ cat id_rsa.pub >> .ssh/authorized_keys

また、デプロイ用に共有アカウントを用意します。
$ sudo /usr/sbin/useradd -m app
$ sudo -u app mkdir -m 700 /home/app/.ssh
$ sudo -u app touch /home/app/.ssh/authorized_keys
$ sudo sh -c "cat id_rsa.pub >> /home/app/.ssh/authorized_keys"

リモートログイン時のパスフェイズ入力を省略する為の設定を行う。
$ ssh-agent bash
$ ssh-add
Enter passphrase for /Users/Radengineer/.ssh/id_rsa:
Identity added: /Users/Radengineer/.ssh/id_rsa (/Users/Radengineer/.ssh/id_rsa)

公開鍵で本番サーバにログインする。
$ ssh 192.168.251.131
$ ssh app@192.168.251.131
パスワードなしでログインできれば設定完了。


以上です。

2011年4月20日水曜日

[Ruby][Heroku] GUIでアプリをリネームしたらローカルでApp not foundになった場合の対応

herokuでは用意されているGUIからアプリネームを変更できますが、GUI側だけでなくローカル側もあわせて変更する必要があります。

General Info > Nameでアプリネーム変更後、ローカル側ではアプリを認識できなくなり、デプロイしようとすると「App not found」が表示されます。

以下のコマンドで確認できます。
$ heroku config
App not found

対応として、gitのconfigファイルで定義されているアプリネームを変更します。
$ vi .git/config
 ・
 ・
 ・
[remote "heroku"]
url = git@heroku.com:[GUI側でRenameしたアプリケーション名].git
fetch = +refs/heads/*:refs/remotes/heroku/*


以上です。

2011年4月18日月曜日

[Javascript-Smartphone][jQuery] 選択オブジェクトのクラス操作

toggleClass()を使用し選択されているオブジェクトに対してクラスの追加または削除を行うことができます。

#header ulにhideクラスを、.leftButtonにpressedクラスを追加/削除する。
function toggleMenu() {
$('#header ul').toggleClass('hide');
$('#header .leftButton').toggleClass('pressed');
}

以上です。

2011年4月10日日曜日

[Reading] 3月読書リスト

イシューからはじめよ―知的生産の「シンプルな本質」安宅和人 (著)
がむしゃらに仕事をしてクォリティを高める道=犬の道であるという定義。そして犬の道を避けよ!という明確なメッセージがストレートに伝わってきた。振り返ってみると入社してからの仕事の中で自分の思い通りに進められず、徒労感を感じた仕事ほど犬の道を地でいくやり方をしていたのだと実感した。
まずはイシューを見つけるために考え抜くことが大切ということが分かっただけでも、本作を手に取って良かったと思う。残念ながらイシューを見つけること、イシュー度の高いアウトプットを実現することは簡単ではない。これからも都度本作を読み返し、実践を積み重ねて体得していきたいと思う。

ハーモニー 伊藤 計劃(著)
体内に取り込まれた人工機関とネットワーク上のサーバによる人体の管理。信じがたいがいまもどこかの人間が考えていそうで恐ろしく、またおぞましいコンセプトだと感じた。その管理された個が当たり前の世界で、なぜその当たり前が実現したのかを主人公の目線から追いかけていくうちに自分の中でも人間の存在、自己の存在に対する漠然とした考えが膨らむのが分かる。やはり、伊藤計劃の作品はとても刺激的だ。
苦しく思うのは、著者がこのコンセプトをどのような状況の中で生み出したのかを容易に想像できること。人智を超えた作品を生み出すには、痛々しく生々しい苦しみが必要なのか。次回作が生まれないことが本当に残念。

2011年4月4日月曜日

[Ruby][Heroku] データベースを使用する

■概要
Herokuのデータベースについてまとめてみました。

Herokuでは5MBの容量を無料で使用できます。
さらに容量が必要となる場合は、有料で拡張していくことになります。

Heroku標準データベースはPostgreSQLです。
ただし、アドオンやAmazonRDSの連携を使用することで、Key Value StoreやMySQLを採用することも可能です。
AmazonRDSを使用する

共有データベース(PostgreSQL 8.3


共有データベースでは月額15ドルで20GBまでの容量を使用できます。


専用データベース(PostgreSQL 9












専用データベースはリソースによって上記6種類のプランが用意されています。
容量はいずれのプランも2TBが上限となっています。(2011/04時点)
※1ECompUnitは、1.0-1.2GHz 2007 Opteronまたは2007 XeonプロセッサのCPU能力と同等の能力とのこと


Railsを使用している場合のテーブル作成例とデプロイ方法は以下の通りです。

・マイグレーションを作成し適用する
$ ruby script/generate scaffold table_name
$ rake db:migrate

・Herokuへデプロイする
$ heroku rake db:migrate


以上です。

2011年3月29日火曜日

[Ruby][Heroku] プロジェクトを作成する

Heroku(ハーオーク)でプロジェクトを立ち上げてみた。

アイデアをサクッと形にできる。

このフットワークの軽さはステキですね。

1. 何はともあれ、サインアップ。https://heroku.com/からユーザ登録します。
無料です。









2. ここからローカルPCのセットアップ
もちろんRailsが入っていることは大前提でございます。

$ cd PATH/TO/MY_APP
$ git init
Initialized empty Git repository in .git/
touch README
$ git add .
$ git commit -m "my_app"
$touch README
[master (root-commit) 694cbe2] my_app
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README

3. git用にSSH公開鍵を設定する(未設定の場合)
MacOS
Windows
Linux

$ heroku keys:add
Uploading ssh public key ~/.ssh/id_rsa.pub
Enter your Heroku credentials.
Email: ****@yourmail.com
Password:

Found existing public key: ~/.ssh/id_rsa.pub
Would you like to associate it with your Heroku account? [Yn] Y
Uploading ssh public key ~/.ssh/id_rsa.pub


4. Herokuにアプリをコミットする準備
$ sudo gem install heroku
$ heroku create
$ Git remote heroku added


5. Herokuのアプリをコミットする(gitのpushコマンド)
$ git push heroku master
Counting objects: 3, done.
Writing objects: 100% (3/3), 214 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
! Heroku push rejected, no Rails or Rack app detected.

error: hooks/pre-receive exited with error code 1
To git@heroku.com:glowing-rain-535.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:glowing-xxx-xxx.git'

ん?何かエラーが出てる。
ssh鍵認証でエラーということで、調べてみたら以下のURLで同じ事象が紹介されていました。
[Linux]ssh 接続しようとすると「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!」が表示されるときは

以下のコマンドを入力してアプリ名が表示されればOKです。
$ heroku list
glowing-xxx-xxx


参考URL
heroku quickstart refference
Ruby版PaaSの"Heroku"で無料Railsホスティング環境を手に入れよう


以上です。

2011年3月26日土曜日

[Javascript-Smartphone] Githubにリポジトリを作成する

これからJavascript+HTML+CSSでスマートフォンアプリを作成していきます。

あくまで勉強ですが、作成したすべてのコードはGithubで管理することにします。
準備作業として、Githubにリポジトリを用意します。

# ローカルにディレクトリを作成
mkdir javascript-smartphone-app
cd javascript-smartphone-app
# 初期化
git init
# READMEを追加
touch README
git add README
# コミット
git commit -m 'first commit'
git remote add origin git@github.com:Radengineer/javascript-smartphone-app.git
git push -u origin master


以上です。

2011年2月22日火曜日

[Emacs拡張] migemo-install

Migemoはローマ字のまま日本語をインクリメンタルサーチできる強力なツールです。

インストールに必要なもの
Emacs 私の環境はEmacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0) です。

APEL 不要かもしれません。

Ruby Migemo は Ruby で書かれています。 (1.6 以降対応)

Ruby/Bsearch バイナリサーチをするための Ruby のライブラリです。
パッケージを展開し、ライブラリファイルをrubyのディレクトリに配置します。
cp -p bsearch.rb /usr/lib/ruby/site_ruby/

Ruby/RomKan ローマ字<->かなを相互変換する Ruby のライブラリです。
パッケージを展開し、ライブラリファイルをrubyのディレクトリに配置します。
cp -p romkan.rb /usr/lib/ruby/site_ruby/

Migemo Migemo 本体です。現在のバージョンは 0.40 です。 migemo コマンドおよび Emacs から操作するための elisp が含まれます。
./configure
make
make install

インストール後に.emacsに以下の設定を追記します。
(require 'migemo)


以上です。


参考URL:
http://0xcc.net/migemo/
http://www4.kcn.ne.jp/~boochang/emacs/migemo.html

2011年2月9日水曜日

[cmd] wgetコマンドでhttpsリクエスト

wgetでhttpsリクエストを送るコマンドは以下の通り(良く使うオプションです)
wget -O file_name --header="header_name:header_value" "https://mail.google.com"

-O file_name 取得結果をファイルに保存します。
--header="header_name:header_value" httpヘッダを指定できます。複数使用可。
※wgetがSSL対応でコンパイルされている必要があります。

■HTTP関連のオプション
http://www.geocities.jp/fut_nis/html/wget-ja/HTTP-Options.html#HTTP-Options
■SSL関連のオプション
http://www.geocities.jp/fut_nis/html/wget-ja/HTTPS-_0028SSL_002fTLS_0029-Options.html


以上です。

2011年1月24日月曜日

[Emacs拡張] auto-install

Emacsを使用してますが、どのように拡張してきたか忘れがちなので記録を残していきたいと思います。

まずauto-install.elを利用できるようにします。
EmacsはLispプログラムをインストールして拡張するので、なるべく楽にインストールできるようにします。

1. EmacsWikiからauto-install.elをダウンロード
mkdir -p ~/.emacs.d/auto-install
cd ~/.emacs.d/auto-install
wget http://www.emacswiki.org/emacs/download/auto-install.el
(MacOSXでは標準ではwgetが使用できないのでcurlを利用します。curl -O http://www.emacswiki.org/emacs/download/auto-install.el)
emacs --batch -Q -f batch-byte-compile auto-install.el
auto-install.elcというコンパイル済みファイルが作成される

2.MacOSXでは以下のパスにコンパイル済みファイルを配置する
/Applications/Emacs.app/Contents/Resources/site-lisp

3. .emacsに以下の設定を追加する
;; auto-install
(require 'auto-install)
;;
(add-to-list 'load-path auto-install-directory)
;; 起動時にEmacsWikiのページ名を補完候補に加える
(auto-install-update-emacswiki-package-name t)
(auto-install-compatibility-setup)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

4. M-x install-elisp-from-emacswikiが実行できればインストール成功です。


以上です。

2011年1月15日土曜日

[Linux][CentOS] yumの再インストール

yumの調子が悪くなったので、再インストールしました。
※具体的にはyum updateができなくなり、yum clean allも効果なしという状況でした。

まずは、環境情報を確認。

ホストネームを確認する
# uname -a
Linux localhost.localdomain 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44 EDT 2010 i686 i686 i386 GNU/Linux

OSバージョンを確認する
# cat /etc/redhat-release
CentOS release 5.5 (Final)

rpmバージョンを確認する
# rpm -q rpm
rpm-4.4.2.3-18.el5

yum関連パッケージをアンインストール
# rpm -e --nodeps python-elementtree
# rpm -e --nodeps python-urlgrabber
# rpm -e --nodeps python-sqlite
# rpm -e --nodeps m2crypto
# rpm -e --nodeps rpm-python
# rpm -e --nodeps python-iniparse
# rpm -e --nodeps yum-metadata-parser
# rpm -e --nodeps yum yum-fastestmirror

再インストール用パッケージをダウンロード
# cd /usr/local/src
# mkdir yumrpm
# cd yumrpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/m2crypto-0.16-6.el5.6.i386.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/rpm-python-4.4.2.3-18.el5.i386.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
# wget http://ftp.riken.jp/Linux/centos/5.5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

yum関連パッケージを再インストール
# rpm -ivh python-elementtree-1.2.6-5.i386.rpm python-urlgrabber-3.1.0-5.el5.noarch.rpm python-sqlite-1.1.7-1.2.1.i386.rpm m2crypto-0.16-6.el5.6.i386.rpm rpm-python-4.4.2.3-18.el5.i386.rpm python-iniparse-0.2.3-4.el5.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm yum-3.2.22-26.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
準備中...        ########################################### [100%]
1:yum-metadata-parser  ########################################### [ 11%]
2:rpm-python       ########################################### [ 22%]
3:m2crypto        ########################################### [ 33%]
4:python-sqlite     ########################################### [ 44%]
5:python-elementtree   ########################################### [ 56%]
6:python-urlgrabber   ########################################### [ 67%]
7:python-iniparse    ########################################### [ 78%]
8:yum-fastestmirror   ########################################### [ 89%]
9:yum          ########################################### [100%]

次のコマンドでエラーが出なければ完了
# yum list


以上です。