How to change priority on Windows scheduled task using Powershell?

By default Windows setups task priority in scheduler to 7 (which is kinda low). The side effect of this is that for eg. backups are taking very long to take. In my case all databases were backed up in about 40-50 minutes…

Continue reading How to change priority on Windows scheduled task using Powershell?

How to force https on IIS webiste?

Edit web.config file in your website directory and carefully add this lines (remember to change domain name):

File: web.config

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="Force HTTPS" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    <action type="Redirect" url="{R:1}" />

Brutal fix for “Incorrect string value:” error in Matomo (Piwik)

If you’re using Matomo (previously Piwik) on MS IIS and MariaDB  and you’re getting a lot of these:

[06-Jun-2018 11:56:36 UTC] Error in Matomo (tracker): Error query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xC3_\xC6\x92\xC3\x82...' for column 'name' at row 1 In query: INSERT INTO matomo_log_action (name, hash, type, url_prefix) VALUES (?,CRC32(?),?,?) Parameters: array (   0 => 'Ă_ƒÂ¢',   1 => 'Ă_ƒÂ¢',   2 => 1,   3 => 1, )

You can use my fix (because literally nothing that can be found in the internet is helpful in this case).

Continue reading Brutal fix for “Incorrect string value:” error in Matomo (Piwik)

Backup script for PostgreSQL with zip support (Windows)

Simplest solution for backing up PostgreSQL databases. With this bat file you can dump one database to a file and compress it using 7-zip.

PS. If you want a date in your filename simply add %date% var to it’s string.
PS2. Of course check your paths before complaining it does not work 😛

@echo off
:: Global config
SET PG_BIN="C:\Program Files\PostgreSQL\9.6\bin\pg_dump.exe"
SET PG_HOST=localhost
SET PG_PATH="C:\inetpub\temporary_backups"
SET ZIP_BIN="C:\Program Files\7-Zip\7z.exe"

:: Database config for 
SET PG_DATABASE=your_database_name
SET PG_USER=your_database_user
SET PGPASSWORD=youe_database_password


@echo Backup Taken Complete %PG_PATH%%PG_FILENAME%

PHP reading problem with files larger than 2 GB

If you’ll ever have problem with opening (fopen) and reading (fread) files larger than 2 GB in your PHP script. Check your version of scripting engine. In my case switching to 64 bit solved the problem. Please mind that this error is very hard to debug because PHP does not log anything (same as MS IIS) in such case. It simply resets client connection…