Timed WiFi enable/disable (MikroTik)

During sleep I don’t need WiFi and while the router is in my room where I sleep it would be health beneficial to sleep without WiFi signal.

Thankfully Mikrotik has some great features

First I needed scripts for enable and disable. After that they could be executed via Scheduler.

Screen Shot 2017-03-16 at 06.48.34

Posted in health, productivity, wakeonlan | Tagged , , | Leave a comment

Linux ffmpeg screencast command

Simple screen capture with ffmpeg in Linux with:

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 output.mp4
Posted in linux | Tagged , , | Leave a comment

Debugging duplicate query exec in WordPress

During debugging a plugin malfunction I had duplicate option update SQL queries and after som thinking I came up with the following debug line to catch the trace of duplicate function call:

 error_log(var_export(debug_backtrace(), true));

I placed it above the return line in update_option() function in wp-includes/option.php

Finally had a trace in php/apache error_log file.

The second query came from an action hook in another plugin 😦

Posted in Uncategorized, wordpress | Tagged | Leave a comment

Mail sending via SMTP for WordPress

I was looking for some really simple SMTP solution for WordPress, only some code to send emails via SMTP. Without a plugin for localhost usage.

Came up with the following script in wp-content/mu-plugins/smtp.php

add_action('phpmailer_init', 'custom_phpmailer_init');
function custom_phpmailer_init($phpmailer) {  
 $phpmailer->Host = 'smtp.example.com';
 $phpmailer->SMTPDebug = 0;
 $phpmailer->SMTPAuth = true;
 $phpmailer->SMTPSecure = "ssl";
 $phpmailer->Port = 465;
 $phpmailer->Username = 'info@example.com';
 $phpmailer->Password = '';

return $phpmailer;
Posted in Uncategorized, wordpress | Tagged , | Leave a comment

Blocking web access by country code via htaccess

Some Ukraine and Russian folks don’t know how to behave so I decided to block the whole country. Also they’re not target audience for the targeted web.

# .htaccess

<IfModule mod_geoip.c>
GeoIPEnable On
Deny from env=blk

They were causing 509 Bandwidth Limit Exceeded on some client webs with Joomla :/

Posted in security | Tagged , | Leave a comment

Useful Postfix CLI commands to manage email queue

During dev I sometimes need to check what emails are scheduled to be sent.

Display a list of queued mails

sudo mailq

View message in queue

sudo postcat -vq QUEUE_ID

Delete queued mail after debugging

sudo postsuper -d ALL
Posted in postfix, Uncategorized | Tagged , , | Leave a comment

Fixing MailChimp error “Data did not match any of the schemas described in anyOf.”

While PUTing subscribers into MailChimp I got a bunch of “Data did not match any of the schemas described in anyOf.” error responses from the API server.

Tried googling, but with no luck.

Second try was to look at the array (data) that was sent.

    [email_address] => info@example.com
    [status_if_new] => subscribed
    [merge_fields] => Array
            [FNAME] => John
            [LNAME] => Doe
            [COMPANY] => 


My thought was that the empty merge field COMPANY was the problem.
So after modifying the code to only send not empty merge field data the error disappeared.

Posted in php, Uncategorized | Tagged , | Leave a comment