2011年1月20日 星期四

Mac OS GitHub設定


之前經常在GitHub上抓取別人的Source,到今天才知道原來有一個這麼棒的東西喔!所以就來試試看...
當然一開始也是花上些時間,才發現原來真的是要認真看文件阿XD

開始使用之前先說一下流程如何進行:
1.安裝 Git與註冊一個GitHub帳號
2.設定/上傳 ssh key
3.最後使用command 或Gitbox tool 進行push or pull

1.安裝 Git與註冊一個GitHub帳號

首先就請大家先上GitHub註冊個帳號吧!接著開一個Project瞜
網站:https://github.com/
註冊完請開一個project吧!其實就是圖上的New Respository

開完之後呢!你就會看到你專案內有下面的步驟!其實跟著做就可以了,不過我們還有更重要的任務要做先來看吧

2.設定/上傳 ssh key

這裡只要跟著help頁面做就可以了http://help.github.com/mac-key-setup/
直到你做到跑出類似下面的頁面
$ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/tekkub/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/tekkub/.ssh/id_rsa. Your public key has been saved in /Users/tekkub/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db tekkub@gmail.com The key's randomart image is: +--[ RSA 2048]----+ |     .+   +      | |       = o O .   | |        = * *    | |       o = +     | |      o S .      | |     o o =       | |      o . E      | |                 | |                 | +-----------------+
接著你在去下cat /Users/tekkub/.ssh/id_rsa.pub 應該會類似下面的加密碼

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAdsfer31324erfewBMNG4DSj/sdf23fd few+x0O32YNgdUJQoigNdyktDHufOzAz89lPpT0+HCdwr5oxTYjVybF76Pcc/Vwoha4ewqrwefe324r2436qH4WjJWtypiSA2VDQOOFa9JeNL+1h+4Kxea1wlWdy0MPLYQr5X6UHrL214GHtlo0+QvZ2D9o9LygzMJr09NiOlXX1CltOmsSX4Lz/MhpG6g9VK9bA2i/alhClZqRmlZl6H4zaFqalFLND9/CWPo5iMldVjAIdCn9LcMIgXNrtoMLURmfAPlVcWwfvnyA1vh+aiOgEUxbHTA9RxTAJzMEBE2btFHmlQ== m31527@gmail.com

你就把這整段貼到Account Settings>>ssh public keys >> add another public key
然後記得title打mail瞜

如下圖


完成之後就可按照以下步驟進行瞜

Global setup:

Download and install Git   git config --global user.name "m31527"   git config --global user.email m31527@gmail.com         

Next steps:

  mkdir Hell   cd Hell   git init   touch README   git add README   git commit -m 'first commit'   git remote add origin git@github.com:m31527/Hell.git   git push origin master       

Existing Git Repo?

  cd existing_git_repo   git remote add origin git@github.com:m31527/Hell.git   git push origin master

若在上面流程有出現master Permission denied (publickey) 這種錯誤,就是key問題!建議重新產生密碼瞜~另外產生密碼時輸入的密碼不要是空的比較好!


3.最後使用command 或Gitbox tool 進行push or pull


參考這裡瞜 http://www.gitboxapp.com/




補充說明:若要用command 方式將Project Clone、Push、Pull可用下面語法:


  clone project(也就是cvs/svn上的checkout)
$ git clone git@github.com:billyanyteen/github-services.git
  
  push (上傳)


假設我要把error.doc上傳至GitHub
步驟1.將error.doc複製到專案底下
步驟2.commandline 下 git add error.doc
步驟3.commandline 下 git commit -m 'error file'
步驟4.git push origin master 
接著看到訊息應該就沒問題了..
$ git push origin master
  
  pull (下載)
$ git pull origin master
GitHub help參考網址 http://help.github.com/forking/

2010年11月9日 星期二

Mac 安裝PHP XDebug


這幾天在用Mac開發php環境,光搞一個PHP debug環境有夠難搞的!後來發現其實要改的php.ini是要改/etc/php/ 下而不是/private/etc/ 接下來我就把流程分享給大家..

