Wednesday, February 04, 2015

Try Ionic framework hybrid app on Mac


Ionic framework is a cross-platform HTML5 Javascript CSS framework for hybrid app.
It works with AngularJS and Cordova (PhoneGap).

Check the Ionic documents for details, you will find what it provides.
  • AngularJS: data binding, page routing...
  • AngularJS Extensions (the magic of UI components; View Controller pattern; Javascript Utilities )
  • Ionic Icons
  • CSS UI Components, which you can use Sass to customize.
  • HTML5 Input Type
  • CLI Command line tools - CLI FAQ
  • Demos and Examples - check the Kitchen Sink App with examples demonstrating most of Ionic's features.
  • App Template: iOS-like Tab View Controller template; Side menu template;
  • Community Forum where you can discuss the issues with Ionic.

Wednesday, October 15, 2014

iOS Set Navigation Bar Back Button Title

In summary, to set the back button title of the current ViewController, we create a backBarButtonItem for the previous ViewController.

Friday, October 10, 2014

Config Apache SVN server for Mavericks

I have a post about Config Apache SVN server for Mountain Lion

This time, after upgrade to 10.9 Mavericks, Apache fails again.

The and are missing.

$ apachectl -S
httpd: Syntax error on line 501 of /private/etc/apache2/httpd.conf: Syntax error on line 2 of /private/etc/apache2/other/svn.conf: Cannot load /usr/libexec/apache2/ into server: dlopen(/usr/libexec/apache2/, 10): image not found

Here's the fix

Download And Build Subversion

add symlink
ln -s /Applications/ /Applications/
cd subversion-1.6.23
sudo cp subversion/mod_dav_svn/.libs/ /usr/libexec/apache2/.
sudo cp subversion/mod_authz_svn/.libs/ /usr/libexec/apache2/.

Wednesday, July 30, 2014

iOS define local and global NSString constant

1. Local Constant

There are two type of constants.

(1)  static NSString * const kMyConstant = @"constant string";

(2)  #define kMyConstant @"constant string"

"static const" is a better way, although "#define" is much shorter,

Here are some reasons:

  • "#define" are not type-safe. 
  • We can test the value of the "static const" constant with debugger;
  • Memory. Preprocessor create a new string each time the macro appear, while "static const" reuse the same string.

2. Global Constant

----------------  .h file  --------------

extern NSString *const kMyConstant;

----------------  .m file  --------------
// define in a .m file OUTSIDE @implementation like...

NSString *const kMyConstant = @"my constant";

The extern declaration says that there exists an NSString * const by the name kMyConstant whose storage is created in some other place.[1]

Remove the static -- that specifies that kMyConstant is only visible in files linked with this one.[1]

C pointer and constant

Review C pointer and constant:

1. Pointer to Constant Value

const char *ptr = 'a';  OR    char const *ptr = 'a'

"const" precedes the *, that means the pointer treat *ptr  as constant

This is NOT valid     :  
*ptr = 'b';

Another example;

int nValue = 5;
const int *pnPtr = &nValue;

Thus, the following is okay:
    nValue = 6; // nValue is non-const
But the following is not:
    *pnPtr = 6; // pnPtr treats its value as const

2. Constant Pointer

char * const ptr = 'a';

This means the pointer ptr is a constant pointer

This is NOT valid:
char char_B = 'b';
ptr = &char_B;

3. Constant Pointer to Constant Value

const char * const ptr = 'a';  OR    char const * const ptr = 'a';


Sunday, July 20, 2014

Android - SuppressLint cannot be resolved to a type

After upgrading my Android SDK 20 and ADT-23.0.2, some projects got error "SuppressLint cannot be resolved to a type"

I fixed this by

1. In project property -> Android, change to another API level and change back.
2. change the order in project property ->Java build path -> Order and Export.
3. also please try refresh and clean the project.

Hope it can help and save some hours.

Tuesday, July 08, 2014

OpenDrive cloud storage direct link

I am trying OpenDrive storage service.
You will get 5G storage, and 1G traffic for a basic account.
It is great that you can share file by direct link.
I think it is very useful for a developer.
We can put XML, JSON, image files on the OpenDrive for testing.

Go to their website and have a look:

Wednesday, January 22, 2014

Setup DNSmasq MAC DNS server

$ brew install dnsmasq

$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Go to System Network preference,
Set the only one DNS as


#upstream dns servers

#for the host domain to the ip, like the "hosts" file

# set listen address as your IP


Put upstream server in /etc/resolv.dnsmasq.conf , such as
nameserver upstream_dns_server

Kill the process, it will restart and reload new config.

$ sudo kill $(ps aux | grep '[d]nsmasq' | awk '{print $2}')


Install DNSmasq locally on Mac OS X via Homebrew

Setup a wildcard TLD using Dnsmasq on OS X


 ps aux  : to see every process on the system using bSD syntax;

$ ps aux 
timothy  29217  0.0  0.0 11916 4560 pts/21   S+   08:15   0:00 pine 
root     29505  0.0  0.0 38196 2728 ?        Ss   Mar07   0:00 sshd: can [priv]  
can      29529  0.0  0.0 38332 1904 ?        S    Mar07   0:00 sshd: can@notty 
USER = user owning the process
PID = process ID of the process
%CPU = It is the CPU time used divided by the time the process has been running.
%MEM = ratio of the process’s resident set size to the physical memory on the machine
VSZ = virtual memory usage of entire process
RSS = resident set size, the non-swapped physical memory that a task has used
TTY = controlling tty (terminal)
STAT = multi-character process state
START = starting time or date of the process
TIME = cumulative CPU time
COMMAND = command with all its arguments
ps -aux VS ps aux

Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist, this ps may interpret the command as "ps aux" instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon.

Thursday, October 17, 2013

Fix Android cannot show Logcat, "Invalid Argument"

Fix problem: Android cannot show Logcat, "Invalid Argument"
  • Unplug and plug your device
  • Switch ON/OFF the developer option – USB debugging
  • Clicking at the device on DDMS-Device tab
  • Use command "adb logcat -c" followed by unplug/plug device.
  • On DDMS-Device tab, click the down triangle, choose “Reset adb”
  • Huawei device: *#*#2846579#*#*  Go ProjectMenu / Background Setting / Log setting
  • Use app to show logcat, such as CatLog (
  • Run “echo 1 > /sys/kernel/logger/log_main/enable” in “adb shell”
Reference :