CasperJS test lazyload

As you know,  CasperJS/PhantomJS is perfect for automation test in client-side. And nowaday, you usually develop lazyload function that means when you pull the scroll of window or element (div html tag) to the bottom of page, the page will automatically load more data and bind it to the view (table or grid). Along with it, we need write unit test function to cover fully user experiences.

CasperJS test lazyload

Life is what we make it, always has been, always will be

With PhantomJS/CasperJS, It is quite easy, just take a look to the source code below. You just need 2 main functions of CasperJS is scrollToBottom and waitFor to implement it.

 

Add user to group Ubuntu

This article to show you some commands that are usually used to moderate user and group in Ubuntu.

Create new user with home directory:

Remove user with related files:

Show groups of user:

Or

And supplementary group to user:

Change user default groups:

 

htaccess htpasswd Ubuntu

In this example, I assume that you want to all user have to input username/password when access http://localhost/test. And web root directory is /var/www/test.

Make sure that your web server was enable mod_rewrite. And your virtual host allow override all:

To use htpasswd command , you need install apache2-utils:

To implement it, firstly, you create .htpassword file by command:

And then, create .htaccess file:

With content:

Please make note that you have to use absolute path for .htpasswd file.

Done, try a test: http://localhost/test

Change MYSQL data directory

Sometimes you need change mysql data directory for the reason expand hard disk driver or rearrange your directory structure. This tutorial will show you the way to change it in Ubuntu.

For example, change mysql data directory from /var/lib/mysql to /var/data/mysql

Looking for:

Change to :

And open file:

Looking for:

Change to:

Reload AppArmor profile:

Finally, restart MYSQL:

It’s done.

Add new hard disk in ubuntu

You are using linux on virtual machine (e.g VMWARE) or real PC. I will show you the way how to add new hard disk in ubuntu

Check new device:

/dev/sdb is new hard disk that you needed. In case, you do not see new devive, it means that the OS system does know about new device. So you should reboot your system, If still not, you need install driver software for new device (read device specification and download drivers from device provider)

Be so busy improving yourself that you have no time to criticize others

Be so busy improving yourself that you have no time to criticize others

Start with command:

Follow the guide to add a new partition

And build Linux file sytem in new hard disk (I chose ext4)

And try to mount new hard disk to directory

Test with df command

Finally, add the mount to fstab to automatically mount disk when system start.

Add line:

To apply the new change of fstab file. We use command:

In case the automation fails, you can troubleshoot with command:

A error case:

 

Install Memcached, PHP Memcache and PHP Memcached in Ubuntu 14.04

As you know, Memcached is great cache system for your web application. Use correctly Memcached will speed up your application so much. So now is how to install memcached, PHP Memcache and PHP Memcached

Install Memcached, PHP Memcache and PHP Memcached in Ubuntu 14.04

In Ubuntu 14.04, the installation is very simple, just need one command:

Please remember restart apache2:

Finally, test your works by writing some PHP scripts.

Add php script to test.php:

Successful result:

 

 

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

In my previous project, I used PhantomJS/CasperJS for automation test. It is really amazing for all front-end guys who need write unit test for verify user experiences (e.g: submit form, change link …). The below is steps to install PhantomJS and CasperJS in Ubuntu 14.04.

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

Get nodeJS from personal Repository to get the latest version.

Install NPM, NodeJS:

Now, check with command:

You can install CasperJS via NPM command:

Install PhantomJS  (Download source, extract files, create soft-link to executable directory):

Check your installation with command:

 

Send email with Postfix in Ubuntu

As you know, to install a email server, you should install both Postfix and Dovecot, in this case it is quite complicated.  In case you just need run sendmail function of Postfix, you should install PostFfix and config to relay to a SMTP server that you have.  So in this article, I will show you steps to install and config it.

The scenario of this example as below:

You have a smtp server with configuration information as below

Firstly, install Postfix:

Open /etc/postfix/main.cf change some parameters as below:

And create /etc/postfix/sasl_passwd file and add content below

Type below comand to create sasl_passwd.db:

Restart Postfix:

Finally, test send email (make sure that you installed mail client):

You are done.

In case having errors, you can check log with command:

And now,  you can write a php script, use Swiftmailer library to test send email via transport sendmail