2012年12月20日 星期四

depoly inotify-tools error : Protected multilib versions: glibc-2.12-1.80.el6.i686 != glibc-2.12-1.80.el6_3.6.x86_64


depoly inotify-tools時出現以下error :

Error: Protected multilib versions: glibc-2.12-1.80.el6.i686 != glibc-2.12-1.80.el6_3.6.x86_64
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
glibc-common-2.12-1.80.el6_3.6.x86_64 is a duplicate with glibc-common-2.12-1.80.el6.x86_64
glibc-common-2.12-1.80.el6_3.6.x86_64 has missing requires of glibc = ('0', '2.12', '1.80.el6_3.6')

solution:

yum remove glibc-2.12-1.80.el6_3.6.x86_64
接著再install一次

SCOM linux agent deploy error : ssl certificate error

當deploy SCOM linux agent時,出現ssl certificate error時,refer以下網址

http://technet.microsoft.com/en-us/library/hh212851.aspx

另外如果安裝完成後執行出現access is  denied,為Run as account設定上面問題,refer

http://blogs.technet.com/b/kevinholman/archive/2012/03/18/deploying-unix-linux-agents-using-opsmgr-2012.aspx

search: run as account

2012年10月12日 星期五

Nginx搭配Apache做balance與proxy與避免ip直接訪問

