筆記一下
brew update
brew search elasticsearch ==> 查看目前有的版本
eg.
elasticsearch
homebrew/versions/elasticsrach22
homebrew/versions/elasticsrach17
brew install homebrew/versions/elasticsrach22 ==> 指定安裝版本
參考資料
http://effectif.com/mac-os-x/installing-specific-version-of-homebrew-formula
歐博摩特斯布拉格
2016年4月1日 星期五
2016年3月18日 星期五
Build & Package with SBT
做個筆記
開發是使用 IntelliJ IDEA
要直接使用 SBT build
1. Download & install SBT
http://www.scala-sbt.org/download.html
2. 確認 build.sbt 中
mainClass in assembly := Some("Your.main.class")
不改也可以在執行 .jar 時指定
3. 執行 sbt assembly
4. 可在 [your project]\target\scala-2.11\ 下找到 [your project].jar
2016年3月3日 星期四
JavaMail API - Send Mail
1. 下載 JavaMail Library
http://www.oracle.com/technetwork/java/javamail/index-138643.html
我用的是 1.4.5
後來發現比較新的是 1.5.0
2. 使用JavaMail API
網路上很多範例, 尤其是使用Gmail SMTP server 的
建議有時間的話先看一下 the most common mistakes people make
另外, API 中有分 SSL 與 STARTTLS.
許多 Gmail SMTP 範例會分 SSL 與 TLS, 但範例中的 TLS 通常是指 STARTTLS , 容易誤導
關於 SSL, TLS, STARTTLS 的區分說明可看這篇
Note: 若要透過 Gmail 發信, 則該 Gmail 帳號需降低安全性, 修改方式可看這裡
3. Sample: SSL/TLS for my mail server
val host = "host.mymailserver.com"
val port = 465
val username = "myaccount"
val password = "mypasswd"
設定 connection property
val properties = System.getProperties
properties.put("mail.smtp.auth", "true")
properties.put("mail.smtp.ssl.enable", "true")
因為是未認證的 mail server, 另外加這段
properties.put("mail.smtp.ssl.checkserveridentity", "false")
properties.put("mail.smtp.ssl.trust", "*")
準備信件內容
val session = Session.getInstance(properties)
val message = new MimeMessage(session)
message.setFrom(new InternetAddress(" noreply@mymailserver.com"))
message.setRecipients(Message.RecipientType.TO, "receipient@gmail.com")
message.setSubject("Greetings")
message.setText( "THIS IS TEST MAIL")
connect & send mail
val transport = session.getTransport("smtp")
transport.connect(host, port, username, password)
transport.sendMessage(message, message.getAllRecipients)
transport.close()
參考資料
https://www.fastmail.com/help/technical/ssltlsstarttls.html
http://www.oracle.com/technetwork/java/javamail/faq/index.html
http://puremonkey2010.blogspot.tw/2010/12/java-javamail-gmail.html
http://www.oracle.com/technetwork/java/javamail/index-138643.html
我用的是 1.4.5
後來發現比較新的是 1.5.0
2. 使用JavaMail API
網路上很多範例, 尤其是使用Gmail SMTP server 的
建議有時間的話先看一下 the most common mistakes people make
另外, API 中有分 SSL 與 STARTTLS.
許多 Gmail SMTP 範例會分 SSL 與 TLS, 但範例中的 TLS 通常是指 STARTTLS , 容易誤導
關於 SSL, TLS, STARTTLS 的區分說明可看這篇
Note: 若要透過 Gmail 發信, 則該 Gmail 帳號需降低安全性, 修改方式可看這裡
3. Sample: SSL/TLS for my mail server
val host = "host.mymailserver.com"
val port = 465
val username = "myaccount"
val password = "mypasswd"
設定 connection property
val properties = System.getProperties
properties.put("mail.smtp.auth", "true")
properties.put("mail.smtp.ssl.enable", "true")
因為是未認證的 mail server, 另外加這段
properties.put("mail.smtp.ssl.checkserveridentity", "false")
properties.put("mail.smtp.ssl.trust", "*")
準備信件內容
val session = Session.getInstance(properties)
val message = new MimeMessage(session)
message.setFrom(new InternetAddress(" noreply@mymailserver.com"))
message.setRecipients(Message.RecipientType.TO, "receipient@gmail.com")
message.setSubject("Greetings")
message.setText( "THIS IS TEST MAIL")
connect & send mail
val transport = session.getTransport("smtp")
transport.connect(host, port, username, password)
transport.sendMessage(message, message.getAllRecipients)
transport.close()
參考資料
https://www.fastmail.com/help/technical/ssltlsstarttls.html
http://www.oracle.com/technetwork/java/javamail/faq/index.html
http://puremonkey2010.blogspot.tw/2010/12/java-javamail-gmail.html
2016年2月23日 星期二
Cassandra Config (3.3.0)
裝完 Cassandra 後試著做兩件事
1. 將 listen interface 由 localhost 改為其他 IP, 支援外部連線
2. 建帳號
兩者皆由修改 ~/cassandra/conf/cassandra.yaml 著手
1. Change IP
目前只是先試出來有兩個地方要改
#listen_address: localhost
待有空再來研究
[另外試了 Cassandra 3.2.1 則是兩者都要設 ip address, 也是奇怪]
2. Create User
預設執行 cql 是不需要 username/password
但當要執行 create user 時, 會出現類似以下 error:
InvalidRequest: code=2200 [Invalid query] message="org.apache.cassandra.auth.CassandraRoleManager doesn't support PASSWORD"
同樣需要修改 config
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator
#authorizer: AllowAllAuthorizer
authorizer: CassandraAuthorizer
這兩項改完可以預設帳號登入(cassandra/cassandra) 並 create user
ex.
~/cassandra/bin/cqlsh 192.168.2.129 -u cassandra -p cassandra
Connected to Test Cluster at 192.168.2.129:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh> create user test with password 'test' ;
參考資料:
http://stackoverflow.com/questions/31820914/in-cassandra-2-2-unable-to-create-role-containing-password
1. 將 listen interface 由 localhost 改為其他 IP, 支援外部連線
2. 建帳號
兩者皆由修改 ~/cassandra/conf/cassandra.yaml 著手
1. Change IP
目前只是先試出來有兩個地方要改
#listen_address: localhost
listen_interface: [your interface] ex. eth1
#rpc_address: localhost
rpc_address: [your ip] ex. 192.168.2.129
比較奇怪的是,
看說明, 應該設 listen_address 就可以, 但直到改了 rpc_address 才真的 listen 在指定的 IP上
另外我目前 listen_address 要改用 listen_interface 才行. 否則執行 cassandra 會有error.待有空再來研究
[另外試了 Cassandra 3.2.1 則是兩者都要設 ip address, 也是奇怪]
2. Create User
預設執行 cql 是不需要 username/password
但當要執行 create user 時, 會出現類似以下 error:
InvalidRequest: code=2200 [Invalid query] message="org.apache.cassandra.auth.CassandraRoleManager doesn't support PASSWORD"
同樣需要修改 config
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator
#authorizer: AllowAllAuthorizer
authorizer: CassandraAuthorizer
ex.
~/cassandra/bin/cqlsh 192.168.2.129 -u cassandra -p cassandra
Connected to Test Cluster at 192.168.2.129:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh> create user test with password 'test' ;
參考資料:
http://stackoverflow.com/questions/31820914/in-cassandra-2-2-unable-to-create-role-containing-password
2016年2月5日 星期五
Install cassandra on ubuntu 14.04
1. 先安裝 Java JDK
目前的是 Java 8, Java 9 官方還不建議使用
$sudo add-apt-repository -y ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java8-installer
2. 安裝 Cassandra
目前從官網看到的最新版是 3.2.1
下載
$ wget http://apache.stu.edu.tw/cassandra/3.2.1/apache-cassandra-3.2.1-bin.tar.gz
目前的是 Java 8, Java 9 官方還不建議使用
$sudo add-apt-repository -y ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java8-installer
2. 安裝 Cassandra
目前從官網看到的最新版是 3.2.1
下載
$ wget http://apache.stu.edu.tw/cassandra/3.2.1/apache-cassandra-3.2.1-bin.tar.gz
$ tar -xvzf apache-cassandra-1.2.4-bin.tar.gz
$ mv apache-cassandra-1.2.4 ~/cassandra
安裝&設定
$sudo mkdir /var/lib/cassandra
$sudo mkdir /var/log/cassandra
$sudo chown -R $USER:$GROUP /var/lib/cassandra
$sudo chown -R $USER:$GROUP /var/log/cassandra
$export CASSANDRA_HOME=~/cassandra
$export PATH=$PATH:$CASSANDRA_HOME/bin
啟動 cassandra
$ ./cassandra/bin/cassandra
原本是用 sudo 去執行, console 上會顯示訊息建議不要用 root 權限啟動 cassandra, 所以就拿掉囉
執行 cql
$ ./cassandra/bin/cqlsh
顯示:
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh>
參考資料
http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/#
http://idroot.net/tutorials/how-to-install-apache-cassandra-on-ubuntu-14-04/
http://wiki.apache.org/cassandra/GettingStarted
http://wiki.apache.org/cassandra/GettingStarted
2015年2月22日 星期日
硫磺之火-超自然迷殺首部曲
是兩個作者合著的偵探小說: 道格拉斯.普萊斯頓 & 林肯.柴爾德
比較好奇的是, 寫小說跟寫報告畢竟有些不同, 即使情節可先溝通, 但每個人慣用的語詞還是會有所不同. 話說回來, 剛出道的上官鼎也是三位一體的兄弟檔, 而非僅現今寫王道劍的那位
原本在圖書館看到的是第三部 "死者之書", 因為是第三部, 圖書館又沒進前兩部 (真怪) 就一直沒借. 今年圖書館網站更新, 發現上網可用館際借書, 在附近圖書館就可取書, 實在是太方便了
會稱之超自然迷殺, 是指死者的死因乍看都是非正常自殺或他殺的狀況
首部曲 "硫磺之火" 死者死因導於人體自燃, 現場狀況更攘人不禁聯想兇手是地獄來的惡魔
也帶出了故事中的支線劇情
主角是一位 FBI探員 & 一位刑警. 可看作是福爾摩斯與華生這樣的拍檔, 一個神通廣大, 相較之下另一個按直覺行事. 後面兩部曲還沒借. 應該還會是這兩位才對. 雖然 FBI 最後被埋起來了 XD.
劇情則跟著一個個死掉的嫌犯發展, 逐漸帶出動機, 兇手及殺人手法
個人是覺得推理的部分不算太多, 動作場面到是不少.
小說應該頗暢銷, 但 Google 了一下, 似乎沒拍成電影.
也難說啦, 小說暢銷, 電影不見得賣座, 像千禧三部曲小說賣得那麼好, 電影也只拍了一步就沒續集了.... 偏驚悚的情節還是不夠大眾吧
比較好奇的是, 寫小說跟寫報告畢竟有些不同, 即使情節可先溝通, 但每個人慣用的語詞還是會有所不同. 話說回來, 剛出道的上官鼎也是三位一體的兄弟檔, 而非僅現今寫王道劍的那位
原本在圖書館看到的是第三部 "死者之書", 因為是第三部, 圖書館又沒進前兩部 (真怪) 就一直沒借. 今年圖書館網站更新, 發現上網可用館際借書, 在附近圖書館就可取書, 實在是太方便了
會稱之超自然迷殺, 是指死者的死因乍看都是非正常自殺或他殺的狀況
首部曲 "硫磺之火" 死者死因導於人體自燃, 現場狀況更攘人不禁聯想兇手是地獄來的惡魔
也帶出了故事中的支線劇情
主角是一位 FBI探員 & 一位刑警. 可看作是福爾摩斯與華生這樣的拍檔, 一個神通廣大, 相較之下另一個按直覺行事. 後面兩部曲還沒借. 應該還會是這兩位才對. 雖然 FBI 最後被埋起來了 XD.
劇情則跟著一個個死掉的嫌犯發展, 逐漸帶出動機, 兇手及殺人手法
個人是覺得推理的部分不算太多, 動作場面到是不少.
小說應該頗暢銷, 但 Google 了一下, 似乎沒拍成電影.
也難說啦, 小說暢銷, 電影不見得賣座, 像千禧三部曲小說賣得那麼好, 電影也只拍了一步就沒續集了.... 偏驚悚的情節還是不夠大眾吧
2015年2月16日 星期一
Install express 4.0 with npm
為了在 nodejs 中使用 express
使用 npm 安裝 express
> sudo npm install -g express
安裝後 nodejs 可正常使用 express
但是當想用 express --version 時, 卻會出現
"The program 'express' is currently not installed"
查了一下才發現
express 4.0 後, 要安裝 express-generator
> sudo npm install -g express-generator
才會有 express 執行檔, 用於建立 application
另外則記得進到 node_modules/express
執行
> sudo npm install 安裝相關套件
參考資料:
install express with npm
使用 npm 安裝 express
> sudo npm install -g express
安裝後 nodejs 可正常使用 express
但是當想用 express --version 時, 卻會出現
"The program 'express' is currently not installed"
查了一下才發現
express 4.0 後, 要安裝 express-generator
> sudo npm install -g express-generator
才會有 express 執行檔, 用於建立 application
另外則記得進到 node_modules/express
執行
> sudo npm install 安裝相關套件
參考資料:
install express with npm
訂閱:
文章 (Atom)