Wednesday, October 5, 2011

GS2 Rooting and Flashing Rom

Things to do:

  1. For the time in 5/10/2011, the latest official rom is ZSKG2 which is for HK phone model. So I upgrade my phone from KF4 to KG2 with the Samsung Kies software. (Note: when you connect your phone with Kies, make sure the debug mode is turned off....)
  2. Go to XDA download Odin3-1.85 and the CF-Root kernel which is a kernel that has already been rooted. For my phone, I need this: CF-Root-SGS2_ZS_OZS_KG2-v4.1-CWM4
    http://forum.xda-developers.com/showthread.php?t=1103399
  3. The next step is pretty simple. Boot to the download mode, and start Odin to flash the rooted kernel. It just takes you no more than 5 minutes. Done!
    http://www.hkepc.com/forum/viewthread.php?tid=1627473&extra=&page=1
  4. Reboot. You will see an exclamation mark in the boot screen. It is normal as the system detected an insecure kernel.
  5. From your app drawer, you will find two new icons. 1) Superuser; 2) CWM (ClockWorkMod)
  6. Now your phone is rooted and you can use all kinds of root-required apps from Market, such as Titanium Backup. You can also flash other roms!
  7. Before you do it, make a backup of your original rom for safe. You can do that in CWM.
  8. Also, guys in XDA recommend to do a backup for the efs folder of your phone. The phone contains some phone-unique-and- specific information. Do it with the shell command listed here:
    http://forum.xda-developers.com/showthread.php?t=1068193

Sunday, June 26, 2011

Wordpress Timeout Problem

If you got this error message when you are using the wordpress API to access plugins and themes:

"An Unexpected HTTP Error occurred during the API request in wordpress"

You probably need to do 2 things to fix it:

1. Edit the wp-includes/class-http.php and find the line:


'timeout' => apply_filters( 'http_request_timeout', 5),

then, change to timeout value from 5 to some values like 30 or 60.

2. Increase the memory limit of your php setting to 64MB.

Wordpress NextGen Gallery Plugin


The wordpress plugin "NextGen Gallery" requires php 5.2 or above but my CentOS is running 5.1. So I need to update it with the following steps:
step 1:
Add PHP 5.3 repository
# rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm 

enable and install 
# yum --enablerepo=webtatic install php 

or update 
# yum --enablerepo=webtatic update php 

Congratulation, You/We have installed php5.3 

we can verify that it is installed or not by 
 [root@server tmp]# rpm -q php php-5.3.6-1.w5


** Remark
You may also want to install the GD library to allow WP resizes your images:
# yum --enablerepo=webtatic install php-gd

Friday, June 10, 2011

Tips for Wordpress

  1. When WP is configured to use permalink, WP will create a .htaccess file in its root directory which uses the mod_rewrite module to rewrite an url. In this case, make sure that your Apache is configured to allow override by the sub-configs located in the document root.
  2. Custom post type
    http://codex.wordpress.org/Post_Types#Custom_Types
    Five types of post: post, page, attachment, revisions, nav menus
  3. Template Hierarchy
    http://codex.wordpress.org/Template_Hierarchy
  4. Wordpress Query
    http://codex.wordpress.org/Query_Overview
    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Function_Reference/get_posts
  5. Change the default Wordpress notification mail subject:
    http://www.yakupgovler.com/we-change-wordpresssitenamecom.html
  6. Hide Menu items from user based on user's role
    http://www.tomauger.com/2011/web-development/wordpress/wordpress-hiding-menu-items-from-users-based-on-their-roles-using-a-custom-walker
  7. What is Hook, Action and Filter?
    http://codex.wordpress.org/Plugin_API
  8. Debugging in Wordpress
    http://codex.wordpress.org/Debugging_in_WordPress

Sunday, May 22, 2011

iOS App Development Fundamentals

Objective-C
  1. If you have understanding in C language and OO design, this is a wonderful quick introduction to all basics of Obj-C you need to know:
    http://cocoadevcentral.com/d/learn_objectivec/
  2. If you need to go further and have time, see this (chinese version)
    http://www.otierney.net/objective-c.html.zh-tw.big5

Xcode and Interface Builder
- Most of the time, in iOS app development, you deals with different views, controllers and nib/xib files. It is important to know what they are at the beginning.
  1. View Controller Basics
    http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html#//apple_ref/doc/uid/TP40007457-CH112-SW10
  2. Resource Programming Guides - Nib File, File's Owner, Delegate Object
    http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW8
  3. Fundamental Design Pattern
    http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhone101/Articles/02_DesignPatterns.html#//apple_ref/doc/uid/TP40007514-CH10-SW1
  4. Cocoa Design Pattern
    http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6
  5. Creating a Working Nib File With Interface Builder
    http://iphone-obsessed.blogspot.com/2009/02/creating-working-nib-file-with.html


Some ideas:
  1. In IB, File's Owner, First Responder and Delegate are all proxy objects, not real!

Tips:

  1. To get the screen size

  • float w = self.view.frame.size.width;
  • CGRect rect = [[UIScreen mainScreen] bounds];
    NSLog(@"The height is %f", rect.size.height);

Friday, May 20, 2011

Shortcuts and Tips for Xcode and Mac

For Xcode

  1. command + s = save
  2. command + c = copy
  3. command + v = paste
  4. command + z = undo
  5. shift + esc = show completion list
  6. ctrl + . = show next completion
