顯示具有 技術文章 標籤的文章。 顯示所有文章
顯示具有 技術文章 標籤的文章。 顯示所有文章

2012年6月25日 星期一

TabbarController為每個UIView 加上各自的UINavigationController

在TabbarController為每個獨立的 UIView加上各自的UINavigatonController有兩個方法:

一、自已以語法的方式建立。


1、在 ExampleAppDelegate.h 檔加上下面的語法
/*
 *   ExampleAppDelegate.h
 */
@interface ExampleAppDelegate : NSObject 
{
   UIWindow *window;
   UITabBarController *mainBar;
   UINavigationController *firstNav;
   UINavigationController *secondNav;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *mainBar;
@property (nonatomic, retain) UINavigationController *firstNav;
@property (nonatomic, retain) UINavigationController *secondNav;

@end

2、在 ExampleAppDelegate.m 寫上下面的語法
/*
 *   ExampleAppDelegate.m
 */
#import "ExampleAppDelegate.h"
#import "FirstView.h"
#import "SecondView.h"

@implementation ExampleAppDelegate

@synthesize window;
@synthesize mainBar;
@synthesize firstNav;
@synthesize secondNav;

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   firstNav = [[UINavigationController alloc] init];
   FirstView *firstView = [[FirstView alloc] init];
   [firstNav pushViewController:firstView animated:YES];
   firstNav.tabBarItem.title = @"First Tab";
   [firstView release];

   secondNav = [[UINavigationController alloc] init];
   SecondView *secondView = [[SecondView alloc] init];
   [secondNav pushViewController:secondView animated:YES];
   secondNav.tabBarItem.title = @"Second Tab";
   [secondView release];

   mainBar = [[UITabBarController alloc] init];
   mainBar.viewControllers = [NSArray arrayWithObjects:
                                             firstNav, secondNav, nil];

   [self.window addSubview:mainBar.view];
   [self.window makeKeyAndVisible];
   return YES; 
}

- (void)dealloc
{
   [firstView release];
   [secondView release];
   [mainBar release];
   [window release];
   [super dealloc];
}

二、以 xib 的方法建立
可以參考 http://blog.willwinder.com/2011/05/xcode4-uitabbarcontroller-with.html
特要注意的是要在 view 也拉一個 UINavigationControll,然後把UIView 和 UINavigationControll全建立個link 到 ViewController.h檔裡面,然後在 VieDidLoad加上下列的語法:在這邊我把UIView取名為theParentViewOutlet,UINavigationController取名為 navigationController。
這樣的用意是可以取代原本的navigationController。就不用改太多了。
[self.theParentViewOutlet addSubview:self.navigationController.view];
以上的資料參考下面兩個網址:
1、http://ppkko.blogspot.tw/2011/05/tabbarcontroller-navigationcontroller.html

2、http://stackoverflow.com/questions/5163024/uinavigationcontroller-inside-uiview

2012年6月5日 星期二

利用個人Gmail收取企業用戶Gmail帳戶的設定

要被收信的Gmail帳戶設定:
被收信帳戶:aaa@gmail.com
登入要被收信的Gmail帳戶,進入設定→轉寄和POP/IMAP
在POP下載的部份,啟用POP功能,共用二種功能
對所有郵件啟用POP:表示新舊郵件都會一併被下載到收信帳戶
對現在起所收到的啟用POP:表示設定完成開始,收到的信件才會下載到收信帳戶
第2個當郵件以POP存取後的動作,有三種:
保留副本:表示郵件到收信帳戶後,原帳戶一樣會保留在收件匣中
封存副本:表示郵件到收信帳戶後,原帳戶一樣會存留,但不在收件匣,會在全部的信件
刪除副本:表示郵件到收信郵戶後,原帳戶不保留信件
選擇完畢後按下儲存變更即可。
收信帳戶設定:
收信帳戶:bbb@gmail.com
點擊設定→帳戶→新增你的郵件帳戶
輸入要被收信的Email,點擊下一步
輸入使用者名稱、密碼,如果是Google Apps的信箱,在使用者名稱必需輸入完整Email
POP伺服器請選:pop.gmail.com 通訊埠:995
下面選項可勾選SSL安全連線,在收信時更安全,另外為了區分外來的郵件,可以勾選將外來郵件標示為:(預設是Email),也可以下拉自行新增其它標籤,設定完畢後點擊新增帳戶