#所有php的动态页面均交由apache处理
location ~ .(php)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:88;
}
#所有静态文件由nginx直接读取不经过apache
location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
{ expires 15d; }
location ~ .*.(js|css)?$
{ expires 1h; }
ref: (http://www.ha97.com/5119.html)

一些觀念
ref : (http://www.itlearner.com/article/4508)

實作補充
ref : (http://stackoverflow.com/questions/3434182/apache-and-ultimate-config-for-nginx-to-serve-all-virtual-hosts-in-the-right-way)

//避免直接ip訪問
在nginx/conf.d/default.conf裡加上並寫上自己對應的rewrite rule ex:http://yourdomain.com$request_uri?


server {
        listen 80 default_server;#ip
        server_name ip;
        rewrite ^ http://mrshih.com$request_uri?;
}






2012年9月12日 星期三

升級到xcode4.5後facebook sdk有遇到問題

問題如下

Ld /Users/shih/Library/Developer/Xcode/DerivedData/food-csyywpmvwokybxdzxglwpmdzfgug/Build/Intermediates/food.build/Debug-iphoneos/food.build/Objects-normal/armv7s/food normal armv7s
    cd /Users/shih/Desktop/food
    setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -L/Users/shih/Library/Developer/Xcode/DerivedData/food-csyywpmvwokybxdzxglwpmdzfgug/Build/Products/Debug-iphoneos -F/Users/shih/Library/Developer/Xcode/DerivedData/food-csyywpmvwokybxdzxglwpmdzfgug/Build/Products/Debug-iphoneos -F/Users/shih/Desktop/food/../../Documents/FacebookSDK -filelist /Users/shih/Library/Developer/Xcode/DerivedData/food-csyywpmvwokybxdzxglwpmdzfgug/Build/Intermediates/food.build/Debug-iphoneos/food.build/Objects-normal/armv7s/food.LinkFileList -dead_strip -lsqlite3.0 -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.0 -framework MapKit -framework MobileCoreServices -framework CoreLocation -framework QuartzCore -framework UIKit -framework Foundation -framework CoreGraphics -framework FacebookSDK -o /Users/shih/Library/Developer/Xcode/DerivedData/food-csyywpmvwokybxdzxglwpmdzfgug/Build/Intermediates/food.build/Debug-iphoneos/food.build/Objects-normal/armv7s/food

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/shih/Documents/FacebookSDK/FacebookSDK.framework/FacebookSDK for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解決辦法

專案 => TARGET => Build Settings => Vaild Architectures => armv7 armv7s

把armv7 armv7s 改成 armv7








2012年9月2日 星期日

在storyboard下使用scroll view如何視覺化編輯畫面

1.
選擇controller的Inspector標籤
size屬性選擇Freeform

2.
選擇scroll view的Inspector標籤的右邊那個標籤
看到view那裏,編輯你要的width, height
接著就會看到storyboard上的controller的可編輯範圍出現變化了

3.
接著設計你的view
然後outlets scrollview的controller程式碼上,設定你在storyboard上的width, height

[self.sc setContentSize:CGSizeMake(320,600)];

DONE.

參考來源:
http://stackoverflow.com/questions/9288070/visually-arrange-subviews-in-a-large-uiscrollview

2012年8月28日 星期二

MBProgressHUD 方便建造thread, 並且不檔到navigation item(比如back)

http://github.com/matej/MBProgressHUD

.h檔部分
#import "MBProgressHUD.h"  
.....{
     
    MBProgressHUD *HUD;
}

.m檔部分
- (voidviewDidLoad{
    
    [super viewDidLoad];

    HUD = [[MBProgressHUD alloc] initWithView:self.tv];
    // 這裡是navigation的item如back在有loading image時可以用的關鍵,記住initWithView不可以指定  self.view,因為這樣以來loading會覆蓋過整個view,關鍵是要另外指定一個較小不是全範圍的view如table view來init.
    [self.tv addSubview:HUD]; 
    // 這裡則是要指定那個較小的view去做addSubview:HUD,如此以來執行的時候也可以按navigation的item了

    HUD.delegate = self;  
    HUD.labelText = @"Loading";  
    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}

- (void) myTask {  
     // Do something usefull in here instead of sleeping ...
     // 背景運作的code如網路載入資料等放這...
}

- (void)hudWasHidden { 
    // Remove HUD from screen when the HUD was hidded  
    [HUD removeFromSuperview];
}

2012年8月20日 星期一

兩個view controller資料傳送呼叫顯示等


---------------------------------------------------------------------------

1 呼叫 2 出來
[self performSegueWithIdentifier:@"upload to location" sender:nil];

---------------------------------------------------------------------------

1 傳送data到 2

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    id dv = segue.destinationViewController;
    [dv setValue:@"123,111" forKey:@"gps"];
}

---------------------------------------------------------------------------

---------------------------------------------------------------------------
2 返回 1 (不透過nav bar 的back button)


    UIViewController *prevVC = [self.navigationController.viewControllers objectAtIndex:1];//1 is level
    [self.navigationController popToViewController:prevVC animated:YES];

指定回去的leval,1就是leavl
---------------------------------------------------------------------------


2 傳送data回 1 (需要實作delegate)

step1 :(在page2的.h檔定義delegate)



//--delegate部分
@protocol page2Delegate <NSObject>

@optional
- (void)passValue:(NSString *)value;

@end
//--

//--
@property (nonatomic, weak) id<LocationDelegate> delegate;
//--

---------------------------------------------------------------------------

step2 : 在page1裡載入delegate

#import "page2.h"//實作協定用

@interface uploadViewController : UIViewController<page2Delegate>


並在page1.m檔裡面實作delegate 方法

- (void)passValue:(NSString *)value{
     //在這裡實作協定
}

---------------------------------------------------------------------------

strp3:在pag1呼叫page2時,指定自己是page2的delegate


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    id dv = segue.destinationViewController;
    [dv setValue:self forKey:@"delegate"];
}
---------------------------------------------------------------------------
step4 :在page2適當的call method,讓delegate執行這個method

[self.delegate passValue:@"pass from 2 data string"];


////類似(  performSegueWithIdentifier + prepareForSegue )

    /*
    UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    
    locationViewController *uploadView = [storybord instantiateViewControllerWithIdentifier:@"location"];
    [self.navigationController pushViewController:uploadView animated:YES];
     */





2012年4月2日 星期一

Video Locker - iPhone iPod


Lock video from Apple Photos app !

Features:
。One Second Lock : press home button , lock Immediately.
。Smart Lock technology : if you forget to turn off the app , it auto-lock your privacy.
。High Quality engine :No compressed , Perfect storage.
。AirPlay Support.
。Total Solution : Import , lock , delete , export , copy.
。Full-featured Video Player
。Import video from your iPod iPhone.
。Easy to use interface and operation.

Note:
Because of Apple's protection for user privacy, we can not delete video from an album locally, You must delete them yourself, after importing into Video Lock.

How to let users to make better use of the software is our obligation, Bath import photo features use special technical
which Apple requires the user allow to open Location Service.

Email : daan.shih@gmail.com

2012年3月31日 星期六

http://stackoverflow.com/questions/6568210/how-to-save-video-from-assets-url
http://stackoverflow.com/questions/4545982/getting-video-from-alasset

2012年3月28日 星期三

控制storyboard , reload storyboard , segue

好用參考來源
http://ryan.easymorse.com/?p=39

---------------------------

要使每次載入都回到login
可在applicationWillEnterForeground加上



    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    
    self.window.rootViewController = [storyboard instantiateInitialViewController];
    
    [self.window makeKeyAndVisible];

這樣可以reload整個storyboard,等於跟剛開啟一樣

-------------------

還有控制segue
    
    [self performSegueWithIdentifier:@"push to photolibrary" sender:nil];

詳細猜考來源

--------------------

直接載入特定storyboard

    UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    [self presentViewController:[storybord instantiateViewControllerWithIdentifier:@"PhotoLibrary"] animated:NO completion:nil];





如何製作圓角tableview, 加上textfield


    tableview.dataSource = self;
    tableview.delegate = self;
   
    //tableview 圓角 邊框 分隔線 coustom
    //圓角
    tableview.layer.cornerRadius = 13.0;
    tableview.layer.masksToBounds = YES;
    //分隔線
    [self.tv setSeparatorColor:[UIColor lightGrayColor]];
    //邊框
    tableview.layer.borderWidth = 1;
    tableview.layer.borderColor = [[UIColor lightGrayColor] CGColor];
   

    接著製作cell  並在裡面加上textfield
   
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tv dequeueReusableCellWithIdentifier:CellIdentifier];
   
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryNone;
    // Configure the cell...
    if([indexPath row]==0){

        //這是原本的cell text label

        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        NSString *tmp = [defaults objectForKey:@"question"];
        cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
        cell.textLabel.text = [NSString stringWithFormat:@"%@%@", @"密碼保護問題 : ", tmp];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }else if ([indexPath row]==2) {

        /這是textfield      

        u3 = [[UITextField alloc] initWithFrame:CGRectMake(9.5, 10, 300, 60)];
        u3.placeholder = @"新密碼";
        u3.returnKeyType = UIReturnKeyDone;
        u3.delegate = self;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell addSubview:u3];      
    }

    依此類推......

}