1.首先打開終端機,輸入$ sudo pecl install xdebug
2.接著輸入 $ sudo cp /etc/php.ini.default /etc/php.ini 複製一份至該路徑下

3.sudo vi /etc/php.ini且加入下面程式


[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.remote_enable = On
;xdebug.remote_handler = 'dbgp'
;xdebug.remote_handler = 'gdb'
;xdebug.remote_mode = jit
xdebug.remote_autostart = 1

4.重啓apache sudo apachectl stop 停止 sudo apachectl start 啓動


5.接著打開phpinfo若有看到下圖內容即表示安裝完成





接下來就看你要用Eclipse或MacGDBp瞜


我後來用MacGDBp 參考官網 http://www.bluestatic.org/software/macgdbp/

2010年10月22日 星期五

iphone開發,使用Three20 lib產生view的問題


最近小弟在進行iPhone App改版時遇到一個問題,搞了超久總算找到方式解決!
我也不知道我這個方式是不是很爛,遇到問題是這樣~
首先我因為要用Launcher效果,所以繼承了TTViewController,結果造成切換view時,view下方如圖1,紅色區塊的功能完全無法被點擊,所以去看了TTViewController.m之後,就想說我重新定義frame的長寬,結果沒想到就解決問題了...

@interface LauncherViewTestController : TTViewController {
TTLauncherView* _launcherView;
UIToolbar *first_toolbar;
UISearchBar *searchBar;
UILabel *title_label;
UIToolbar *states_toolbar;
}
@property (nonatomic,retain) UISearchBar *searchBar;
@property (nonatomic,retain) UIToolbar *first_toolbar;
@property (nonatomic,retain) UIToolbar *states_toolbar;
@property (nonatomic,retain) UILabel *title_label;

圖1

第二個問題如果一開始的view位置全部怪怪可以定義[window setCenter:CGPointMake(160, 259)];我在第一個view沒有使用xib方式賺寫,但其他view都採用xib,解決造成後面幾個view的內容全部網上,全部超過到statesbar去了,所以後來加入window setCenter 解決了~大家可以試試看摟

2010年8月21日 星期六

iPhone SQLite 新增一直失敗找到原因了




一開始的部份就不再說明教學了(是我太懶),讓大家參考這三個網站

1.iPhone Tutorial: Using SQLite3 database
http://ved-dimensions.blogspot.com/2009/03/iphone-development-sqlite3-populating.html

2.SQLite Tutorial - Saving images in the database
http://www.iphonesdkarticles.com/2009/02/sqlite-tutorial-saving-images-in.html

3.How do you insert an image into SQLite on the iPhone?
http://stackoverflow.com/questions/737443/how-do-you-insert-an-image-into-sqlite-on-the-iphone

今天為了要讓iPhone能透過讀取xml方式,取得更新的圖片url,得到url之後希望把圖片存到SQLite內,搞了超久一直失敗...
首先出現out of memory,光這個問題就找一個下午=.=,最後認真看到國外網友,它點出了db沒有正確讀到才會發生問題,下面這隻method就是連線成功的方式

- (void) getNewDBConnection{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"data.sqlite"];
BOOL success = [fileManager fileExistsAtPath:path];
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Database Successfully Opened :)");
} else {
NSLog(@"Error in opening database :(");
}
}

接下來連線成功之後遇到第二個error : no such table: item ,這個問題也讓人很吐血,明明在resource下有一個data.sqlite,我也用Firefox plugin 的SQLite Manager 建好table與欄位,為什麼會告訴我找不到item這個table呢。最後我把上面的method中的path路徑 NSlog出來才看到原來根本不是在resource下的data.sqlite,原來它存取的是/Users/Maccc/Library/Application Support/iPhone Simulator/4.0/Applications/87386C6E-CCBC-48BF-A121-CF9900D4E0C3/Documents/data.sqlite

insert 至db的method

