Tuesday, May 14, 2013

Config GData-objective-c-client to a Project


  1. Checking Out Sources
  2. Create Project to Test
  3. Add Source code GData to my Project
  4. Build Project and Copy Folder Headers
  5. Linking to the iPhone Static Library
  6. Removing Unneeded Code
  7. Config to Product/Archive


Checking Out Source

                Check out with link : http://gdata-objectivec-client.googlecode.com/svn/trunk/ 

Create Project To Test 

Copy Source code to my Project on folder:
              ex: GData

Add Source Code to Project.
              
    
Add a new target dependency:
             a.  Click your target -> Build Phases -> Target Dependencies -> the + button
             

             b. Choose GDataTouchStaticLib and click Add
             
             b.   Build Phases -> Link Binary With Libraries,  the + button 
                   add the libGDataTouchStaticLib.a
                   
             c. Also add the following frameworks at the same place, they are needed by GData.
    • SystemConfiguration.framework
    • Security.framework
    • libxml2.2.dylib
    • libz.1.2.5.dylib                   
            
           d. In Build Settings,  add the following entries under “Other Linker Flags”
               
          e. Also in Build Settings, set /usr/include/libxml2 under “Header Search Paths”
            
          f. Add some settings for Project GData
              Select GData.xcodeproj -> Select GDataTouchStaticLib - > Build Settings : type "Other C"
              Add to Debug and Release : 
                     -DGDATA_REQUIRE_SERVICE_INCLUDES=1
                     -DGDATA_INCLUDE_YOUTUBE_SERVICE=1
                
             
      
Build Project and Copy Folder Headers
          Build your project (⌘B). When build success.
         In your derived data directory, browse to Build/Products/Debug-iphonesimulator
           
           

        Copy Folder Headers to my Folder GData in Project and Add Files to ..                                                                
           
             

Removing Unneeded Code

However you build the library, it is worthwhile to remove code for the services that your application will not be using. To remove unneeded code, set these compile flags in the project or target build settings of the GData.xcodeproj project file. When compiling the sources directly into your application, set these flags in your project's settings.
The conditional flags in most source files of the library look something like this:
#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
So in either the project's settings for compile flags or in your project's config file, set GDATA_REQUIRE_SERVICE_INCLUDES to 1, along with the services you are using. For example,
Other C Flags: -DGDATA_REQUIRE_SERVICE_INCLUDES=1 -DGDATA_INCLUDE_CONTACTS_SERVICE=1
If your project compiles the OAuth 2 classes for authentication, also define the conditional -DGTM_INCLUDE_OAUTH2=1 in Other C Flags.
Do remember to set build settings so they apply to both Debug and Release configurations.
There is a conditional set in the static library target as a reminder to developers to define the needed services. For your project, replace or delete the definition
-DGDATA_INCLUDE_nameServiceHere_SERVICE=1
in the Other C Flags section of the static library target's Release configuration.

Config to Product/Archive

          


*Note: You can comment some code:
#if !DEBUG
  #if GDATA_INCLUDE_nameServiceHere_SERVICE && !GDATA_SUPPRESS_INCLUDE_WARNING
    #error The service placeholder compiler flag should be replaced by actual service specifications
  #endif
#endif

and 

Select GData.xcodeproj -> Select GDataTouchStaticLib - > Build Settings : type "skip" and change to Yes.



Ok done.
Good luck!




Wednesday, April 10, 2013

Cập nhật cách cấu hình Mongodb trên windows


Sau một thời gian sử dụng cách cấu hình này, hiện nay mongo đã có chút gì đó thay đổi dẫn đến hướng dẫn của mình có chút vấn đề.
Sau đây mình hướng dẫn lại mọi người cách cấu hình
1. Sử dụng: mongodb-win32-i386-2.4.1 (bản mới nhất 3/23/2013)

     2. Tạo file cấu hình: Lưu vào thư mục c:\mongodb\mongo.config (Chú ý phần đuôi mở rộng là .config)