避免textfield被鍵盤檔到

http://www.cppblog.com/kongque/archive/2011/08/24/154256.html 簡單易懂的教學

2012年3月21日 星期三

push到storyboard的view上

給 storyboard 的 view 一個Identifier

UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

[self presentViewController:[storybord instantiateViewControllerWithIdentifier:@"PhotoLibrary"] animated:NOcompletion:nil];

粗體 => 取得view

--------------------------------------------------------------------------------------

建立一個segue 並加上idIdentifier
就可利用以下方法任意觸發

[self performSegueWithIdentifier:@"touch to push" sender:nil];


資料來源:http://ryan.easymorse.com/?p=39

2012年3月15日 星期四

不要讓法律嚇你!

有鑑於之前遇到的一些事情,讓我覺得這個資訊格外有用,不要被人家用法律嚇你!


設計手機上網填報之應用程式是否會侵害他人著作權? 作者:章忠信

引用來源網址:http://www.copyrightnote.org/crnote/bbs.php?board=3&act=read&id=1388

1783◎設計一款手機應用程式,讓使用者在手機上填報瓦斯使用度數,直接上載至瓦斯公司的瓦斯自報度數網頁,不需要到瓦斯公司的自報度數網頁去填寫,要不要獲得瓦斯公司之同意?

