All posts by Carlos

Javascript engine

So in web news, the go language is being used to parse php. What’s this mean?

A. The nebulous entity in the quest to impose javascript to web developers can not only infiltrate the PHP/apache team. With that said, it makes sense to make a separate engine to parse PHP.
B. With go language being the parser, PHP is at the hands of major js promoters (ie google).
C. The js promoters have a history of nosy and stalkish behavior on the web (via share buttons, analytics and the privacy-free android operating system).
D. The server that is voluntarily infiltrated with js is no longer private.
E. PHP projects are no longer private.

The bottom line has been to make javascript the back-end and front end language of choice.

A second post will spotlight how php programmers are influenced by ‘public polls’ of ‘desired PHP features’ and answers mostly being what ‘js already has built in’.

Which CMS

Personal notes of notable CMS and caveats

WordPress – FIND ALTERNATIVE ASAP – bloated html and *loads* of unnecessary javascript everywhere

Bolt – DO NOT USE – uses bootstrap css, the create new user page alone does 150db queries in 800ms!

getGrav – OKAY – flat file, all managed from cmd line

OctoberCMS – DO NOT USE – based on laravel

Meddling with web traffic in an HTTPS world

HTTPS ensures integrity of data across computers. Great. We know “Russia” didnt change information that was in transmission from a journalist article to the consumer.

BUT, let’s say an entity doesn’t want The People to read an activist article. To interfere with the article’s contents reaching the minds of the The People, simply put too many “redirects” on the single article and that way, information dissemination is meddled with.

I created this idea while trying to access

The Community Rights Movement to New Hampshire: Let the People Decide What’s Best
New Hampshire activists plan to rewrite state law through a popular referendum.
BY JOHN COLLINS

https://archive.is/u42ZC

deb

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
\<Files "*"\>
  Order allow,deny
  Deny from all
\</Files\>
:%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');

Apple

If you’ll be using the disk on a Windows computer, choose the Master Boot Record partition scheme (also known as “fdisk”).

If you’ll be using the disk only with Mac computers, choose GUID Partition Table.

Deployment

Put your rsync command in a shell script so you sync to a release directory and the swap to symlink from www->release1 to www->release2. The script will only take 5min to write and test, but it means you have no downtime and nothing breaks if rsync cuts out halfway through.

Notification Center in Dashboard

Just a thought. With many people voting for Apple to get rid of the dashboard, that would be throwing away a good item. It’s also useful to many people (the ones voting for it to stay). The dashboard is in no one’s way, so I dont see why it would be voted out of OS X.

So instead of duplicating the widget functionality from Dashboard to Notification Center, maybe ideally the notification button in the upper right of the screen can be a click to display the dashboard. The widgets introduced in the Notification Center would have been more useful in the dashboard (just to keep the nay-sayers unhappy lol).

CiviCRM HelloTest.php

Totten does phpunit4 HelloTest.php at https://www.youtube.com/watch?v=uN6CQKwZiVQ but my result was (on both 4.6.4 and 4.7.23):

1) HelloTest::testGet
session_start(): Cannot send session cookie - headers already sent by (output started at phar:///home/vagrant/buildkit/bin/phpunit4/phpunit/Util/Printer.php:134)

Please make sure "session.auto_start": "1" in php.ini and verify with cv api system.get

Multiple SSH keys for a single server

Attempting to git clone:

Cloning into 'vagrant_vm'...
repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[Aim: create new key pair to access work bitbucket account]

Working from home, here’s how I went about setting up the environment on my personal Mac:
1. Created SSH key pair (bitbucket_work.pub, bitbucket_work)
2. Logged into my work bitbucket account and added the public key
3. Added the private key to the ssh agent (OS X)
4. Attempted to git clone and failed.

Turns out the git clone command would try using the private key associated with my personal bitbucket account. Tried vim ~/.ssh/config and added the lines but nothing.

Running ssh-add -l shows the agent’s loaded strings and there it was: the git clone using my personal key.

Carloss-iMac:Sites carlos$ ssh-add -l
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/strasmore_byl (RSA)
2048 SHA256:xxxxxxxxxxxxxx /home/vagrant/.ssh/bitbucket_personal (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/2017FEB09_lithium_backyardlogs (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/lithium_lucs_17246 (RSA)
2048 SHA256:xxxxxxxxxxxxxx /Users/carlos/.ssh/bitbucket_work (RSA)

Ran ssh-add -D to clean out all keys.

Carloss-iMac:Sites carlos$ ssh-add -D
All identities removed.

Added the new private key to the agent (bitbucket_work) and ta-dah. Git clone works.

cv and civix blank output

CiviCRM 4.6.4, Vagrant


Running cv vars:show outputs nothing
including adding -vvv
and civix civicrm:ping -vvv output is

[Bootstrap] Options: {
    "dynamicSettingsFile": "phar:///usr/local/bin/civix/vendor/civicrm/cv/settings_location.php",
    "env": "CIVICRM_SETTINGS",
    "prefetch": false,
    "settingsFile": null,
    "search": true,
    "cmsType": null,
    "httpHost": "",
    "output": {

    }
}
[Bootstrap] Find settings file
[Bootstrap] Load supplemental configuration for "/vagrant/mysite/wp-content/plugins/civicrm/civicrm.settings.php"
[Bootstrap] Load settings file "/vagrant/mysite/wp-content/plugins/civicrm/civicrm.settings.php"

Turns out that if my civicrm.settings.php has variables, wont work!

Example:

$wordpress_root = '/vagrant/mysite/';
$website_address = 'http://www.my.site/';

define( 'CIVICRM_UF_BASEURL'      , $website_address );

global $civicrm_setting;

// Temporary Files (System Settings > Directories)
$civicrm_setting['Directory Preferences']['uploadDir'] = $wordpress_root . 'wp-content/plugins/files/civicrm/upload' ;

// Images (System Settings > Directories)
$civicrm_setting['Directory Preferences']['imageUploadDir'] = $wordpress_root . 'wp-content/plugins/files/civicrm/persist/contribute' ;