Bootstrap make all columns of same height in a row — August 17, 2017
WordPress Use Environment Variables for diff domains like local, staging or production — August 15, 2017

WordPress Use Environment Variables for diff domains like local, staging or production

I always use this. Put this in wp-config.php

//GET HOSTNAME INFO
$hostname = $_SERVER['SERVER_NAME']; 

//VERIFY WHICH ENVIRONMENT THE APP IS RUNNING
switch ($hostname) {
    case 'site.dev':
        define('WP_ENV', 'local');
        break;
    case 'staging.site.com':
        define('WP_ENV', 'staging');
        break;
    case 'site.com':
        define('WP_ENV', 'production');
        break;
    default:
        define('WP_ENV', 'local');
}
WordPress filter for all images which appear in a page —
Ubuntu add proxy with username, password and port — July 26, 2017

Ubuntu add proxy with username, password and port

I have tested this with Ubuntu 14.04
First go to system settings > Network > Network Proxy
and fill ‘Proxy’ and ‘Port’
Then click on ‘Apply system wide’

Now open apt.conf file

gksudo gedit /etc/apt/apt.conf

and add this

Acquire::http::proxy "http://username:password@proxy_ip:port/";
Acquire::https::proxy "https://username:password@proxy_ip:port/";
Acquire::ftp::proxy "ftp://username:password@proxy_ip:port/";
Acquire::socks::proxy "socks://username:password@proxy_ip:port/";

Take care of every semi-colon and slash. Save this,

Now open this ‘environment’ file. For this file you may need sudo password

nano /etc/environment

and add this

http_proxy="http://username:password@proxy_ip:port/"
https_proxy="https://username:password@proxy_ip:port/"
ftp_proxy="ftp://username:password@proxy_ip:port/"
socks_proxy="socks://username:password@proxy_ip:port/"

save file and then logout user to check settings. Use this command

set | grep -i proxy

and check if you see any variables now. If yes then you have successfully enabled proxy.
Now open firefox and check if it asks for password on startup. Then enter proxy username and password and Boom :).

WordPress get posts where date is greater than particular date —

WordPress get posts where date is greater than particular date

We need to use wordpress date_query for this query. Example:-

$the_query = new WP_Query(array(
	'post_type' => 'estate_property',
	'post_status' => 'publish',
	'posts_per_page' => 10,
	'order' => 'ASC',
	'date_query' => array(
	    array(
	        // 'after'     => 'June 22nd, 2017',
	        // 'before'    => 'December 31st, 2015',
	        'after'    => array(
				'year'  => 2017,
				'month' => 6,
				'day'   => 21,
			),
			'inclusive' => true,
	        
	    ),

	),
));

You can check wordpress documentation for better understanding.

Ubuntu wget scrap a website — July 23, 2017

Ubuntu wget scrap a website

$ wget \
     --recursive \
     --no-clobber \
     --page-requisites \
     --html-extension \
     --convert-links \
     --restrict-file-names=windows \
     --domains website.org \
     --no-parent \
         www.website.org/tutorials/html/

This command downloads the Web site www.website.org/tutorials/html/.

The options are:

  • –recursive: download the entire Web site.
  • –domains website.org: don’t follow links outside website.org.
  • –no-parent: don’t follow links outside the directory tutorials/html/.
  • –page-requisites: get all the elements that compose the page (images, CSS and so on).
  • –html-extension: save files with the .html extension.
  • –convert-links: convert links so that they work locally, off-line.
  • –restrict-file-names=windows: modify filenames so that they will work in Windows as well.
  • –no-clobber: don’t overwrite any existing files (used in case the download is interrupted and
    resumed).

You can read of original resource.

Ubuntu install missing packages — July 18, 2017