手機應用程式是屬於著作權法第五條第一項第十款所保護的電腦程式著作,依第十條規定,自創作完成起就自動受保護,不待作任何申請。

手機應用程式之功能具備讓使用者在手機上填報瓦斯使用度數,直接上載至瓦斯公司的瓦斯自報度數網頁,不需要到瓦斯公司的自報度數網頁去填寫。這種功能並沒有使用到瓦斯公司的著作,應該不必獲得瓦斯公司之同意。

這程式有兩個問題是瓦斯公司所關切。一是使用者會跳過瓦斯公司網頁,減少瓦斯公司網頁之點閱率,降低廣告收入,或是讓消費者看不到瓦斯公司希望消費者看到的相關消費或用戶訊息,但卻增加程式公司自己的點閱率與廣告收入;二是程式撰寫者會使用到瓦斯公司的使用度數申報表格。

前一問題是有無違反公平交易法,這部分目前國內尚未見先例,成立可能性尚不高;後一問題是瓦斯公司的表格是否具通用性,因為著作權法第九條第一項第三款規定,「通用之表格」不得為著作權標的。若瓦斯公司的表格是「通用之表格」,不得為著作權標的,任何人都可以自由利用。

2012年2月2日 星期四

clint收信驚魂

為了這個搞很久,原本自以為我domain跟mail.domain在dns都指向同一ip,在outlook設定時便在寄件伺服器名稱上寫上domain而已,結果沒辦法寄信,只能收信(收信很乖有寫mail.domain)

如果clint有辦法收信,但無法寄信,或者者寄信時認證錯誤,要確定smtp伺服器名稱(mail.water.twgg.org)要對!!!

如果你偷懶自以為寫(water.twgg.org),縱使dns設定對應ip都一樣,也不行。

簡單來說,你host -t mx domain 168.95.1.1

你的mx對應查到什麼名字就要填什麼名字

2012年2月1日 星期三

Dovecot 機車問題一覽

問題0
vim /etc/dovecot/dovecot.conf
下面加上
protocols = pop3
不然預設沒有開啟pop3 只有imap

-------
問題1(這個出現原因解法不一定正確或對應的起來)

Trying xxx.xxx.xxx.xxx...
Connected to xxx
Escape character is '^]'.
+OK Dovecot ready.
user root
+OK
pass appx4698
Connection closed by foreign host.

確定senmail的/var/spool/mail/有收到信,telnet也能跟我說說幾句話,好像很ok,但為什麼就不給登入?用outlook也不行登入!

看看maillog發現
Error: user ec2-user: Couldn't drop privileges: Mail access for users with UID 222 not permitted (see first_valid_uid in config file).


一切都有了解答,改uid即可


有時候不想用ssl:

vim /etc/dovecot/dovecot.conf
ssl_disable = yes

--------------


問題1-1

登入出現
Escape character is '^]'.
+OK Dovecot ready.
user user
-ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections.

代表要disable tls連線
vim /etc/dovecot/dovecot.conf
加上這行
disable_plaintext_auth = no
重開dovecot.conf
-------
問題2

maillog中出了這個訊息
Nov 5 15:54:16 test dovecot: pop3(towns): Error: user towns: Initialization failed: mail_location not set and autodetection failed: Mail storage autodetection failed with home=/home/towns
Nov 5 15:54:16 test dovecot: pop3(towns): Error: Invalid user settings. Refer to server log for more information.


vim /etc/dovecot/conf.d/10-mail.conf
找到並修改下行,沒找到就自己加上去,注意/var/spool/mail/這段,請改成自己系統的
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u

----------

