2016年10月23日日曜日

D3.js : Bubbleチャートの利用

Bubbleチャート表示をやってみたくてやってみました。
http://bl.ocks.org/mbostock/4063269
を見てやってみようと思ったのですが、データ階層が面倒だったので簡単な方法で
http://www.openspc2.org/reibun/D3.js/code/graph/bubble-chart/0003/index.html
がシンプルだったのでこれを使わせてもらいました。

 1. jsファイルの作成
app]$ vi webroot/js/bubble.js
上記で使っているファイルに色をランダムにする部分を追加してあります。


2.viewへの取り込み
app]$ vi View/Keywords/graph.ctp


ここで使っている$countはコントローラで生成してあります。
if(count($weight) < 100 ) {
    $count = count($weight);
}else{
    $count = 100;
}
$this->set('count',$count);
100件未満だと表示されないようなので、その場合は配列数にしてあります。
これで表示するとこんな感じです。
16進数への変換は
http://d.hatena.ne.jp/DECKS/20100907/1283843862
を利用しています。

2016年10月20日木曜日

サーバ証明書の作成・設定

サーバ証明書の作成と設定をします。

1.設定したいサーバでCSR(証明書発行要求:Certificate Signing Request)を作成します。OpenSSLを用いて作成をします。
[OpenSSLのインストール]
# yum install openssl

[鍵ペアの生成]
# cd /etc/httpd/conf
# mkdir ssl.key   作業ディレクトリの作成
# vi random1.txt    鍵生成用ランダムファイル
# vi random2.txt
# vi random3.txt
# openssl genrsa -des3 -rand random1.txt:random2.txt:random3.txt 2048 >test.sample.ac.jp.key
[CSRの生成]
ssl.key]# openssl req -new -key test.sample.ac.jp.key -sha256 -out test.sample.ac.jp.csr
Enter pass phrase for test.sample.ac.jp.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:.
Locality Name (eg, city) [Default City]:Fukuroi
注意(2019/4/1変更) Academe固定は廃止されました。
2018年7月9日以降、L=Academeを指定するとエラーとなります
Organization Name (eg, company) [Default Company Ltd]:Shizuoka Institute of Science and Technology
Organizational Unit Name (eg, section) []:sist.ac.jp
Common Name (eg, your name or your server's hostname) []:test.sample.ac.jp
Email Address []:.

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:.
An optional company name []:.
 内容確認
# openssl req -noout -text -in cloud02.sist.ac.jp.csr
Certificate Request:
    Data:
        Version: 0 (0x0)
        Subject: C=JP, L=Academe, O=Shizuoka Institute of Science and Technology, OU=sist.ac.jp, CN=test.sample.ac.jp
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:bd:fe:3a:13:dc:fb:b3:8d:bd:67:00:12:bf:b4:

このcsrファイルをダウンロードします。

2.申請用TSVファイルの作成
https://certs.nii.ac.jp/tsv-tool/
にアクセスしてtsvファイルを作成します。


補足(2019/4/1)
しているFQDNのホスト名以外でも利用する場合、(例:office365.sist.ac.jpで登録しておいて、fsecure.sist.ac.jpでも使う場合、dNSNameの部分に例のように書き込む:記入例:dNSName=xxx.example.ac.jp,dNSName=yyy.example.ac.jp)


ここでtsvファイルを作成し、NIIのサイトへアップロードし、証明書を発行します。
NIIからメールで送られてくる。

リンクからダウンロードしファイル名.crtで保存する。

3.証明書のインストール
[mod_sslインストール]
# yum install mod_ssl

# vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/httpd/conf/ssl.crt/cloud02.sist.ac.jp.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/cloud02.sist.ac.jp.key
SSLCertificateChainFile  /etc/httpd/conf/ssl.crt/nii-odca3sha2.cer

 
[中間証明書のインストール]
https://repo1.secomtrust.net/sppca/nii/odca3/index.html
より中間証明書を取得します。
/etc/httpd/conf/ssl.crt/nii-odca3sha2.cer  に設置します。
# mkdir  /etc/httpd/conf/ssl.crt
# cp nii-odca3sha2.cer /etc/httpd/conf/ssl.crt/

[サーバ証明書の設置]
# cp cloud02.sist.ac.jp.crt /etc/httpd/conf/ssl.crt/

サーバを再起動
# service httpd restart

[確認]
設定したサーバにhttpsでアクセスします。
https://サーバ名/
サーバ証明書の確認ができました。

参考
https://certs.nii.ac.jp/?action=pages_view_main&active_action=repository_view_main_item_detail&item_id=1&item_no=1&page_id=85&block_id=439

2016年10月6日木曜日

WordCloudの利用

形態素解析した結果を表示するのにWordCloudを使ってみました。

1.ライブラリの設置
今回使ったファイルは
d3.layout.cloud.js
word-cloud.js
d3.v3.min.js
です。app/webroot/jsに配置します。またはURL指定です。
ダウンロードは
https://github.com/shprink/d3js-wordcloud
https://github.com/jasondavies/d3-cloud/tree/master/build
からしました。

2.形態素解析した結果を取り込みます。
今回は View/graph.ctpに書きました。


オリンピックのtweet結果を形態素分析して、WordCloudで表示するとそれなりでした。