はてなのマイホットエントリーのRSS 配信が終了していたので
Amazon Linux 2017.09 の mysql57-libs(mysql57-devel) を使おうとしたらハマるかもしれない話
Amazon Linux 2017.09 の mysql57-libs(だいたいは mysql57-devel の依存関係で入る) に付随する
/etc/ld.so.conf.d/mysql57-x86_64.conf
の内容が mysql56-libs と同じようだ。
mysql57-libs
$ cat /etc/system-release Amazon Linux AMI release 2017.09 $ sudo yum install mysql57-libs -y $ cat /etc/ld.so.conf.d/mysql57-x86_64.conf /usr/lib64/mysql56 $ ls -l /usr/lib64/mysql57/ 合計 3768 lrwxrwxrwx 1 root root 26 10月 25 14:14 libmysqlclient.so.1020 -> libmysqlclient.so.1020.3.5 -rwxr-xr-x 1 root root 3855408 8月 23 04:20 libmysqlclient.so.1020.3.5
mysql56-libs
$ cat /etc/system-release Amazon Linux AMI release 2017.09 $ sudo yum install mysql56-libs -y $ cat /etc/ld.so.conf.d/mysql56-x86_64.conf /usr/lib64/mysql56 $ ls -l /usr/lib64/mysql56/ 合計 3448 lrwxrwxrwx 1 root root 26 10月 25 14:42 libmysqlclient.so.1018 -> libmysqlclient.so.1018.1.0 -rwxr-xr-x 1 root root 3527456 8月 31 08:00 libmysqlclient.so.1018.1.0 lrwxrwxrwx 1 root root 22 10月 25 14:42 libmysqlclient_r.so.1018 -> libmysqlclient.so.1018 lrwxrwxrwx 1 root root 26 10月 25 14:42 libmysqlclient_r.so.1018.1.0 -> libmysqlclient.so.1018.1.0
gem や pip, composer などでMySQL クライアント用のライブラリをビルドするときに、
libmysqlclient.so が見つからない、というようなエラーになるだろう。
Amazon CloudSearch のドメインから全ドキュメントを削除する
CloudSearch の検証中にドメイン内の全ドキュメントを削除したくなったのだが、
Troubleshooting Amazon CloudSearch - Amazon CloudSearch
Deleting All Documents in an Amazon CloudSearch Domain
Amazon CloudSearch currently does not provide a mechanism for deleting all of the documents in a domain.
とのことで、いまのところ公式ではその手段が提供されていない。 新しいドメインを作りなおすといちいち待ち時間が発生するのでうまくない。
Amazon CloudSearch 用 deleteByQuery を書きました。 - よしだのブログ を参考にしてもよかったが、Python には不慣れなのと、ちょっと大仰な気がしてうまくやれる方法がないか考えてみた。
$ rm -f delete.json && rm -f tmp.json && aws cloudsearchdomain search --endpoint-url https://<Search Endpoint> --query-parser lucene --search-query "*:*" --size 5000 | jq '.hits.hit[].id' | while read i;do echo -n {\"type\": \"delete\", \"id\": ${i}}, >> tmp.json ;done; sed 's/\(.*\),/[\1]/' tmp.json > delete.json
上記で、削除用のバッチファイルを作成し(Preparing Your Data for Amazon CloudSearch - Amazon CloudSearch)、
$ aws cloudsearchdomain --endpoint-url https://<Document Endpoint> upload-documents --content-type application/json --documents delete.json
AWS CLI でデータの更新ができる(http://docs.aws.amazon.com/cloudsearch/latest/developerguide/uploading-data.html#uploading-data-clt)。
Amazon Linux を使っていれば追加でインストールするのは jq のみなので、こっちのほうが準備は簡単かな?
2015年9月25日追記
aws cloudsearchdomain search の size オプションは10,000 が上限のようだ。
それ以上のドキュメントが入ってる場合にはちょっと考えないといけない。
ChatWork adapter for Ruboty を作った
Idobata のアダプタ を参考にしています。
ChatWork のAPI はルーム内の発言を取るのに毎回HTTP リクエストが発生するのでなんか微妙……。
Ruby とかよく分からないので、プルリクをお待ちしております。
Ubuntu 14.04 LTS に Fluentd をインストールする
2014年7月4日時点で公式の deb パッケージが用意されていないので自前で。
rbenv とかは使っていない。なるべく楽に。
先に下記のとおり設定を確認、変更。
Before Installing Fluentd | Fluentd
下記のパッケージをインストール。
$ sudo apt-get install ruby2.0 ruby2.0-dev build-essential
Ruby2.0系をデフォルトに変更。
$ sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 0 $ sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.0 1 $ sudo update-alternatives --config ruby
Gemも。
$ sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.1 0 $ sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem2.0 1 $ sudo update-alternatives --config gem
irbも(2014/07/29追記)。
$ sudo update-alternatives --install /usr/bin/irb irb /usr/bin/irb 0 $ sudo update-alternatives --install /usr/bin/irb irb /usr/bin/irb2.0 1 $ sudo update-alternatives --config irb
rbenv で入れよう。
Twitter / mhag: 結論 Ubuntu 14.04 ...
Twitter / mhag: @yoshi_ken 以前に ...
Twitter / mhag: @yoshi_ken rbenv から 2.1.2 ...
有名事案だったらしい
Google グループ
oh...
Twitter / tagomoris: 今日も ruby 2.0.0-p353 ...
最後にFluentd のインストール。
Installing Fluentd Using Ruby Gem | Fluentd
$ sudo gem install fluentd --no-ri --no-rdoc
動作確認。
$ fluentd --setup ./fluent $ fluentd -c ./fluent/fluent.conf -vv & $ echo '{"json":"message"}' | fluent-cat debug.test
お疲れ様でした。
CentOS 6.3(64bit) にmod_mruby をインストール
11月1日時点で
# git clone git://github.com/matsumoto-r/mod_mruby.git # cd mod_ruby # make
すると
/usr/bin/ld: ./vendors/mrblib/mrblib.o: relocation R_X86_64_32 against `mrblib_irep' can not be used when making a shared object; recompile with -fPIC ./vendors/mrblib/mrblib.o: could not read symbols: Bad value collect2: ld returned 1 exit status apxs:Error: Command failed with rc=65536 . make: *** [mod_mruby.so] エラー 1
でmake に失敗するので
diff --git a/Makefile b/Makefile index 5855d2b..702ddab 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ tmp/mruby: cd tmp; git clone git://github.com/mruby/mruby.git libmruby.a: tmp/mruby - cd tmp/mruby && make + cd tmp/mruby && make CFLAGS="-O3 -fPIC" cp -r tmp/mruby/include vendors/ cp -r tmp/mruby/lib vendors/ cp -r tmp/mruby/src vendors/
こんな感じで修正した。
JavaScript でオブジェクトのクローンを生成(ディープコピー)
jQuery を使っていると超シンプル。
// Shallow copy
var newObject = jQuery.extend({}, oldObject);// Deep copy
var newObject = jQuery.extend(true, {}, oldObject);
What is the most efficient way to clone a JavaScript object? - Stack Overflow
ちなみに jQuery.extend については jQuery.extend マニアックス - てっく煮ブログ が詳しい。