Reinstall (bless) rEFInd after Mac OS X update

If you are using Mac OS X 10.11 or later boot into recovery mode (command+R while booting) and in the terminal disable SIP:

$ csrutil disable

Restart and then check in what partition is EFI installed:

$ diskutil list | grep EFI
   1:   EFI EFI      209.7 MB   disk0s1

Then:

$ sudo mkdir /Volumes/EFI
$ sudo mount -t msdos /dev/disk0s1 /Volumes/EFI
$ sudo bless --mount /Volumes/EFI --setBoot --file /Volumes/EFI/efi/refind/refind_x64.efi --shortform
$ sudo diskutil unmount /Volumes/EFI

Enable SIP again in the recovery mode if needed:

$ csrutil enable

Fix “There is no suitable CSPRNG installed on your system” in Plesk

After updating paragonie/random_compat you may get this error. This is caused because version 2.0 stopped using OpenSSL and now it uses /dev/urandom which may not be readable by your PHP configuration. This is fixed adding /dev/urandom to your open_base configuration in “Websites & Domains -> PHP Settings -> open_basedir”:

plesk-open_basedir-dev-urandom

Ref: http://forum.odin.com/threads/how-to-change-php-open_basedir-in-plesk-10-4-4.259102/
https://forum.owncloud.org/viewtopic.php?t=34286
https://github.com/paragonie/random_compat/issues/99

CentOS “Error: php-mysql conflicts with php-mysqlnd” updating with PHP 7.0

If you get an error about a conflict between php-mysql and php-mysqlnd when updating CentOS packages after installing and activating the PHP 7.0 remi package source like this one:

# yum -y install php-mysql

...

--> Finished Dependency Resolution
Error: Package: php-mysql-5.4.45-7.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.45-7.el6.remi
           Removing: php-pdo-5.3.3-46.el6_7.1.x86_64 (@updates)
               php-pdo(x86-64) = 5.3.3-46.el6_7.1
           Updated By: php-pdo-7.0.5-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.5-1.el6.remi
           Available: php-pdo-5.3.3-40.el6_6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-40.el6_6
           Available: php-pdo-5.3.3-46.el6_6.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-46.el6_6
           Available: php-pdo-5.4.45-5.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-5.el6.remi
           Available: php-pdo-5.4.45-7.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-7.el6.remi
           Available: php-pdo-7.0.4-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.4-1.el6.remi
Error: php-mysql conflicts with php-mysqlnd-7.0.5-1.el6.remi.x86_64
Error: Package: php-mysql-5.4.45-5.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.45-5.el6.remi
           Removing: php-pdo-5.3.3-46.el6_7.1.x86_64 (@updates)
               php-pdo(x86-64) = 5.3.3-46.el6_7.1
           Updated By: php-pdo-7.0.5-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.5-1.el6.remi
           Available: php-pdo-5.3.3-40.el6_6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-40.el6_6
           Available: php-pdo-5.3.3-46.el6_6.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-46.el6_6
           Available: php-pdo-5.4.45-5.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-5.el6.remi
           Available: php-pdo-5.4.45-7.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-7.el6.remi
           Available: php-pdo-7.0.4-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.4-1.el6.remi
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

You can just remove the PHP 5.x version of php-mysql:

# yum remove php-mysql

Update all the packages:

# yum -y update

And finally just install php-mysql again but this time it will be from PHP 7.0:

# yum -y install php-mysql

Exit maintenance mode in WordPress when an update fails

To exit maintenance mode in WordPress when an update fails is as easy as deleting the .maintenance file from the root folder. Fixing the update problem is another history…

wordpress-maintenance-mode

Use HTTPS protocol in WordPress 4.4+ for srcset attribute

I’ve started using “Let’s Encrypt” in multiple sites I manage. Just after installing it for this blog I noticed that all images didn’t load because they were originally linked with HTTP.

mixed-content-loaded-over-https-insecure-script

This was easy to fix with a simple SQL update:

UPDATE wp_posts SET post_content = replace(post_content, 'http://tech.enekochan.com', 'https://tech.enekochan.com');

But I still got the “Mixed Content” error messages. Looking at the generated page source code I found that WordPress 4.4+ adds a responsive image attribute to images img tags: srcset. And the problem was that the links there were using HTTP. Adding this code in functions.php solved the issue:

/*
 * Force URLs in srcset attributes into HTTPS scheme.
 * This is particularly useful when you're running a Flexible SSL frontend like Cloudflare
 */
function ssl_srcset( $sources ) {
  foreach ( $sources as &$source ) {
    $source['url'] = set_url_scheme( $source['url'], 'https' );
  }

  return $sources;
}
add_filter( 'wp_calculate_image_srcset', 'ssl_srcset' );

Ref: https://wordpress.org/support/topic/responsive-images-src-url-is-https-srcset-url-is-http-no-images-loaded#post-7767555
https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/