Wednesday, December 7, 2011
Tuesday, November 8, 2011
Modern Design Patterns and Styles
Inversion of Control Containers and the Dependency Injection pattern
http://martinfowler.com/articles/injection.html
Duck-Typing
Wednesday, October 5, 2011
GS2 Rooting and Flashing Rom
Things to do:
- 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....)
- 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 - 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 - Reboot. You will see an exclamation mark in the boot screen. It is normal as the system detected an insecure kernel.
- From your app drawer, you will find two new icons. 1) Superuser; 2) CWM (ClockWorkMod)
- 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!
- Before you do it, make a backup of your original rom for safe. You can do that in CWM.
- 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, September 4, 2011
PHP Object Serialization Format
It is undocumented but could be clearly seen here:
http://www.metabrew.com/article/reading-serialized-php-objects-from-erlang
http://www.metabrew.com/article/reading-serialized-php-objects-from-erlang
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:
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.
"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
** 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
- 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.
- Custom post type
http://codex.wordpress.org/Post_Types#Custom_Types
Five types of post: post, page, attachment, revisions, nav menus - Template Hierarchy
http://codex.wordpress.org/Template_Hierarchy - 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 - Change the default Wordpress notification mail subject:
http://www.yakupgovler.com/we-change-wordpresssitenamecom.html - 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 - What is Hook, Action and Filter?
http://codex.wordpress.org/Plugin_API - Debugging in Wordpress
http://codex.wordpress.org/Debugging_in_WordPress
Sunday, May 22, 2011
iOS App Development Fundamentals
Objective-C
Some ideas:
Tips:
- 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/ - 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.
- View Controller Basics
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html#//apple_ref/doc/uid/TP40007457-CH112-SW10 - 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 - Fundamental Design Pattern
http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhone101/Articles/02_DesignPatterns.html#//apple_ref/doc/uid/TP40007514-CH10-SW1 - Cocoa Design Pattern
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6 - Creating a Working Nib File With Interface Builder
http://iphone-obsessed.blogspot.com/2009/02/creating-working-nib-file-with.html
Some ideas:
- In IB, File's Owner, First Responder and Delegate are all proxy objects, not real!
Tips:
- 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
- command + s = save
- command + c = copy
- command + v = paste
- command + z = undo
- shift + esc = show completion list
- ctrl + . = show next completion
For Mac:
- command + shift + 3 = capture full screen
- 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.
- Install Ubuntu 10.04 (desktop edition)
- Set up openssh and LAMP (optionally install phpmyadmin or mysql administrator)
# apt-get install openssh-server
# apt-get install lamp^ - Download the latest CodeIgniter (CI) and unpack it in your web root directory.
http://codeigniter.com/user_guide/installation/index.html - To restart apache and mysql, run this:
# /etc/init.d/apache2 restart
or
# sudo service apache2 restart
# sudo service mysql restart - 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) - All urls above should go to the same destination, a welcome page.
- Now use the mod_rewrite module of apache to remove the ugly index.php in the urls:
http://codeigniter.com/wiki/mod_rewrite/ - The procedures there are basically fine with a few modifications to fit my configuration.
- 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 - This is my apache extra config file put under /etc/apache2/conf.d/
http://dl.dropbox.com/u/908171/blog/blogger/codeigniter-url-rewrite - 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.
- Now it's done. You can access your CI controller in the following way:
www.yourdomain.com/ci/welcome/ - 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:
Reference:
http://blog.herbert.groot.jebbink.nl/2009/05/using-php-on-gae.html
http://wiki.caucho.com/Quercus_Google_App_Engine
- Download Resin-4.x.x from http://caucho.com/download
- Copy lib/resin.jar to your WEB-INF/lib
- Add com.caucho.quercus.servlet.GoogleQuercusServlet as a standard servlet in your web.xml
- 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
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
> 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.
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 = false3. 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
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.
Subscribe to:
Comments (Atom)