Monday, February 16, 2015

Java Enum Assign Values

For Java Enums, the values are normally auto-assigned starting from 0.

To assign specific value, see the example here: http://stackoverflow.com/questions/8811815/is-it-possible-to-assign-numeric-value-to-an-enum-in-java

Git: Reverting Back Multiple Commits

Let's say you want to roll back the Git repository back to a specific commit e.g. by getting rid of the last 8 commits. This is how it's done:
git revert HEAD~8..HEAD

Wednesday, February 11, 2015

Wordpress Pagination Multiple Loops

Wordpress pagination can be tricky when you have multiple loops. The trick is obtaining the "paged" variable "get_query_var('paged')" before the first loop starts.

Thursday, February 5, 2015

Cocos2D-X: Disable Keyboard Autocomplete for Android

As at Cocos2D-X 3.2, it is not possible to disable autocomplete in the keyboard and this can prove to be a critical issue e.g. when user is keying in password.

A simple solution (which will disable autocomplete throughout the app) is to edit the "org.cocos2dx.lib.Cocos2dxActivity" file in the Cocos2D-X Android Java library. In the "init()" method, add the following line:

edittext.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_PASSWORD);

According to this article, some devices may require different flags: http://stackoverflow.com/questions/6281514/android-programmatically-disable-autocomplete-autosuggest-for-edittext-in-emulat

Tuesday, February 3, 2015

Common Causes of Wordpress "White Screen of Death"

Links:



To find out the error, enable debug, and the error will be shown in the white screen.

APC Performance

APC: Alternate PHP Cache

Here is a study about potential performance gains: http://www.webperformance.com/library/reports/SugarAPC/

Conclusion in this test was that it gave 180% performance improvement meaning 2.8 times original performance.

TypeError: $ is not a function when calling jQuery function

I got this error with one of the plugins in Wordpress. The solution was to edit the JS source file of the WP plugin, and replacing references of "$" with "jQuery".

More info: