Screen Shot 2014-12-16 at 8.19.52 AM

Install remote desktop on ubuntu server vps

Sometimes it would be nice if we can setup a remote desktop on vps. We can use it to hide our presence or to work with big files which we need to download or upload. Or perhaps install virtualbox there to run windows softwares and then running internet marketing apps .. you will need kvm or xen vps for this purpose.

Open terminal and login using ssh, then run the following commands:

apt-get update
apt-get upgrade
apt-get install xorg lxde-core tightvncserver
tightvncserver :1
tightvncserver -kill :1
vi ~/.vnc/xstartup

When inside vi, add the following 2 lines in the end of file:

lxterminal &
/usr/bin/lxsession -s LXDE &

Save the file and exit to terminal again.
Then run

vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565

Now the server part is ready. You need to download vnc client, then pointing the remote access to:

IPAddress:1

Don’t forget to add :1 after the ip address.

As an optional step, you can install firefox and leafpad editor:

apt-get install firefox
apt-get install leafpad

… okay then, happy spamming :)
..oops sorry, happy coding :)

Screen Shot 2014-12-01 at 10.05.16 PM

Running phalcon php on cpanel for production and setup on MAMP for development

Enable Phalcon on cPanel

Today I just realized that cpanel already support phalcon php framework. It may not enabled by default, but you can enable it yourself via cpanel menu.

Screen Shot 2014-12-01 at 10.08.05 PM

Login into your cpanel account. Then click on Select PHP Version.

Screen Shot 2014-12-01 at 10.08.31 PM

There 2 things you need to do in this screen. First, you need to select which PHP Version, let say PHP 5.5. Then you need to enable phalcon by ticking it from available php extensions. Then save it.

Now time to test it, create a new php file which calling phpinfo(). You should get something like this.

Screen Shot 2014-12-01 at 10.19.19 PM

Setup Phalcon on MAMP

Next we need to setup development environment. In the past I prefer using vagrant, but now I need to keep cpu and memory usage low. So I use MAMP.

Screen Shot 2014-12-01 at 10.23.51 PM

We do not need to compile the phalcon extension, because we can grab one from this github repository. By following the documentation, we need to copy phalcon.so to /Applications/MAMP/bin/php/php5.5.x/lib/php/extensions/no-debug-non-zts-20121212. The next step is update the php.ini to load phalcon.so. Edit php.ini then add this line:

extension=phalcon.so

Restart Apache, if everything is ok, you should get something like:

Screen Shot 2014-12-01 at 10.06.14 PM

appstorebadge

Apple App Store Optimization

There are a lot of mobile users today. Many people have their own mobile devices that come with many great applications. Apple is one of the most popular mobile device manufacturers in the world. You can find more than 2 million mobile apps that are specially created for Apple’s iOS system. These apps are specially created to help all users get maximum benefits from their Apple’s devices, such as iPad, iPhone, iPod, and some other devices. Many app developers want to learn about the Apple app store optimization. If you are an app developer for Apple’s devices, you should keep reading this article.

What is Apple App Store Optimization (ASO)?

ASO is the procedure for optimizing any mobile apps, so they can rank higher in the app store’s search result. When your application can rank high in the search result, you can attract more visitors to your mobile app. It means that you can increase the visibility of your own app. It can allow you to increase the traffic to your application significantly. Before you sell your application, you should understand the algorithm of the App Store’. There are some important things that you need to know about this system.

Why is ASO Technique Important?

Many experts believe that most apps can be discovered through the App Store searches. Therefore, you can improve your app performance when this app can reach the first page of the search result. This technique can be used to boost the ranking of your application on the App Store’s search result. It is recommended for all app developers to learn about this optimization technique. When you are able to optimize your app on the App Store, you should be able to impact your app’s ranking significantly. You can increase the visibility of your app when you are able to follow this technique properly.

Some Factors That Can Increase Your ASO Method

1. Title

It is one of the most important factors in boosting your app’s ranking. The title should contain the targeted keyword. You need to spend some time for doing research, so you can find the best keywords for your application. You can also choose a good title for your app. Optimizing your title is very important for you, especially if you want to develop a good application for the iOS system. When your customers are happy with your app, they are going to share your app with their friends or families. The title of your app plays an important role in this stage.

2. Keywords

It is another important thing that you should consider when you are doing the Apple ASO campaign. You need to know some relevant keywords that are related with the primary keywords. Choosing the right keywords is very useful to help you reach your target audience easily. You can also monitor your competitors easily when you target some specific keywords for promoting your app. Don’t forget to include some keywords in the description, so your users can learn about your app easily.

3. Number of Downloads

Some experts believe that this is another important thing for most app developers. This factor can also determine the app’s ranking on the Apple App Store’s search results. The number of downloads becomes very important for the Apple App Store Optimization campaign. Popular apps tend to rank higher on the Apple’s search results than the other normal apps. You cannot control the total downloads for your app. However, you can still optimize your application for improving the benefits of this application. When people are happy with your app, they are going to keep downloading your mobile app.

4. Ratings and Reviews

If you want to rank your app on the App Store’s search results, you should consider these two factors. All apps in the App Store are valued by using the ratings and reviews. These testimonials usually come from other users who are using similar apps. Apps with good reviews tend to rank higher on the search results. It means that you should use some creative ways for promoting your application to your friends or relatives. Positive reviews are very useful to help you boost the ranking of your application. Make sure that all happy customers leave some positive testimonials or ratings for your application.

There are a lot of benefits that you can get from the proper App Store optimization (ASO) campaign. If you want to be a successful app developer, you should know about this method. It is recommended that you promote your app on the App Store’s search results by using this simple method. Many people are interested with this technique because they want to get all benefits from this campaign. You can optimize the sales performance of your app easily when you are following some of those ASO techniques. You can start using proper ASO method for promoting your app to your potential customers easily.

Postfix-logo

Configure postfix to use mandrill for sending email

Postfix-logo

In this configuration relay all email sending mandrill. So that we do not need to configure all applications one by one to use mandrill. It will affect all applications in the server.

1. Create /etc/postfix/sasl_passwd

[smtp.mandrillapp.com]:587 USERNAME:API_KEY

2. Edit /etc/postfix/main.cf, add the following code

smtp_sasl_security_options = noanonymous

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
relayhost = [smtp.mandrillapp.com]:587

3. run in shell:

postmap hash:/etc/postfix/sasl_passwd

4. restart postfix

service postfix restart

Now try to send an email, then monitor the log in mandrill dashboard.

Securing JSON-API wordpress plugin

wordpress-logo

JSON-API is very useful wordpress plugin. I often use it to retrieve wordpress data to mobile app. It can handle custom fields, custom post types, taxonomy, etc. It also has custom controllers that we can use to extent the functionality.

Unfortunately this plugin has no access control. So once you install this plugin, everyone can access the data as well. I made a little update to limit the access. Basically I added a secret key or a password, but I will use term api key. Only someone with correct api key can access the data.

So how to do this.

Edit json-api.php file, line 26, add the following code.

  /* ########### QUICK MOD: ADDING API KEY ########### */
  $json_api_key = "b34b40ca8771c48c204e55f927376885";
  /* ########### QUICK MOD: ADDING API KEY ########### */
  if ($_GET['json']) {
    if ($_GET['wpapikey'] != $json_api_key) {
      print "[error:99] Permission denied!";
      exit;
    }
  }
  /* ########### QUICK MOD: ADDING API KEY ########### */

Change b34b40ca8771c48c204e55f927376885 to anything as you like as the api key. For the complete diff, see this commit in github:
https://github.com/dodyrw/wp-json-api-key/commit/d29459421ceec73e9b639d4e2ffbeb04931df576

Now every JSON-API request will require api key. Otherwise it will return permission denied error message. For example:

http://www.dodyweb.com/?json=get_recent_posts&dev=1&wpapikey=b34b40ca8771c48c204e55f927376885

SSL Pinning with AFNetworking 2

Screen Shot 2013-12-23 at 8.14.56 AM

If we use web services in our app, we need to secure the connection from data sniffing. Normally we can use SSL connection every time we call web services. It will prevent someone from sniffing the data traffic.

However it is not enough. We also need to prevent from “Man in the middle attack“. Someone else can disguise as the web service provider. Instead of connecting to genuine web service server, the app will connect to someone else server. And we know that it will lead to a serious problem!

So how do we prevent from “Man in the middle attack”.

First, the web service provider must have SSL certificate. They will supply us with .crt file. Or if you own the web service, buy a SSL certificate for your domain. Then we need to tell our app that it should always connect to server with valid SSL certificate.

Before we begin to code, we need to convert .crt file to .cer file and add this file in xcode project. Open terminal and run the following command.

openssl x509 -in www.mydomain.com.crt -out www.mydomain.com.cer -outform der

If you use NSURLConnection, you need to check certificate in - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge. You need to add NSURLConnectionDelegate protocol.

Using AFNetworking 2.0, it will be easier. We need to create AFSecurityPolicy and set AFHTTPRequestOperationManager to use it.

Since I use it multiple times, I create a method for this purpose.

- (AFSecurityPolicy*) dodyrwSecurityPolicy
{
    /**** SSL Pinning ****/
    NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"www.dodyrw.com" ofType:@"cer"];
    NSData *certData = [NSData dataWithContentsOfFile:cerPath];
    AFSecurityPolicy *securityPolicy = [[AFSecurityPolicy alloc] init];
    [securityPolicy setAllowInvalidCertificates:NO];
    [securityPolicy setPinnedCertificates:@[certData]];
    [securityPolicy setSSLPinningMode:AFSSLPinningModeCertificate];
    /**** SSL Pinning ****/

    return securityPolicy;
}

Then set it in manager.

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    /**** SSL Pinning ****/
    [manager setSecurityPolicy:[self dodyrwSecurityPolicy]];
    /**** SSL Pinning ****/
    
    [manager GET:WEBSITE_URL parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary* responseObject) {
        //..... beautiful code here
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        //..... beautiful code here
    }];

Installing phpredis (pecl) on ubuntu

Screen Shot 2013-06-18 at 12.33.11 PM

In order to install phpredis, we will need to have make and pecl installed.

apt-get install php-pear
apt-get install make
pecl install redis

Then we need to put extension=redis.so in php.ini file. In my case it php ini file is located at /etc/php5/fpm/php.ini.

vim /etc/php5/fpm/php.ini

To activate it, we need to restart apache or php5-fpm.

service php5-fpm restart