For Mac:
  1. command + shift + 3 = capture full screen
  2. command + shirt + 4 = capture part of a screen

Configure CodeIgniter and LAMP in Ubuntu

The following steps describe the configuration I used in this setup.

  1. Install Ubuntu 10.04 (desktop edition)
  2. Set up openssh and LAMP (optionally install phpmyadmin or mysql administrator)
    # apt-get install openssh-server
    # apt-get install lamp^
  3. Download the latest CodeIgniter (CI) and unpack it in your web root directory.
    http://codeigniter.com/user_guide/installation/index.html
  4. To restart apache and mysql, run this:
    # /etc/init.d/apache2 restart
    or
    # sudo service apache2 restart
    # sudo service mysql restart
  5. Now you can test your CI welcome page (assume you unpack it into a subfolder "ci"):
    www.yourdomain.com/ci/
    www.yourdomian.com/ci/index.php                               (default delegate)
    www.yourdomian.com/ci/index.php/welcome/               (welcome is the default controller class)
    www.yourdomian.com/ci/index.php/welcome/index/      (index is the default function in the controller)
  6. All urls above should go to the same destination, a welcome page.
  7. Now use the mod_rewrite module of apache to remove the ugly index.php in the urls:
    http://codeigniter.com/wiki/mod_rewrite/
  8. The procedures there are basically fine with a few modifications to fit my configuration.
  9. This is my modified .htaccess file put under my "ci" folder (you got to rename it yourself):
    http://dl.dropbox.com/u/908171/blog/blogger/codeigniter-url-rewrite_.htaccess
  10. This is my apache extra config file put under /etc/apache2/conf.d/
    http://dl.dropbox.com/u/908171/blog/blogger/codeigniter-url-rewrite
  11. One thing omitted in the document is that you need to remove the .htaccess comes with the default installation inside the "application" and "system" subfolder in "ci". That two files are invalid and will cause the mod_rewrite working improperly.
  12. Now it's done. You can access your CI controller in the following way:
    www.yourdomain.com/ci/welcome/
  13. Thanks God and the CI team!




Monday, April 18, 2011

Running PHP on GAE

Steps to run Quercus (Java-based PHP interpreter) on Google App Engine:

  1. Download Resin-4.x.x from http://caucho.com/download
  2. Copy lib/resin.jar to your WEB-INF/lib 
  3. Add com.caucho.quercus.servlet.GoogleQuercusServlet as a standard servlet in your web.xml
  4. Add index.php pages to your web-app

Reference:
http://blog.herbert.groot.jebbink.nl/2009/05/using-php-on-gae.html
http://wiki.caucho.com/Quercus_Google_App_Engine

Friday, April 15, 2011

JDO, JPA and Hibernate

1. JDO and JPA are specifications. They specify an interface to abstract the database technologies.

2. Hibernate is an implementation of JPA.

3. DataNucleus is an implementation of both JPA and JDO.

Java Data Objects (JDO) is a standard interface for storing objects containing data into a database. The standard defines interfaces for annotating Java objects, retrieving objects with queries, and interacting with a database using transactions. An application that uses the JDO interface can work with different kinds of databases without using any database-specific code, including relational databases, hierarchical databases, and object databases. As with other interface standards, JDO simplifies porting your application between different storage solutions.


Java Persistence API (JPA) is a standard interface for storing objects containing data into a relational database. The standard defines interfaces for annotating Java objects, retrieving objects using queries, and interacting with a database using transactions. An application that uses the JPA interface can work with different databases without using any vendor-specific database code. JPA simplifies porting your application between different database vendors.


Reference:
http://code.google.com/intl/eclipse/appengine/docs/java/datastore/jdo/overview.html


Wednesday, April 6, 2011

Running Linux Process in Background After Logout

You may know to append an ampersand to a shell command so as to run a process in background. For example,

> java myprogram &

This command runs the Java program in background. However, the process will be halted when you log out the session. To overcome this, you can make use of the 'screen' command.

screen                  # start a virtual session which keeps itself alive even you log out
Ctrl-A + ?             # show help
Ctrl-A + d             # detach from the screen
screen -r              # re-attach to the previous screen

Reference here: http://jmcpherson.org/screen.html

Friday, April 1, 2011

Firefox Addon: User Agent Switcher

If you are using the User Agent Switcher add-on with Firefox, and find it pesky to reset the user agent every time when the browser restarts, here is a trick:

1. Open the configuration tab in your FF by typing "about:config" in the URL bar.
2. Add the following attribute and value.
useragentswitcher.reset.onclose = false
3. Done!

Sunday, March 20, 2011

Java Application Launcher's Options

-Dproperty=value
Set a system property value. If value is a string that contains spaces, you must enclose the string in double quotes:
java -Dfoo="some string" SomeClass

For options start with X, they are non-standard options.

http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/java.html

Saturday, March 5, 2011

Difference bewteen 3-tier and MVC architecture

At first glance, the three tiers may seem similar to the model-view-controller (MVC) concept; however, topologically they are different. A fundamental rule in a three tier architecture is the client tier never communicates directly with the data tier; in a three-tier model all communication must pass through the middle tier. Conceptually the three-tier architecture is linear. However, the MVC architecture is triangular: the view sends updates to the controller, the controller updates the model, and the view gets updated directly from the model.