vi is default advanced editor available in majority of the UNIX Operating System. It stands for visual Editor. It becomes very useful when you're using Terminal and want to access/edit file on UNIX system. Following are some of the useful vi commands which can be used for quick editing of file.
Most of the services like httpd, mysqld, crond, etc. are setup to start on boot when we install them. If we want to add new services to auto start on boot, we can use chkconfig utility. Below is example to auto start memcached service on boot.
Gzip compression allows reducing file size when transferring from server to user browser. We can enable Gzip compression by writing few lines of code in .htaccess file.
For enabling Gzip compression, we need Apache's mod_deflate module enabled. If it is not already enabled, you can enable using the steps provided here.
Taking regular backup of database is very important part of project development. Here's how we can take a backup of database using terminal.
Suppose we've file name (with extension) as part of string and while displaying to users we want to replace file extension from string.
Here's how we can do this:
Note: Make sure you're enabling this only on development server.
It's very common for any developers to make a mistake while developing, which will result in White Screen of Death (WSOD). WSOD is normally because PHP error reporting is turned Off.
Here's how you can enable error reporting using PHP.ini file:
When showing list of content (i.e. Posts, Custom Post Type) on Category Page, the main $WP_Query renders posts of default Posts type. To show content from different post type we've to alter the main $WP_Query.
There are few different ways using which we can alter the $WP_Query. But here is one of the way to alter $WP_Query without removing existing conditions in Query.
The current project I'm working on has a lot of customization of Drupal Commerce and display of views. One of the customization I've done is while displaying views result, show total of two views results in one view i.e. there are two views viewA and viewB shown on page, which shares the output and so we need to show the sum of total results in viewA and viewB will be displayed in viewA header.
Here's how I've achieved this with only few lines of code:
Today we're going to see how we can retrieve the payment method settings when ever we required. The payment methods are used to accept the payments from user during Checkout process. More details on payment in Drupal Commerce can be found here.