W3 Total Cache custom cache preload

For some reason W3TC cache preload didn’t work, the w3_pgcache_prime was set, but the cron event was still missing.

While the web hosting didn’t allow CLI like cron to schedule php wp-cli.phar w3-total-cache pgcache_prime I ended up by reusing the command PHP code in a new file which is called via cron.

 * Web version of:
 * php wp-cli.phar w3-total-cache pgcache_prime
 * Check W3TC cache prime offset
 * SELECT * FROM `md_options` WHERE `option_name` = 'w3tc_pgcache_prime_offset';

use W3TC\Dispatcher;

error_reporting( -1 );

require_once __DIR__ . '/../wp-load.php';

try {
	$o = Dispatcher::component( 'PgCache_Plugin_Admin' );
		( isset( $vars['start'] ) ? $vars['start'] - 1 : null ),
		( $vars['limit'] ?? null )
} catch ( \Exception $e ) {
	error_log( __( 'PageCache Priming did failed: %s', 'w3-total-cache' ), $e );

error_log( __( 'PageCache Priming triggered successfully.', 'w3-total-cache' ) );


Filter Slovak question queries from Google Search Console

Based on https://twitter.com/DataChaz/status/1416330157749583872 I assembled a Slovak version

(?i)^(ako|aka|ake|kde|kam|kedy|co|naco|preco|koho|odkial|kto|ktory|ktora|ktore)[" "]

Works flawlessly

Slovak question words

Decorate docker logs with multitail

Colorscheme from ~/.multitailrc

# cs_re:cyan:.*\.(INFO|DEBUG).*
cs_re:white,red,bold:.* HTTP.* 500 .*

Then run multitail command

multitail -cS docker -l 'docker-compose logs -f app1 app2'

Inspired by https://gist.github.com/Stubbs/9504462 and https://devsrealm.com/cloud-computing/ubuntu/monitoring-multi-files-in-realtime-with-multitail-ubuntu/

To scroll back press “b”

To switch colorscheme just press “c” and select

Transmission daemon wait for mount

After reboot I had to manually start transmission due ConditionPathIsDirectory=/media/usb-4tb/torrent

Finally found the solution at https://unix.stackexchange.com/a/247547/39470

With systemctl list-units --type=mount just list your mounts and add the unit name to After=

My /etc/systemd/system/transmission.service looks the following now

Description=Transmission BitTorrent Daemon
After=network.target systemd-networkd-wait-online.service media-usb\x2d4tb.mount

StartLimitBurst=3 # Only 3 retries of restart

ExecStart=/usr/bin/transmission-daemon -f --log-error
ExecReload=/bin/kill -s HUP $MAINPID


Fixing Java Runtime

Wanted to try Bisq, but got error

bisq-desktop                                                                                                               [7:45:13]
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: bisq/desktop/app/BisqAppMain has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

Solution was to set JAVA_HOME before running it

JAVA_HOME=/usr/lib/jvm/java-11-openjdk bisq-desktop

I ended up aliasing it

alias bisq-desktop='JAVA_HOME=/usr/lib/jvm/java-11-openjdk bisq-desktop'

Set Brave browser as default in Linux

You might test/check if it isn’t already with

$ xdg-mime query default x-scheme-handler/http
$ xdg-settings get default-web-browser
$ echo $BROWSER

To set xdg-mime

$ xdg-mime default brave-browser.desktop x-scheme-handler/http
$ xdg-mime default brave-browser.desktop x-scheme-handler/https

Setting BROWSER env via .bashrc or .zshrc just append export BROWSER=/usr/bin/brave

Monitor remote service via LibreNMS

I wanted to monitor with LibreNMS if transmission-daemon process is running . On the remote host I had to install https://www.monitoring-plugins.org/ due check_procs command

Test monitoring command

$ cd /usr/lib/monitoring-plugins
$ ./check_procs -c 1:1 -a transmission-daemon
PROCS OK: 1 process with args 'transmission-daemon' | procs=1;;1:1;0;

Also on the remote host I had to install LibreNMS agent Check_MK which pushes data to LibreNMS server. Had to download and configure check_mrpe

wget https://raw.githubusercontent.com/librenms/librenms-agent/master/agent-local/check_mrpe
mv check_mrpe /usr/lib/check_mk_agent/local
chmod +x /usr/lib/check_mk_agent/local/check_mrpe
echo "transmission /usr/lib/monitoring-plugins/check_procs -c 1:1 -a transmission-daemon" > /etc/check_mk/mrpe.cfg

To monitor transmission service I had to Add service in LibreNMS service, select type mrpe and fill parameters

Save tabs/context in PHPStorm

Today I wanted to save open file tabs in PHPStorm due task switch so if I had to come back to the previous task I would have some guidance. Fortunately PHPStorm has some help for this, read https://www.jetbrains.com/help/phpstorm/managing-tasks-and-context.html#work-with-context

Just enable plugin Task management

After restarting you should see Tasks & Contexts under Tools