問題三

Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: chown(/home/andy/mail/.imap/I
NBOX, group=12(mail)) failed: Operation not permitted (egid=501(andy), group based
on /var/spool/mail/andy - see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: mkdir(/home/andy/mail/.imap/I
NBOX) failed: Operation not permitted
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: Couldn't open INBOX: Internal
error occurred. Refer to server log for more information. [2012-02-03 11:07:17]
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Couldn't open INBOX top=0/0, retr=0/
0, del=0/0, size=0


原因:/var/mail/user 檔案權限不正確
在新增使用者後,/var/mail/ 都會產生一個使用者名稱的 mailbox,但預設的檔案權限為 660,需手動改為 600

處理方式:將 /var/mail/* 全改為 600,並在新增使用者時,手動修改檔案權限
只是這麼做,不就每次都要手動變更

-----問題4

fedora之類的新版本預設會鎖一堆port
到/etc/rc.d/rc.local
開port
下列示範port 53 25 110


/sbin/iptables -I INPUT -p tcp --dport 53 -j ACCEPT
/sbin/iptables -I INPUT -p udp --dport 53 -j ACCEPT

/sbin/iptables -I OUTPUT -p tcp --sport 53 -j ACCEPT
/sbin/iptables -I OUTPUT -p udp --sport 53 -j ACCEPT

/sbin/iptables -I INPUT -p tcp --dport 25 -j ACCEPT
/sbin/iptables -I OUTPUT -p tcp --sport 25 -j ACCEPT

/sbin/iptables -I INPUT -p tcp --dport 110 -j ACCEPT
/sbin/iptables -I OUTPUT -p tcp --sport 110 -j ACCEPT

用好後重開機,可能可以restart某些東西就不用,但我都直接重開機

------

;; connection timed out; no servers could be reached

dns架好後

用# host www.google.com.tw 127.0.0.1
ok
但# host www.google.com.tw 本地ip
會回復
;; connection timed out; no servers could be reached

很明顯本地dns有run起來,可是外面沒辦法呼叫
搞了老半天不是防火牆問題

是/etc/named.conf下的其中兩行在搞鬼

listen-on port 53 { 127.0.0.1; };
allow-query { 127.0.0.1; };

把預設改成any就可以了

listen-on port 53 { any; };
allow-query { any; };

2012年1月31日 星期二

0131

今天早上一直心神不寧

早上一到公司發現寫的xor遞迴跑太深,java丟出錯誤

於是乎超過部分就用if寫

接下來沒什麼,就這樣到了快下班因為隔天要處理mail server的事

先上網看了有關ip正反解與dns在unix like下的建設方法

This tomorrow has been upset

arrive office , find my xor via java has something wrong

final, the reason is Recursive write to deep

case stack over error, so overflow part use for loop to fix

next, no big thing, and then become get off work

because i need to process mail server

so suffer net , search about dns .

2012年1月30日 星期一

httpd

cd /etc/httpd/conf
nano httpd.conf

/sbin/service httpd restart

web資料夾
/var/www

*******
Access denied for user 'root'@'localhost' (using password: NO)

ans:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>

mysql>

*****phpmyadmin

http://superuser.com/questions/291230/how-to-install-phpmyadmin-on-linux-ec2-instance

2012年1月28日 星期六

vsftpd in Amazon EC2

1.
yum install vsftpd

2.
被動模式port設定

vi /etc/vsftpd/vsftpd.conf

#---Add following lines at the end of file---
pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=

3.
去ec2 consolo 開
21 tcp port
1024-1048 tcp port


3.
restart
$ /etc/init.d/vsftpd restart


resource:
http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/
其他conf看鳥哥囉~

2012年1月27日 星期五

Apache Tomcat in Amazon EC2

1.
安裝一般java
http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-java-stack.html
到Installing Oracle Java打完兩行指令後

2.
改變預設java環境(把open jdk換掉)
http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-java-stack.html#java
裡面的Replacing the OpenJDK Java Gracefully

3.
安裝tomcat
http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-basic.html
從Installing Tomcat From The Official Repo

4.
DONE
deploy your own application(s) to /usr/share/tomcat6/webapps (which is a symlink to /var/lib/tomcat6/webapps.) !!!!


coding部分
******環境建置*******
webapps下先建一个文件夹,比如 "WebApp "
在 "WebApp "下再建一个 "WEB-INF "文件夹, "WEB-INF "文件夹下建一个web.xml文件,内容
-------------------------------------web.xml--------------------------------
http://sun.cis.scu.edu.tw/~nms9115/articles/java/WebAppTutor/ServletPrimer/ServletPrimer.htm
表一
---------------------------------------------------------------------

"WEB-INF "文件夹下再建一个 "classes "文件夹,把 HelloWorld.class 放 "classes "文件夹里面
最后把整个 "WebApp "文件夹拷贝到TOMCAT根目录的 "webapps "文件夹下面

用url: http://localhost:8080/WebApp/helloworld 访问

******本機編譯注意******
首次在本機編譯servlet時必須要去找一個servlet.jar的檔案丟到ext裡或-classpath才能用javac編譯,原生lib裡面沒有。

******更動檔案如果沒有變動到web.xml server是不會reload的,請重新啟動,

service tomcat6 start
service tomcat6 stop

2012年1月25日 星期三

台電電費查詢 via JAVA

這本來不是件直的拿來記錄的簡單事情

但沒想到以為1小時搞定的東西硬是搞了2天,過程糾結點整理如下

1.show資料的頁面全是get而沒有post,讓笨笨的我困惑了,以往都是post看裡面有哪些data照傳就可以取得資料,這次卻沒post而全部是get,找來找去原來是很迅速的post資料後馬上跳頁,所以用firebug不易攔到,最後再對應你的cookie來做get識別

2.回應標頭檔很機車,長這樣
HTTP/1.1 200 OK
Cache-Control: private
Date: Wed, 25 Jan 2012 12:30:11 GMT
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked

看到了嘛....他沒有datalength。不過其實也無所謂照讀下面的資料不就好了,但問題就卡在這行Transfer-Encoding: chunked,你用inputstream不管資料怎麼讀怎麼錯,原因是chunked是1.1其中一種獨特的網頁傳輸編碼方式,解決方法也很吐血把HTTP改成1.0搞定........按,在這裡卡超久

3.最後則是雖然要讀的內容有中文可是
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8")); 文字會亂碼
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream())); 文字ok
這裡覺得很奇怪,也用了一下

寫下來記錄這次奇幻的經驗orz

2012年1月17日 星期二

把第三方jar檔通通跟本身打包再一起

http://www.icycandy.com/blog/use-netbeans-to-combine-jar-files-into-a-single-jar-file

2012年1月16日 星期一

輕鬆看新聞 app

thanks you to use this app :)

Support Email Address : daan.shih@gmail.com

中文介紹:

體驗簡單,眼睛看起來最舒服,閱讀最有效率的新聞瀏覽方式

*文章全自動換行,閱讀超輕鬆
*全文字瀏覽,BBS般的速度,出門在外3G網路依然順暢
*標題單獨呈現,當天新聞一眼瞬間
*使用流程特別設計,適合零散時間新聞閱讀

Introduction in English:

The fastest news app in Taiwan !
Lower loading time !
More reading time !

The easiest to use, the eyes look the most comfortable, most efficient news reading up browsing

* Articles automatic line, super-easy to read
* Full text browser, BBS-like speed, 3G network is still smooth away
* Title to display, easy to read all day news
* Use process specifically designed for fragmented time news reader

2012年1月14日 星期六

ftp系列via java tutorial

ftp
http://blog.csdn.net/hbcui1984/article/details/2720204

ftps
http://www.zehon.com/downloads.htm

2012年1月12日 星期四

ios socket

http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server

http://furnacedigital.blogspot.com/2011/03/socket.html

keyword:CFStreamCreatePairWithSocketToHost

2012年1月8日 星期日

SQLite 教學

http://bonjouryentinglai.wordpress.com/2011/03/20/fmdb%EF%BC%9A%E6%88%91%E7%9A%84sqlite%E6%95%91%E6%98%9F/

2012年1月5日 星期四

運用thread實作背景load data,同時畫面show loading Image

1.一開始先看如何製作並管理thread在obj-c環境下---運用NSInvocationOperation

http://c.gzl.name/archives/tag/nsinvocationoperation

2.上面教學沒有教到call back main thread的方法,這裡有---performSelectorOnMainThread

http://www.switchonthecode.com/tutorials/loading-images-asynchronously-on-iphone-using-nsinvocationoperation

3.有關畫面更新開發注意

除了main thread以外,其他thread不能使用UIkit,這意謂著你不能再其他thread做更新view的動作(addSubview: ....etc)

解決方法就是用第二點回到main thread並呼叫你想要的更新view的方法!

比如實作運用如MBProgressHUD來在main thread裡面做show Loading Image,然後在second thread裡面load data,load完之後再call back回main去執行[HUD removeFromSuperview];

4.如果配合MBProgressHUD開發而loading時間很長時(>5秒)請注意

另外有時候loading時間會很長,預設MBProgressHUD的loading image過一段時間(約5秒)不管是否有呼叫 removeFromSuperview都會自己消失,簡單得解決辦法是去MBProgressHUD.m找到hide方法,把它的

[self hideUsingAnimation:useAnimation];

這行註解調就可以了,這樣如果沒有呼叫removeFromSuperview圖案就不會消失囉~

2012年1月4日 星期三

AleartView---無網路提醒

這功能很重要

沒有apple會把你給退件!

1.先下載.h .m檔,這是ARC compatible版本
https://github.com/tonymillion/Reachability

2.使用no-wifi aleart教學
http://paulpeelen.com/2011/11/30/ios-4-ios-5-tutorial-uialertview-with-link-to-wifi-or-settings-app-using-reachability-and-xcode-4-2/

3.注意教學文是就算有3g沒wi-fi也提醒喔,所以改成

- (void)checkForHOSTConnection {

Reachability *hostReach = [Reachability reachabilityWithHostname:@"www.google.com"];
NSString *netStatus = [hostReach currentReachabilityString];
//NSLog(@"currentReachabilityString = %@", netStatus);

if ([netStatus isEqualToString:@"No Connection"])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"已關閉\"行動數據\"", @"AlertView")message:NSLocalizedString(@"開啟行動數據或使用WI-FI來取用資料。", @"AlertView")delegate:self cancelButtonTitle:NSLocalizedString(@"好", @"AlertView")otherButtonTitles:NSLocalizedString(@"設定", @"AlertView"), nil];
[alertView show];
}
}

會比較適當

2012年1月3日 星期二

畫面預載的Loading...畫面

https://github.com/jk/MBProgressHUD

參照上面project可以自由叫出loading畫面

但無法讓tableview先"預先載入空白畫面" 好讓我們在上面做loading

要再研究...

pull & Pull-refresh depend on ARC

http://blog.csdn.net/w59879213/article/details/7165236

照著改,有些沒講到下面補充

註解掉.m下的- (void)dealloc {}方法

去build phases的link binary with ....加入quartzcore.framework

可以在arc下跑了

實作方法照舊~

我拖來一個ViewController,阿我自己寫的xxxViewController是...

that was it !

選擇一套控制方法---當你在為Storyboard上新拖出來的ViewController選擇Custom Class時你正在為它上面的view做這件事。

否則view就會被系統的預設ViewController給控制,那只是個樣板,除了預設它不會去改變你拖出來畫面。

套上去了你客製化自己寫的xxxxViewController就會幫你去控制你在Storyboard上拖出來的東畫面。

2012年1月2日 星期一

Property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects

啟用arc,變數名稱不能用 new 或 alloc 或 copy 做開頭 ~

開發注意

.h
NSMutableArray *newsURLList;
@property (nonatomic,retain) NSMutableArray *newsURLList;

.m
@synthesize newsURLList;

都宣告完之後記得這個初始

self.newsURLList = [[NSMutableArray alloc] init];

如果忘記初始化,一直

[newsURLList addObject:string];

value一定取不出來都是(null),編譯器也不會跟你說有錯,怎麼死的都不知道