##store data here
dbpath=c:\mongodb\data
 
##all output go here
logpath=c:\mongodb\log\mongo.log
 
##log read and write operations
diaglog=3

Đây là hình ảnh thử mục mongodb

                   
               
3. Tiếp đến là bạn chạy đoạn lệnh sau
C:\mongodb-win32\bin\mongod.exe --dbpath c:\mongodb\data



  Sau khi chạy được như vậy là đã thành công rồi.
Bạn lại mở 1 cửa sổ cmd khác để kiểm tra kết quả nhé


Ngoài ra ta có thể viết 1 service để tiện cho mỗi lần ta chạy thì có thể làm theo cách sau:

c:\mongodb-win32\bin> mongod --config c:\mongodb\mongo.config --install

Sau khi chạy đoạn lệnh cmd kia ta vào Start của window và gõ : Services
Sẽ thấy được ngay kết quả ta làm. Ở đây ta có thể start và stop một cách dễ dàng.

Good luck!

 

Thursday, April 4, 2013

Hidden features of xcode

1. Switch to Header/Source File - (h/m)
2. Jump to Definition of a symbol
3.  Find Text in Documentation of a symbol. (Only works if you have they symbol's Doc Set installed.)
4. Open Quickly

5. Takes you to the beginning and end of a line.
6. Select the next auto-completion argument.
7. Select the previous auto-completion argument


8. Shows the auto completion pop-up list.
9. Quickly jump to a Group in the Groups and Files pane
10. Swipe three fingers left - Go back
11. Swipe three fingers right - Go forward
12. Show or hide right menu



Friday, May 4, 2012

Từ khóa “static” [Java]


Từ khóa "static" có thể được sử dụng trong 3 trường hợp:
1) static variables (biến)  2) static methods 3) static blocks of code (1 đoạn code ).

Thường thì, khi bạn tạo ra một class, bạn chỉ chỉ ra object thuộc class đó trông như thế nào, có những hành vi gì. Bạn chưa thật sự có bất cứ thứ gì cho đến khi bạn tạo ra một instance của class đó. Chỉ khi đó thì vùng lưu trữ cho data mới được tạo và method mới có hiệu lực.
Tuy nhiên, có hạn chế khi: 1. bạn chỉ muốn có một vùng lưu trữ  cho một loại dữ liệu thôi, không phụ thuộc vào số object được tạo ra, 2. bạn muốn có những method không gắn liền với object cụ thể nào cả, method mà có thể gọi ngay khi chưa tạo ra object nào cả. Để khắc phục hạn chế này, hãy sử dụng từ khóa static
Để làm cho một field hay method trở thành static, chỉ đơn giản đặt từ khóa static lên trước khai báo của nó.
Ví dụ:
class StaticTest {
  static int i = 47;
}
Bây giờ, nếu bạn tạo ra 2 object s1, s2 thuộc class trên thì nó vẫn chia sẻ chung một vùng lưu trữ  i. Tức là s1.i và s2.i là cùng 1 giá trị.
Để chỉ một biến static, có thể thông qua object như thông thường hoặc thông qua chính class.
Với static method cũng như vậy. Ví dụ:
class StaticFun {
  static void incr() { StaticTest.i++; }
}
Ta có thể gọi hàm incr() từ object thuộc class StaticFun, hoặc từ chính class StaticFun.
Điểm khác nhau: static, khi áp dụng với field thì sẽ thay đổi hoàn toàn cách lưu trữ data, một bên là chỉ một vùng cho mỗi class, một bên là một vùng cho mỗi non-static object. Còn khi áp dụng với method, tác dụng lớn nhất của nó là có thể gọi method mà không cần phải tạo object, điều này rất quan trọng ví dụ như khi định nghĩa main() method.



Nguồn : http://hoangviet182.wordpress.com/2009/02/20/javat%E1%BB%AB-khoa-static/
http://www.javatutorialhub.com/wiki/All_about_%22static%22