參考來源:http://steachs.com/archives/837

2012年3月13日 星期二

XE2 找不到DesignIntf.duc 的處理方法

當在BCB6 或 Delphi 6的版本下可以正常安裝的元件,重新裝到 XE2時,都會出現找不到DesignIntf.du,這個時間就需要在  Project>Options>Delphi Compiler>Compiling>Other Options>Additional options to pass to the compiler 加上 參數 -LUDesignIDE,這樣就可以編輯過了,示意圖如下:


資料參考來源:https://forums.embarcadero.com/thread.jspa?threadID=1966

2011年12月7日 星期三

Centos 5.5 完整 Cacti + Spine

1、先安裝以下的軟体
yum -y install zlib-devel libpng-devel gcc libart_lgpl-devel zlib-devel
2、安裝 apacth + mysql + php
3、安裝 rrdtool
下載最新版本:http://oss.oetiker.ch/rrdtool/
cd rrdtool-1.4.5
./configure --prefix=/usr/local/rrtool --disable-python --disable-tcl
make && make install
4、安装net-snmp
下載地址:http://sourceforge.net/projects/net-snmp/files/net-snmp/ tar zxvf net-snmp-5.2.6.tar.gz
cd net-snmp-5.2.6
./configure --prefix=/usr/local/net-snmp
make
make install
copy一份配置過去:
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
啟動snmpd:
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
要被監控的主機還要安裝這個東西,還需要進行一個簡單的配置:
vi /usr/local/net-snmp/share/snmp/snmpd.conf
加上一行
# sec.name source community
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
com2sec local 192.168.1.210 public #允許監控主機來抓資料
5、安装cacti
下載最新版本:http://www.cacti.net/
tar zxvf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /home/www/xxxx.xxx/cacti
創建系統用戶:
useradd cacti
chown cacti:cacti /home/www/xxxx.xxx/cacti
創建資料庫用戶並授權
mysql -uroot -p123456 -e "create database cacti"
mysql-uroot -p123456 -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cacti'@localhost IDENTIFIED BY 'cacti'"
導入數據庫資料並修改配置:

mysql -ucacti -pcacti cacti < /home/www/xxxx.xxx/cacti/cacti.sql
vi /home/www/xxxx.xxx/cacti/include/config.php
根據你所設置的情況來修改下面的內容:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
最後設上 crontab 讓 net-snmp 每5分鐘抓一次數據
crontab -u cacti -e
*/5 * * * * /usr/local/php/bin/php /home/www/xxxx.xxx/cacti/poller.php > /dev/null 2>&1
授權 rra 目錄
chown -R cacti:cacti /home/www/xxxx.xxx/cacti/rra
6、安裝spine
下載最新版本:http://www.cacti.net/downloads/
tar zxvf cacti-spine-0.8.7g.tar.gz
cd cacti-spine-0.8.7g
./configure --prefix=/usr/local/cacti-spine --with-snmp=/usr/local/net-snmp
make && make install
設定 spine
vi /usr/local/cacti-spine/etc/spine.conf
根據實際狀況修改以下內容:
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass cacti
DB_Port 3306
DB_PreG 0
6、最後打開瀏覽器,測試一下。http:/xxxx.xxx/cacti

第一次使用,會顯示 cacti 的安裝步驟。
點選 “Next” 選擇“New Install”,再點選“Next”
指定 rrdtool、 php、 snmp 工具的執行檔路徑,確定所有的路徑都是顯示“ FOUND”,沒有“NOT FOUND”的,點選 Finish 就可以完成安裝。
Cacti 預設的用戶名及密碼都是 admin,第一次會要求修改admin 密碼
然後進去 settin 修改一下配置如圖:

然後在poller 頁上選擇 spine 如圖:
本文參考出自 “疯狂的猴子” 博客。 如需安裝 cacti - mysql套件: 請參考此網址:http://xok.la/2009/05/cacti_mysql_monitor.html

2010年1月30日 星期六

VMware Server Error 1718. on Windows Server 2003

VMware Server 裝在我的Windows Server 2003的OS上,
安裝的過程有點小小不順利, 安裝時跳出Error 1718的錯誤.

解決辦法:


1.開啟「控制台」=> 「系統管理工具」

2.開啟「本機安全原則」

3.選擇左手邊的「軟體限制原則」( 有可能是沒東西的,此時,按右鍵->新增原則)

4.選擇「強制」,然後「右鍵」-> 「內容」

5.最後一步 : 選「所有使用者,除了本機系統管理員(E)」

最最後,記得重開機…

2010年1月26日 星期二

啟用 VSPhere4.0 的VMware Web Access 服務

用 root 登入
執行 > service vmware-webAccess start
啟用服務

2010年1月5日 星期二

在 Centos 上架設SVN 服務器

**以下的指令,請以 root 執行
1、先檢查是否有安裝 SVN
在 CentOS5 中預設會裝有SVN。
可以使用下面的指令查詢SVN Version
svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 18:00:04

## 如果沒有安裝過 SVN Version 和版本比較舊,可以透過下面的指令,進行安裝 or 更新
安裝:yum -y install mod_dav_svn subversion

2、新增 SVN 的管理帳號(這可以看個人的命名習慣)
useradd -d /var/empty svn(這是帳號)

3、進行 SVN Server 相關配置
## 先建立要用來放 SVN 相關的主要目錄(這可以看個人習慣)
mkdir /var/svn

## 放專案資料
mkdir /var/svn/repos

## 放權限管理相關
mkdir /var/svn/etc

## 更改該目錄的擁有者
chown -R svn.svn /var/svn

4、啟動 SVN Server

## 啟動服務
svnserve -d -r /var/svn/repos

5、建立專案名稱(如果有多個專案,只要重覆這個行為就好了)
## 建立每個單獨專案名稱
svnadmin create /var/svn/repos/MyProjectName
chown -R svn.svn /var/svn/repos/MyProjectName

## 配制專案的使用相關設定,每個專案可以獨立設定
vi svnserve.conf
** 可以直接修改舊的設定,或是直接新增
[general]
anon-access = none
auth-access = write
password-db = /var/svn/etc/svn-user.conf
authz-db = /var/svn/etc/svn-authz.conf
realm = My First Repository

說明:
anon-access = none #不允許匿名訪問
auth-access = write #通過驗證的用戶可以讀和寫
password-db = /var/svn/etc/svn-user.conf #每個用戶名單
authz-db = /var/svn/etc/svn-authz.conf #每個用戶權限名單
realm = My First Repository #專案名稱

## 如果有第二個
[general]
anon-access = none
auth-access = write
password-db = /opt/svn/etc/svn-user.conf
authz-db = /opt/svn/etc/svn-authz.conf
realm = My Second Repository

----------------------------------------------------------------------
svnserve.conf的原始?容:

### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
# anon-access = read
# auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
# password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository
----------------------------------------------------------------------

## 用戶帳號及帳號管理

## 設置用戶帳號
vi /var/svn/etc/svn-user.conf

## 下面是範例,請根據自已需要修改
[users]
harry = harryssecret
sally = sallyssecret
bote = botessecret

說明:
[users] #這是必要的,是表示用戶配置開始
harry = harryssecret # harry 是帳號 , harryssecret 是密碼。注意,是明碼的密碼
sally = sallyssecret # 同上
bote = botessecret # 同上

** 可以把所有的帳號都在同一個檔案上記錄就好了,至於那個帳號要談問什麼專案,可以在權限管理的檔案裡,進行設置。

## 設置帳號權限管理
vi /var/svn/etc/svn-authz.conf

## 下面是範例,請根據自已需要修改
[groups]
MyProjectName = harry
MyProjectName2 = sally

[MyProjectName:/]
@MyProjectName = rw
@MyProjectName2 = r

