Exploring and Thinking

iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k]

不錯的 iTerm2 加畫面顯示設定,對於做git非常好用。
留存記錄: https://gist.github.com/kevin-smets/8568070
PS. 另一個Oh My Zsh的theme: https://github.com/caiogondim/bullet-train.zsh
Share:

雀巢 Nespresso 膠囊咖啡機使用心得

使用雀巢膠囊咖啡機三個月了,來寫寫使用的心得。

主要心得有兩個:
  1. 除非心臟夠大顆,否則不要買Prodigio咖啡機。
  2. 全鋁膠囊雖然比Dolce Gusto還好回收,但雀巢給我感覺是不太推環保回收的活動。
我剛買的第一台機器是Prodigio,依說明書沖三杯清水時就發生故障,第三杯注水一半就閃起紅燈,連帶膠囊入口的蓋子也卡死打不開,重新開機才恢復正常。 (之前錄給客服的操作影片,3:00 處: https://youtu.be/Q2pTC0hWVbI?t=3m00s )

後來跟客服反覆的測試還是有一樣的問題,但咖啡機已經拆封使用,只能走維修流程。因為這件事,我才知道七天鑑賞期是不包含開封使用膠囊的。當初一開始沖水有問題打給客服後,就應該馬上寄回,結果我還跟客服說先放膠囊試看看,導致無法退貨。

客服隔天寄了一台備用機PIXIE,全程使用都沒有問題。寄回去的機器經客服測試也發生影片錄製的情況。他們與主管討論後,決議換一台新的Prodigio交換,結果新品試用後還是一樣問題。

經過反覆測試,我跟客服說這一台設計上可能有瑕疵,Prodigio的特色是會自動退膠囊,但一般注入清水時,機器可能會退不出膠囊而卡死,因為實際上膠囊並不存在!最後和客服達成協議,直接加錢換CITYZ。CITYZ的外型很好看,沒有其他機器那種塑膠感,放在公司茶水間還滿適合的。後來我們同仁還合購了一台同色同材質的奶泡機,很少喝拿鐵的我也變成習慣加牛奶了!

膠囊咖啡最為人垢病的就是環保問題,當初會選Nespresso的原因就是膠囊比Dolce Gusto好回收。所以我一直說服同仁使用完後要將膠囊放在回收袋裡,我甚至還從垃圾桶挖同仁丟的空膠囊回來過。但後續交到雀巢這一段卻讓我感覺環保這一塊只是官方的影片宣傳,實際上並不是這一回事。

熱心的同事第一次幫我拿去站前店的新光三越櫃點回收,店員說沒有原本的回收袋,問要不要拿回去清洗再使用,還是拿一般的密封袋?因為原有的袋子長滿了霉菌,我同事就選擇一般密封袋。第二次再拿去回收時,連普通的密封袋也沒了,直接跟我同事說用一般的袋子裝就行。

我是不知道專門賣咖啡機的店員有沒有聞過放半個月發霉咖啡渣的味道,但同事聽完之後的感覺是店員真的有在回收膠囊嗎?還是人一離開,他們就丟垃圾桶了?

我致電客服詢問,對方回答是櫃點的問題,因為公司規定連一般的密封袋也不能提供,統一在官網買7條可以送一個袋子。我問當時買16條也只有一個袋子,我要怎麼把160顆膠囊丟在同一個袋子裡?客服回覆說那先幫我補一個袋子在帳戶裡,日後可以在購買時順便領取。

我又說,當我拿膠囊回去回收時,代表我是你們忠誠且重視環保的客戶,但你們的回應卻讓我感受不到特地去一趟的價值。換個袋子有這麼困難嗎?別人是用完即丟,我們拿過來卻這樣被對待,公司的政策是否要調整呢?

之後客服還是回覆網站買膠囊就會送回收袋的官方回答,不太想反應我的建議。我真的覺得雀巢應該訂個回收率標準,不到該數值就有必要提出來檢討,因為這真的是名副其實的不環保。

* 官網是寫明可在精品店拿取,實際上我們在新光三越A11館也不能拿。

除了環保的問題外,使用上還方便的,有朋友來可以馬上沖一杯咖啡。而且咖啡是Espresso的,加牛奶非常適合。此外大概就沒什麼優點了吧...

Share:

Passwordless scp file to Synology NAS

Synology 要先開啟ssh與home directory功能。

前往homes目錄

cd /var/services/homes

將該使用者的目錄權限設為755。(原本是777,底下以bkuser帳號為例)

chmod 755 bkuser

在帳號的home上新增.ssh目錄

mkdir ~/.ssh/

目錄權限設為700

chmod 700 ~/.ssh/

編輯 /etc/ssh/sshd_config 檔案,將參數改為下方數值

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys

在來源主機產出key (詢問通通按enter)

ssh-keygen -t rsa

查詢是否產生成功

$ cd ~/.ssh
$ ll
total 12
-rw------- 1 user user 1679 Jun  2 15:02 id_rsa
-rw-r--r-- 1 user user  391 Jun  2 15:02 id_rsa.pub

接著將id_rsa.pub檔案scp到NAS

scp ~/.ssh/id_rsa.pub bkuser@192.168.20.102:~/.ssh

在NAS裡,把id_rsa.pub內容加進同一層目錄的authorized_keys檔案中

cat id_rsa.pub >> authorized_keys

authorized_keys檔權限要設為644
chmod 644 authorized_keys

來源主機使用scp,會在.ssh目錄多一個known_hosts的檔案,之後就不會再詢問密碼了!
Share:

網頁阻止IE相容性檢視語法

之前發現自己寫的 jQuery Mobile 網頁在 IE 上會異常。追半天才發現是網站被加入相容性檢視,強制以 IE6 的結果自然是無法呈現 jQuery Mobile 語法了。

解決的方法是在 <head> </head> 中加入這一行程式碼:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

意即使用 IE 來到此網頁時,需以實際的版本或 Chrome 檢視。

其餘相關語法,例如強制相容 IE6 ,請參考: 【HTML教學】X-UA-Compatible設置IE兼容模式
Share:

和歌壽司


之前提到公司附近一家偽日式餐廳,開幕不到三個月後關門大吉。 (食記:上田日式定食)

沉寂一段時間後,又開了新的日式餐廳:和歌壽司 (Waka sushi)

以一般上班區域餐廳來說並不平價,但食材用的很好。

手機拍的菜單:






飲料是羅漢果茶。


老婆點的日本綜合魚天丼。


我的天丼,味噌湯裡有不同的魚片,很豐富。中間小碗是醬汁,直接淋在丼飯上。


小方盤是十月底之前,慶開幕送的80元炸蝦,配著盤中的胡椒鹽很不錯。小圓盤應該是岩鹽,口感也很棒!

丼飯很豐富,連干貝也炸下去了。份量很大碗,一碗199塊扣除成本老實說沒賺多少,是一個滿適合請客吃飯的地點。只是單點不要點太多,會大失血!

店名:和歌壽司 (Waka Sushi)
地址:台北市重慶南路一段66號一樓
Share:

Mac 取消滑鼠右鍵選單 CleanMyMac 項目

CleanMyMac 是一套滿好用的空間整理程式。但平常點選右鍵要編輯檔案時,會多出兩個我不太會去用的功能:Securely Erase with CleanMyMac 、 Erase with CleanMyMac。


剛看到一篇 VICJHT 網友分享的文章:如何取消蘋果電腦右鍵裏頭不需要的服務選單,解決了我的問題,也一併分享給大家!

首先,在點選系統偏好設定,再點選鍵盤。

在快速鍵頁中,點選服務。將 Erase with CleanMyMac 和 Securely Erase with CleanMyMac 取消勾選即可。

Share:

Node.js 使用網頁更新MongoDB資料

需要安裝下列 module:
npm install express
npm install mongodb
npm install --save body-parser

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var express = require('express');

var MongoClient = require('mongodb').MongoClient
    , format = require('util').format;    

/*
 * body-parser is a piece of express middleware that 
 *   reads a form's input and stores it as a javascript
 *   object accessible through `req.body` 
 *
 * 'body-parser' must be installed (via `npm install --save body-parser`)
 * For more info see: https://github.com/expressjs/body-parser
 */
var bodyParser = require('body-parser');

// create our app
var app = express();

// instruct the app to use the `bodyParser()` middleware for all routes

//app.use(bodyParser()); // 原寫法會有錯誤訊息,改以下面寫法:
//------------------------------
app.use(bodyParser.urlencoded({
  extended: true
}));

app.use(bodyParser.json())
//------------------------------

// A browser's default method is 'GET', so this
// is the route that express uses when we visit
// our site initially.
app.get('/', function(req, res){
  // The form's action is '/' and its method is 'POST',
  // so the `app.post('/', ...` route will receive the
  // result of our form
  var html = '<form action="/" method="post">' +
               '身份證號:' +
               '<input type="text" name="uid" placeholder="A123456789" />' +
               '<br>' +
               '到期日:' +
               '<input type="text" name="afterDate" placeholder="2014/01/01" />' +
               '<br>' +
               '<button type="submit">送出</button>' +
            '</form>';
               
  res.send(html);
});

// This route receives the posted form.
// As explained above, usage of 'body-parser' means
// that `req.body` will be filled in with the form elements
app.post('/', function(req, res){
  var uid = req.body.uid;
  var afterDate = req.body.afterDate;

  if (uid != '' & afterDate != '') {
    console.log(uid.toUpperCase()); // 加.toUpperCase()強制大寫
    console.log(afterDate);

    MongoClient.connect('mongodb://10.0.1.1:27017/mydb', function(err, db) {
    if(err) throw err;

    db.collection('mycollection').update({name: uid.toUpperCase()}, {$set: {"data1.after": afterDate, "data2.after": afterDate}}, function(err) {
        if (err) console.warn(err.message);
        else console.log('successfully updated');
        db.close();
      });

    });
  };  

  var html = '送出資料如下<br> <br>' + 
             '身分證號: ' + uid.toUpperCase() + '<br>' +
             '到期日: ' + afterDate + '<br>' +
             '<a href="/">回上頁</a>';
  res.send(html);
});

app.listen(80);

在terminal執行這個js程式即可。(80port在mac需要使用sudo才能跑)

畫面:

參考資料:example reading form input with express 4.0 and body parser for node js
Share:

Node.js 使用 FTP 傳送檔案

先安裝 FTP 模組: npm install ftp

node.js程式如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  var Client = require('ftp');
  var fs = require('fs');

  var c = new Client();

  c.connect({
   host: "10.0.1.1",
   user: "test",
   password: "test"
  });

  c.on('ready', function() {
    c.put('BackupLog.txt', 'Remote/BackupLog.txt', function(err) {
      if (err) throw err;
      c.end();
    });
  });
Share:

使用 Node.js 執行外部壓縮程式與外部指令

4~9: 執行壓縮指令,壓縮完畢跳到 code:11
11~17: 執行 xcopy 指令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
var exec = require('child_process').exec,
    child; 
 
child = exec('"C:\\Program Files\\7-zip\\7zG.exe" a -r -mx9 "BackupLog.7z" "BackupLog.txt"', function(error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);
    }
 
    exec('xcopy "BackupLog.7z" \\\\10.0.1.1\\test /y', function(error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
            console.log('exec error: ' + error);
        }
    });
});
Share:

Node.js 取得上個月的日期字串

取年份要使用 getFullYear()才會有完整正確的數字。

如果要取當月,因為月份的算法是0~11,需改為(MyDate.getMonth()+1)。
1
2
3
4
5
6
var MyDate = new Date();
var MyDateString;

MyDateString = MyDate.getFullYear() + '/' + ('0' + MyDate.getMonth()).slice(-2);

console.log(MyDateString);

結果:

Ians-MBP:Desktop ian$ node LastMonth.js
2014/07

取前一天:

1
2
3
4
5
6
var MyDate = new Date();
var MyDateString;

MyDate.setDate(MyDate.getDate() - 1); // 取前一日,自行依備份日期調整

MyDateString = MyDate.getFullYear() + '/' + ('0' + (MyDate.getMonth()+1)).slice(-2) + '/' + ('0' + MyDate.getDate()).slice(-2);  //日期補零 2014/08/16

原有取得的日期沒有補0,因此才有加0和slice(-2)的轉換,原理如下。(原文網址:http://stackoverflow.com/questions/3605214/javascript-add-leading-zeroes-to-date)

To explain, .slice(-2) gives us the last two characters of the string.
So no matter what, we can add "0" to the day or month, and just ask for the last two since those are always the two we want.
So if the MyDate.getMonth() returns 9, it will be:
("0" + "9") // Giving us "09"
so adding .slice(-2) on that gives us the last two characters which is:
("0" + "9").slice(-2)
"09"
But if MyDate.getMonth() returns 10, it will be:
("0" + "10") // Giving us "010"
so adding .slice(-2) gives us the last two characters, or:
("0" + "10").slice(-2)
"10"
Share:

熱門文章