deb

Published: Sep 26, 2017

MySQL

SELECT @@GLOBAL.sql_mode;

BASH

alias ll='ls -lah'
alias ss='sudo service apache2 restart'

GIT

echo "Host bitbucket.org
 IdentitiesOnly yes
 StrictHostKeyChecking no
 IdentityFile ${USER_HOME}${PRIVATE_KEY}" | sudo tee $USER_HOME.ssh/config > /dev/null
create a branch in your git repository, commit the patch to this branch, and create a PR with our main git repo at https://github.com/civicrm/civicrm-core

SYSADMIN

Debian Stretch

https://packages.sury.org/php/

PHP 5.6 on Xenial

sudo apt-get update
sudo apt-get install -y vim git curl

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

sudo apt-get install apache2
sudo apache2 -t

sudo apt-get install -y mysql-server
mysql_secure_installation

sudo apt-get install -y php5.6 libapache2-mod-php5.6 php5.6-mcrypt php5.6-mysql 

sudo apt-get install -y php5.6-curl php5.6-bcmath php5.6-gd php5.6-imap php5.6-json php5.6-xmlrpc php5.6-xsl php5.6-mbstring php5.6-soap php5.6-xml php5.6-zip php5.6-intl php-imagick php-gettext php-xdebug

sudo service apache2 restart

php -v

# disable opcache for php and php-cli
sudo vim /etc/php/5.6/apache2/php.ini

# set ServerName
sudo vim /etc/apache2/apache2.conf

sudo a2enmod rewrite
sudo service apache2 restart

# verify apache mods
apachectl -M | sort

sudo chown -R carlos:www-data /var/www/html

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash
sudo apt-get install -y nodejs
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
apt-cache search php dom
sudo apt-get install php5.6-*
will install everything related to php5.6
// upload local .sql into production
/Applications/MAMP/Library/bin/mysql -udnuser -p -h 111.11.111.111 dbname < dbfile.sql
\
  Order allow,deny
  Deny from all
\
:%s/\r//g only works when:

set ff=unix, which when done, automatically converts all CRLF to LF
set ff=dos and CR is a rogue char that is not preceded by LF, e.g., inserted with C-V C-M.

CR in LF CR pairs will not be found.
Therefore, if all you want is to convert every LF CR to LF, you should use:

:set ff=unix
:w
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

CIVICRM

https://github.com/civicrm/civicrm-buildkit-vagrant/blob/master/provision/provision.sh
civibuild create my-47 \
--type wp-demo \
--civi-ver master \
--cms-ver 4.7.5 \
--url http://my-47.localhost \
--admin-pass admin
4111111111111111

WORDPRESS

utf8mb4_unicode_520_ci to utf8mb4_unicode_ci
/**
 * Disable Posts' meta from being preloaded
 * This fixes memory problems
 */
function nlf_pre_get_posts( WP_Query $wp_query ) {
	if ( in_array( $wp_query->get( 'post_type' ), array( 'my_post_type_1', 'my_post_type_2' ) ) ) {
		$wp_query->set( 'update_post_meta_cache', false );
	}
}

// Only do this for admin
if ( is_admin() ) {
	add_action( 'pre_get_posts', 'nlf_pre_get_posts' );
}
error_log("Memory Usage: " . (memory_get_usage()));
add_action( 'plugins_loaded', 'checking_memory_cl' );
function checking_memory_cl() {
    error_log("Memory Usage at plugins_loaded: " . (memory_get_usage()));
}

add_action( 'after_setup_theme', 'checking_memory_cl2' );
function checking_memory_cl2() {
    error_log("Memory Usage after setup theme: " . (memory_get_usage()));
}

add_action( 'wp_loaded', 'checking_memory_cl3' );
function checking_memory_cl3() {
    error_log("Memory Usage after wp_loaded: " . (memory_get_usage()));
}
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://newsite.com');
Last modified: November 18, 2017 5:41 pm
Posted in: Snippets