發表文章

目前顯示的是 3月, 2017的文章

[ jenkins ] Install Jenkins On Ubuntu [incomplete]

圖片
Ref: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu http://alex-dai.logdown.com/posts/2016/04/17/jenkins-bitbucket-ssh-key wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins

安裝ssl & letsencrypt certbot

圖片
https://www.namecheap.com/support/knowledgebase/article.aspx/9419/0/nginx cat certificate.crt ca_bundle.crt >> ca.chain.crt 將certificate.crt & ca_bundle.crt 輸出到 ca.cahin.crt 然後根據nginx的設定 ssl_certificate /home/ubuntu/project_dir/ssl/license/ca.chained.crt; ssl_certificate_key /home/ubuntu/project_dir/ssl/license/private.key;記得將private.key也替換上去! ################################################################## 題外話: 再裝nginx的時候 (on ubuntu16.04), nginx竟然會無法stop/restart 最後只能先跑一次 ps -ef | grep nginx kill <pid> 之後才可以正常stop/restart ..Orz 移除nginx sudo apt-get purge nginx nginx-common Ref:   https://certbot.eff.org/#ubuntuxenial-nginx https://certbot.eff.org/docs/using.html#certbot-commands 首先先安裝letsencrypt sudo apt-get install letencrypt 接下來使用webroot的方式驗證這個domain真的是屬於你的 letsencrypt certonly --webroot -w /var/www/你的domain -d 你的domain 註: webroot是letsencrypt利用在本機產生檔案, 然後透過domain驗證 來確認這個domain真的是你的 ex: letsencrypt certonly --webr

[ mongodb ] aggregation example

MySQL中可以做 JOIN, GROUP BY, .. 但在Mongodb就必須靠 aggregation 像Left outer join在Mongodb要用特別的operator : $lookup 官網有提供一些簡單的MySQL to Mongodb aggregate的語法範例 https://docs.mongodb.com/v3.2/reference/sql-aggregation-comparison/ 小舉例 db.collection('collName').aggregate([     {          $match: matchQuery         // 搜尋條件式, 符合的documents傳給下個階段     },     {         $project: {                         // 將上個階段的documents取出指定欄位傳給下個階段             user: 1, place: 1, createdAt: 1          }       },     {         $group: {                       // 將上個階段的documents給group成指定的物件             _id: "$user",               // _id 是必須要有的             place: {                     // 要輸出的place欄位是陣列 [ { _id: xxx }, { _id: xxx}, .. ]                 $push: {                     _id: "$place"                 }         }     } }, { $sort: { createdAt: -1 } }, { $limit: limit } ], function(err, aggregations) { }); 目前Aggregate在Mongodb原生的套件中沒有提