git new branch

git checkout -b new_branch_name

git remove remote branch

git push origin --delete feature/login
git push origin :feature/login

Run command on Ubuntu startup as superuser

vi /etc/rc.local

Flush Redis cache

redis-cli flushall

Joomla check if admin logged-in

<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..' ));
 
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
 
$mainframe =& JFactory::getApplication('administrator');
$mainframe->initialise();
 
$app =& JFactory::getApplication();
$user =& JFactory::getUser();
 
if($app->isAdmin() && !$user->id) {
header('Location: /administrator');
exit();
}
?>

Dig to query specific dns server

dig mydomain.com @ns.myserver.com

Updating custom db table in WordPress

function my_function() {
global $wpdb;
$wpdb->update('wp_my_appointments', array(
                            'title' => 'Msc',
                            'msg' => 'Message'
                            ),array(id => 3));
}

Inserting in custom db table in WordPress

function my_function() {
global $wpdb;
$wpdb->insert('wp_my_appointments', array(
                            'title' => 'Mr',
                            'msg' => 'Message'
                            ),array(
                            '%s',
                            '%s'));
}

Selecting from db custom table in WordPress

function my_function() {
global $wpdb;
$appointments = $wpdb->get_results("SELECT * FROM wp_my_appointments;");
echo '<pre>';
print_r($appointments);
}

Sending email in WordPress

$to = 'your@emailaddress.com';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
 
wp_mail( $to, $subject, $body, $headers );