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),編譯器也不會跟你說有錯,怎麼死的都不知道