[MyProjectName2:/]
@MyProjectName2 = rw
bote = rw

參考來源:http://16hot.blog.isyi.com/post/1/552

2009年12月17日 星期四

windows 查詢端口被什麼軟体給佔住的方法

先進到命令列模式(開始 -> 所有程式 -> 附屬應用程式 -> 命令提示字元),指令:netstat -abn。參數 a 表示列出所有連線中或 listening的連線;n 表示使用數字形態列出,亦即 http 會以 80 顯示,ftp 會以 21 顯示…;b為列出哪支程式在使用該連接埠;o 則為列出該程式的 PID。以下圖為例,可以看出使用 80 port 的程式為 httpd.exe,即正被 Apache 使用。



若上述方式無法找到佔用的程式,可再試著使用下列方法。改下指令:netstat -ano。以下圖為例,可以看出 80 port 正在使用,PID 為 1392。


知道 PID 之後,接著就可以使用『工作管理員』查看該 PID 是由哪一支程式所執行。找到 PID 1392 原來是 Skype.exe。(亦可在命令列模式下,輸入: 『tasklist』指令查詢。


進到 skype 裡查看設定,果然在連線設定看到預設允許其使用 80/443 port 進對外連線。將此勾選移除,再重新啟動 skype,釋放其佔用的 80 port。



如果工作管理員中沒列出 PID 欄位,可自行調整顯示欄位設定。




參考來源:http://blog.xuite.net/reshenchen/computer/28953313

2009年12月2日 星期三

在XPPro上架設VPN Server

首先就是分配ip位址的設定,必須符合分享器(router)所給的內部網域區段。中文版的windows xp的設定如下列各圖:
一、 選擇網路連線


二、建立新的連線



三、進入新增連線精靈,進行下一步


四、選擇設定一個進接的連線


五、選擇接受連入連線


六、連入連線接收裝置,直接跳到下一步,不需作任何設定

七、選擇允許私人連線



八、點選Internet Protocol(TCP/IP),再點「內容」設定


九、指派tcp/ip的位址範圍:這部份要非常注意,必須設定與對外router所設的內部網域 相同的ip sheme,假設router設定192.168.2.1為gateway,dhcp配給192.168.2.100-50,那就可以作如下圖的設定 192.168.2.x,讓vpn server分配的ip位址跟router同屬於一個IP scheme 。這個設定非常重要,要不然會無法讓連上vpn server的電腦透過router對外。


十、最後就是按下「完成」結束設定。


十一、防火牆的部份,無論是開啟哪個部份的防火牆,都必須開啟這四個port 1723、500、50、51給予對應vpn server所用的ip。這部份若沒有處理,會讓client無法連上server
整個設定的過成就屬步驟十跟十一最重要,其他的步驟按照圖片設定,基本上沒有太大問題,就這麼簡單。

2009年10月7日 星期三

MCRYPT 加密方式解釋

運作模式 描述
MCRYPT_MODE_ECB 適合隨機數據,你可以用這種模式來加密不同的密碼。
MCRYPT_MODE_CBC 用來加密文件。
MCRYPT_MODE_CFB 建議用來加密字節流。
MCRYPT_MODE_OFB 專門用在不容許出錯的應用系統。
MCRYPT_MODE_NOFB 兼容 OFB,但更加安全。
MCRYPT_MODE_STREAM 需要資料流算法時使用,例如 WAKE 或 RC4。

2009年4月7日 星期二

Linux 下查詢硬碟的空間

Linux 下查詢硬碟空間的指令
df

2009年4月6日 星期一

Active FTP 及 Passive FTP

Active FTP 及 Passive FTP

在大部份的防火牆設定中,使用 FTP 傳輸檔案時經常會遇到需要設定使用 passive mode 的 FTP.但大部份的 FTP client 軟體,default 大都是 active mode FTP,這二種 FTP 模式在傳輸上有何不同?先了解 FTP 的工作方式,有助於了解 active FTP 及 passive FTP 的不同.

一般的 FTP 使用 TCP port 20 及 21 二個 port. 正常來說, port 20 是傳輸資料用,而 port 21 傳輸命令.但事實上並不是一直使用 port 20 來傳輸資料.

Active mode FTP (主動模式 FTP)
在 Active 模式的 FTP client 一開始時會先使用一個大於 1024(N) 的 TCP port 連結至 FTP server 的port 21. 然後 FTP client 會打開該 port 的下一個數字的 port (N+1) 並送至 FTPserver 說期望下次的溝通可以經由新的 port (N+1),這樣比較不會占用到 FTP server 的 port 21 而影響別的 FTP sessions.同時 FTP server 會使用 port 20 連結至 FTP client 新送過來的 port 號來傳資料.
所以在防火牆上需要打開:

FTP server port 21 from anywhere # 給 FTP client 開始連接
FTP server port 21 to port > 1024 # 給 FTP server 回應 client 命令
FTP server port 20 to port > 1024 # 給 FTP server 開始資料傳輸
FTP server port 20 from port > 1024 # 給 FTP cleint 傳送 data ACK 給 server

所以連接順序為:
1. FTP client use TCP port 1026 for command to FTP server command port 21
2. FTP server use TCP port 21 responed to FTP client command port 1026
3. FTP server use TCP port 20 for sending data to FTP client data port 1027 (1026 + 1)
4. FTP client use TCP port 1027 ( 1026 + 1) for data ACK to FTP server port 20

問 題在於使用 active mode FTP 時主控權在 FTP client, FTP client 並不是真正的連至 FTP server 的data port (TCP port 20),它只是告訴 FTP server 它準備在那個 port 接收資料及port+1 傳送 ACK.並期望 FTP server 可以主動連接至 FTP client 所期望的 port.這在使用防火牆的環境中就會造成問題.


Passive mode FTP (被動模式 FTP)
解 決主動模式在防火牆外面時所發生無法連接的問題,可以用被動模式 FTP. 在Passive mode FTP 下,FTP client一開始和 active mode FTP 一樣,打開二個 port (N > 1024 及 N+1), 使用第一個port 連接至 FTP server的 port 21,並送出命令 PORT 讓 server 連至 N port 再送出 PASV 命令給 server,這樣會造成 server使用 一個大於 1024 的 port 連接至 client 並送出命令 PORT N ( N >1024 ) 給client. 樣 client 就會使用 N + 1 並開始傳輸資料.

這樣子在防火牆上需要設定

FTP server TCP port 21 from anywhere # FTP client 開始連接至 FTP server
FTP server TCP port 21 to port > 1024 # FTP server 回應 client 控制
FTP server TCP port > 1024 from anywhere # FTP client 資料傳輸
FTP server TCP port > 1024 to client port > 1024 # FTP server 回應資料 ACK至 client data port

連接順序為:
1. FTP client use TCP port 1026 to FTP server command port 21 via command PASV
2. FTP server use TCP port 21 to FTP client 1026 command port for reply data port 2024
3. FTP client use TCP port 1027 (N+1) to FTP server 2024 for data transmit and ACK
4. FTP server use TCP port 2024 to FTP client for data transmit and ACK


因為 passive mode FTP 是由 FTP server 發起一個大於 1024 的 port 至 client,在防火牆上的設定就相對簡單,而可以傳輸資料而不會被防火牆 block.


參考資料 RFC595

註:在 Windows 下原來的 ftp client 並沒有 passive 這個指令,但可以利用 literal 指今來下給 FTP server FTP session 為 passive mode

方法如下:

C:\>ftp 10.10.100.121
Connected to 10.10.100.121.
220 (vsFTPd 2.0.1)
User (10.10.100.121:(none)): ftp
331 Please specify the password.
Password:
230 Login successful.
ftp> literal pasv
227 Entering Passive Mode (10,10,100,121,242,172)
ftp>

可以看到進入 passive mode 了.使用的 port 號碼是 (242*256)+172= 62124

若是 UNIX 但 FTP client 不支援 passive mode 指令可以用 quote pasv

資料來源:http://tasuka.idv.tw/blog/index.php?entry=entry051011-132012