2010年9月27日 星期一

Reverse SSH Tunnel (反向 ssh 連線)

Gmail IMAP, SMTP, POP3 設定值

IMAP
  • imap.gmail.com
  • Port: 993
  • Use SSL: Yes
SMTP
  • smtp.gmail.com
  • Port for TLS/STARTTLS: 587
  • Port for SSL: 465
POP3
  • pop.gmail.com
  • Port: 995
  • Use SSL: Yes

Meld : Diff and merge tool.

Meld is a visual diff and merge tool. You can compare two or three files and edit them in place (diffs update dynamically). You can compare two or three folders and launch file comparisons. You can browse and view a working copy from popular version control systems such such as CVS, Subversion, Bazaar-ng and Mercurial. Look at the screenshots page for more detailed features.


Token-pasting operator(##) in C

我們都知道C語言define前端處理假指令用來定義變數、字串或幾行的原始碼(統稱為巨集, Macro)。
當某一巨集被定義為參數帶入之巨集, 我們最常用的就是把該參數當作變數或指標來使用,如下所示:
#define INC_IDX(val, size) (++val % size) -> 以參數為變數之值帶入此巨集
#define GET_DATA(ptr) (ptr->data) -> 以參數為指標帶入此巨集

然而,我們可以把巨集所帶入的參數當作為識別子(Token)的一部分,如下所示:


#include

int class_num = 9;
int class_stds = 10;

#define GET_MEMBER(postfix) class_ ## postfix

int main(void)
{
     printf("class_num: %d\n", GET_MEMBER(num));
     printf("class_stds: %d\n", GET_MEMBER(stds));
     return 0;
}


如上列所示,class_num可以經由GET_MEMBER巨集(帶入部份識別子, 也就是num)取得,此參數傳遞方法稱為Token-pasting operator,這是一個非常好用的方法, 提供給大家參考。

The Stringify Operator (#) in C

繼上次提到Token-pasting operator (##) in C文章後, 這次講一下在C語言define巨集參數使用的另一種方法, 在參數名稱前加一個#運算子, 此運算子代表所帶入的參數會被編譯器視為"字串", 所以#運算子又被稱為字串化運算子, 底下為一簡單的例子:


#define GET_RESULT(exp) printf(#exp "=%d\n", exp)

int main(void)
{
    GET_RESULT(3+2);
    return ;
}






How to use simple speedtest in RaspberryPi CLI

  pi@ChunchaiRPI2:/tmp $  wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py --2023-06-26 10:4...