Change Last Modified and Creation Dates on Linux or Mac OS X

Use terminal or console to get to the files you want to modify.
Then use touch command like this

touch -a -m -t YYYYMMDDHHMMSS *.pdf

To update timestamp of all pdf files in folder. Real life example, if you want to change last modified and create date to 1st of September 15:16:17 ( hours minutes seconds respectively ) for file todo.txt

touch -a -m -t 20170901151617 todo.txt

Youtube iframe and Analytics tracking

If you need to use iframe to display youtube video on your website, tracking starts and pauses via analytics can be easily done.
The main trick is to add enablejsapi=1 into url.

E.g.
<iframe width=”560″ id=”somevideo” height=”315″ src=”https://www.youtube.com/embed/aCpGA7OrwyI?autoplay=1&enablejsapi=1″></iframe></pre>

becomes

<iframe width=”560″ id=”somevideo” height=”315″ src=”https://www.youtube.com/embed/aCpGA7OrwyI?autoplay=1&enablejsapi=1“></iframe></pre>

Now you can easily use the API. Feel free to use following example


<iframe width="560" id="somevideo" height="315" src="https://www.youtube.com/embed/aCpGA7OrwyI?autoplay=1&enablejsapi=1"></iframe></pre>

<script>
var player;
function onYouTubeIframeAPIReady() {
    player = new YT.Player( 'somevideo', {
        events: { 'onStateChange': function(state){
            if(state.data){
                if(state.data == YT.PlayerState.PAUSED){
                    // paused
                    ga('send', 'event', 'somevideo', 'paused', creativecoffeebreak.getCurrentTime());
                } else if(state.data == YT.PlayerState.PLAYING){
                    if(!playedAlready){
                        playedAlready = true;
                        ga('send', 'event', 'somevideo', 'start', creativecoffeebreak.getCurrentTime());
                    }
                } else if(state.data == YT.PlayerState.ENDED){
                    ga('send', 'event', 'somevideo', 'finished', creativecoffeebreak.getCurrentTime());
                }
            }
        } }
    });
}

</script>
<script src="https://www.youtube.com/iframe_api"></script>

Please note that the YT.PlayerState.ENDED doesn’t work in almost any browser.
Also, the “PAUSED” event is triggered when fast forwarding as well.

You need to load iframe_api javascript, otherwise the YT object won’t exist.

Laravel 5 installation error – Parse error: syntax error, unexpected ‘class’ (T_CLASS)

If you get

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in I:\PP\public\index.php on line 50

error while installing Laravel 5, you are probably running on old PHP version – make sure to upgrade to 5.6.* and higher.

Crafting application...

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T
_STRING) or variable (T_VARIABLE) or '{' or '$' in I:\PP\artisan on line 31
Script php artisan clear-compiled handling the post-install-cmd event returned w
ith an error

[RuntimeException]
Error Output:

run-script [--dev] [--no-dev] [-l|--list] [script] [args1] ... [argsN]

Application ready! Build something amazing.

Solution
Update to newer version of PHP.

Braintree Paypal – Please try a different payment method

If you got any of these errors
Oops, something went wrong. Please try a different payment method.
Error: This PayPal integration does not support this currency
Hups, něco se pokazilo. Zkuste prosím jiný způsob platby.

or any other localized version of this message, the issue is not with b>Merchand ID, as official documentation might hint.
It’s the issue with plugin itself.

Open this file wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/class-wc-gateway-braintree.php
On line 108, you need to comment out the wp_enqueue_script() and replace it with a different ( up-to-date url )

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );

		parent::enqueue_gateway_assets();
	}
}

becomes

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		// wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/js/braintree-2.32.1.min.js', array(), WC_Braintree::VERSION, true );
		parent::enqueue_gateway_assets();
	}
}

That’s it, works without adding additional Merchant ID. Simply but, the JS used in official plugin is outdated.

Centos7 Plesk 17.0 mu14 error updating psa-mail-driver-common

If you get this error while running yum update

--> Finished Dependency Resolution
Error: Package: psa-mail-driver-common-17.0.17-cos7.build1700161124.17.x86_64 (@PLESK_17_0_17-dist)
           Requires: libopendkim.so.10()(64bit)
           Removing: libopendkim-2.10.3-7.el7.x86_64 (@epel)
               libopendkim.so.10()(64bit)
           Updated By: libopendkim-2.11.0-0.1.el7.x86_64 (epel)
              ~libopendkim.so.11()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Just run

$ plesk installer --select-release-current --reinstall-patch --upgrade-installed-components
$ yum update

And you are all set