2010年4月19日 星期一

How to Step TAB for SCREEN

#編輯 .screenrc

vi ~/.screenrc
caption always "%{= bK} %{= bG} [%n]%t @ %H %{-} %= %{= bR} %l %{-} | %{= bG} %Y-%m-%d %{-}"
hardstatus alwayslastline " %-Lw%{= BW}%n%f %t%{-}%+Lw %=| %0c:%s "
 
# Ctrl + left  : last page
# Ctrl + right : next page
bindkey "^[[1;5C" next
bindkey "^[O5C" next
bindkey "^[[C" next
bindkey "^[[1;5D" prev
bindkey "^[O5D" prev
bindkey "^[[D" prev


SCREEN 熱鍵

1) Ctrl+a c:建立一個新分頁
2) Ctrl+a a:分頁往返
3) Ctrl+a [1...9]:切換到第 n 分頁
4) Ctrl+a d:Detach 將工作放到背景執行
5) Ctrl+a S:分割上下畫面
6) Ctrl+a [TAB]:在分割畫面中往返

References:
http://en.gentoo-wiki.com/wiki/Screen
http://blog.cwke.net/2008x06/screen
screen
screen 常用教學筆記

2010年4月8日 星期四

strtok 應用

char* strtok(char* str, const char* delimiters)

用途:將字串切割成tokens


用法:

#include <iostream>
#include <string.h>

using namespace std;

int main()

{
    char c[20] ="Hello World!"
    char *s;
    
    s = strtok(c, " ");

    while(s!= NULL){
      cout >> s >> endl;

      s = strtok(NULL, " ");
    }
}

2010年4月7日 星期三

解決ssh 連線登入問題

3.3 - ssh(1) takes a long time to connect or log in

Large delays (more that 10 seconds) are typically caused a problem with name resolution:
  • Some versions of glibc (notably glibc 2.1 shipped with Red Hat 6.1) can take a long time to resolve "IPv6 or IPv4" addresses from domain names. This can be worked around with by specifying AddressFamily inet option in sshd_config.
  • There may be a DNS lookup problem, either at the client or server. You can use the nslookup command to check this on both client and server by looking up the other end's name and IP address. In addition, on the server look up the name returned by the client's IP-name lookup. You can disable most of the server-side lookups by setting UseDNS no in sshd_config.
解決的方法, 修改 /etc/ssh/sshd_conf 裡面
UseDNS no

小於 3.7.1 版之前的請改
VerifyReverseMapping no

更早之前的如 2.9.9p2 
ReverseMappingCheck no
* Replaced sshd(8)'s VerifyReverseMapping with UseDNS option.
  When UseDNS option is on, reverse hostname lookups are always
  performed.

2010年3月24日 星期三

UNSIGNED INT

unsigned 修飾字是用於正數變數, 在32位元 


int的範圍是 -2147483648~2147483647, 加上修飾字 unsigned int, 其範圍是 0~4294967295.


補充:


  • sbyte 型別代表的是帶正負號的 8 位元整數,且介於 -128  127 的值。
  • byte 型別代表的是不帶正負號的 8 位元整數,且介於 0  255 的值。
  • short 型別代表的是帶正負號的 16 位元整數,且介於 -32768  32767 的值。
  • ushort 型別代表的是不帶正負號的 16 位元整數,且介於 0  65535 的值。
  • int 型別代表的是帶正負號的 32 位元整數,且介於 -2147483648  2147483647 的值。
  • uint 型別代表的是不帶正負號的 32 位元整數,且介於 0  4294967295 的值。
  • long 型別代表的是帶正負號的 64 位元整數,且介於 –9223372036854775808  9223372036854775807 的值。
  • ulong 型別代表的是不帶正負號的 64 位元整數,且介於  18446744073709551615 的值。
  • char 型別代表的是不帶正負號的 16 位元整數,且介於 0  65535 的值。



http://en.wikipedia.org/wiki/Integer_(computer_science)
http://programming.im.ncnu.edu.tw/Chapter5.htm

2010年3月9日 星期二

如何在 opensuse 上安裝套件

因為不常用OpenSuse 常常忘掉安裝套件的指令, 所以把指令寫起來以免日後找不到~~

#搜查資料庫
zypper search gcc

#安裝gcc
zypper install gcc33 gcc33-c++