- (void) addData:(UIImage*)image {
NSString *title=[NSString stringWithString:@"test"];
NSData *ImageData = UIImagePNGRepresentation(image);
NSInteger Imagelen = [ImageData length];
if(addStmt == nil) {
const char *sql = "insert into item(title,imageData) values(?,?)";
if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
NSLog(@"Error while creating add statement. '%s'", sqlite3_errmsg(database));
}

sqlite3_bind_text(addStmt, 1, [title UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_blob(addStmt, 2, [ImageData bytes], Imagelen, SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStmt))
NSLog(@"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
sqlite3_last_insert_rowid(database);
//Reset the add statement.
sqlite3_reset(addStmt);
}

如果你有要轉換UImage為NSData可以用此method

- (UIImage*)loadImageFromUrl:(NSString*)url
{
NSURL *picUrl = [NSURL URLWithString:url];
NSData *picData = [NSData dataWithContentsOfURL:picUrl];
UIImage *image = [UIImage imageWithData:picData];
return image;
}

這樣你轉完後就可以存進db了..

2010年6月17日 星期四

iPhone Facebook SDK : no such file error


iPhone的Facebook SDK我相信有不少人在套用時候發生不少問題,光是把開發環境設定我就搞很久,按照官方的設定方式如圖匡起來的地方,根本一樣設定不好,所以你build的時候就會出現類似
FBSession.h no such file ......等等的error,解決方式如下
依照此流程:

在xcode的專案上按右鍵,選Get info,然後選Build tab,然後找到Search Paths下得Header Search Paths 把絕對路徑的Facebook路徑給他,
ex: Header Search Paths /Users/Mac/Documents/facebook-facebook-iphone-sdk-1059eb6/src/

這時候你在build應該就可以了

2010年6月10日 星期四

分享mobile開發上很棒的Framework

最近開發手機app時,常為了解決我們以關鍵字為主的服務,技術上會遇上許多問題,
所以找了很多Framework,希望未來可以再開發上更方便且又可以跨平台,所以跟大家分享一下瞜..
一個跨平台的Open Source Framework,可以支援iPhone, Android,Blackberry,Symbian (Sony Ericsson , Nokia , Qt) ,WindowMobile ,Palm,重點是寫他的code只要具備Html+Javascript+CSS就可以寫出手機平台的程式,真的非常的棒,你完全可以不需要會Object-c Java or C++ 就可以做出一個很棒UI的app,我今天還特別測試想說jQuery是否可以支援,我就去網路上找了一下,jQuery推出了一個以支援Mobile平台上的jQuery 稱 jQTouch,然後我就把jQTouch內的Demo code與JS and CSS檔丟進iPhone 的PhoneGap專案,沒想到執行之後居然可以跑,這就表示
連Ajax都可以支援,所以未來要開發除了iPhone平台之外的手持式平台都可以用這個來試水溫...

想挑戰他的威力就上網站看吧


附上執行的image

2009年5月24日 星期日

一起加入Android的世界吧

最近一兩個月開始真正的投入Android懷抱中,其實Android不太難涉入,老實說比學一個Flex還要快呢!想學的人可以聽聽我的建議嚕
1.首先呢你必須先將Android開發環境裝好,其實在這裡部分我想第一次安裝就會遇上問題,所以我這邊的建議呢,建議你直接新安裝Ecplise 3.4版本
Ecplise 3.4下載
接著就去下載最新版的Android 1.5 SDK
Window 版
Linux 版
都下載且解壓縮完後接著就是安裝ADT(Android Developer Tool),接著按照官方的做法加入ADT

  1. Start Eclipse, then select Help > Software Updates....
  2. In the dialog that appears, click the Available Software tab.
  3. Click Add Site...
  4. Enter the Location:
    https://dl-ssl.google.com/android/eclipse/

    If you have trouble aqcuiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

    Click OK.

  5. Back in the Available Software view, you should see the plugin listed by the URL, with "Developer Tools" nested within it. Select the checkbox next to Developer Tools and click Install...
  6. On the subsequent Install window, "Android DDMS" and "Android Development Tools" should both be checked. Click Next.
  7. Read and accept the license agreement, then click Finish.
  8. Restart Eclipse.
以上都弄完後,記得你的java JDK 一定要1.6版本以上喔!!,Ecplise內complier一定也要選1.6以上喔!!

這樣你就算把基本環境架設完嚕