2016年7月19日火曜日

Recommendifyを入れてみたらちょっとはまった

今更なのですがRecommendifyを試してみて、普通にgem入れようとしたら入らなかったので調べました。
試した環境はMac OSX El Capitanです。

まずは以下の2つをインストール。
brew insert redis
brew insert hiredis

次にGemfileにhiredisとrecommendifyを追加。
gem install hiredis
gem install recommendify

そしてbundle installを実行。
すると、recommendifyが入らなくてエラーになりました。
Installing recommendify 0.3.8 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/xxx/.rbenv/versions/2.1.3/bin/ruby extconf.rb

make "DESTDIR=" clean
rm -f *.o

make "DESTDIR="
mkdir -p ../bin
gcc -Wall recommendify.c -lhiredis -o ../bin/recommendify
recommendify.c:4:10: fatal error: 'hiredis/hiredis.h' file not found
#include 
         ^
1 error generated.
make: *** [build] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/xxx/yyy/vendor/bundle/ruby/2.1.0/gems/recommendify-0.3.8 for inspection.
Results logged to /Users/xxx/yyy/vendor/bundle/ruby/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/recommendify-0.3.8/gem_make.out
An error occurred while installing recommendify (0.3.8), and Bundler cannot continue.
Make sure that `gem install recommendify -v '0.3.8'` succeeds before bundling.

調べてみたところ、recommendifyをgitからnativeブランチで取得するとよさそうです。
gem install recommendify, git: "https://github.com/danmorin/recommendify.git", branch: "native"
これで無事に入りました。

参考URL
http://blog.naberon.jp/post/2013/09/09/site-recommend/
http://d.hatena.ne.jp/itmsc/20130812/1376289715
http://qiita.com/toyama0919/items/bef2e375e9ebde9a01ba
https://github.com/paulasmuth/recommendify/issues/6

2016年7月6日水曜日

nologinのユーザーをログインできるようにする

ログインできないユーザーをログインできるようにする必要があったので調べました。
usermodでログインシェルを変更できるようです。
cat /etc/passwd | grep test
test:x:501:501::/home/test:/sbin/nologin

usermod -s /bin/bash test

cat /etc/passwd | grep test
test:x:501:501::/home/test:/bin/bash

参考URL
http://server-setting.info/centos/login_user.html

2016年7月1日金曜日

Google Maps APIでMissingKeyMapError出たので調べた

ちょっとgoogle maps apiで出力してる地図を置き換えていたら、
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
でこれまで動かしていた地図は表示されていたのですが、
<script src=”https://maps.googleapis.com/maps/api/js”></script>
を使ったら地図が表示されず、MissingKeyMapErrorがコンソールに出ていました。

google maps apiで調べてみると、呼び出してるJSにはAPIキーがパラメーターで渡せるようですが、
使い方を説明しているページの多くが、APIキーはなくても大丈夫と書いてあったので、
面倒だし取得しないでやろうとしていたら地図が表示されてません。

そして更に調べたところ、2016/06/22からAPIキーは必須になったそうです。
渋々APIキーを取得してパラメーターに入れたところ、ちゃんと地図が表示されました。
現状ではこれが正しい形なようです。(sensor=true|falseはつけなくてよいようです。)
<script src=”https://maps.googleapis.com/maps/api/js?key={APIキー}”></script>

参考URL
http://blog.cloud9works.net/web/how-to-fix-google-map-api-key-error/
https://developers.google.com/maps/documentation/javascript/error-messages#deverrorcodes