Redirect va htaccess non-www to www and keep http and https protocols

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|offs()
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]

Mysql number of tables in DB

SELECT COUNT(*) FROM information_schema.TABLES WHERE table_schema = 'databasename';

Mysql create utf-8 database

Former practice:

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

Current practice:

CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Postfix localhost IP address only bind configuration

Open /etc/postfix/main.cf file:

bash# vi /etc/postfix/main.cf

Append / modify line as follows to bind to localhost (127.0.0.1) only:

inet_interfaces = 127.0.0.1

Type the following to restart Postfix:

bash# /etc/init.d/postfix restart

function memory_get_usage

 
<?php
 
function memoryChecker($variable) {
echo 'in function: '.memory_get_usage()."\n";
}
 
echo 'before function: '.memory_get_usage()."\n";
 
$var = "hello world\n";
 
memoryChecker($var);

Re-indent with PhpStorm

PhpStorm->Code->Reformat Code
or
Ctrl+Shift+Alt+L and click Reformat file

Git checkout single file

Checkout from other branch

git checkout develop /path/to/file.php

Checkout from HEAD

git checkout HEAD -- /path/to/file.php

Double ??

Before PHP 7:

if (isset($inputData)) {
    $param = $inputData;
} else {
    $param = 'default'; 
}

In PHP 7:

$param = $inputData ?? 'default';

or

$param = $inputData ?? $someData ?? 'default';

Css list with curly brackets

ol {
  counter-reset: list;
}
ol > li {
  list-style: none;
}
ol > li:before {
  content: counter(list) ") ";
  counter-increment: list;
}

Output:
1) Number1
2) Number2
3) Number3

Hard reset of local branch to match remote

git reset --hard origin/develop