1 февраля 2019 г.

dompdf setPaper size orientation not working

According to the Usage page, in order to set the paper size and orientation you need to call setPaper(). However, this won't work if in your actual HTML you're rendering you have page size definition such as this:
    @page {
        margin: 0;
        padding: 0;
        size: 210mm 297mm;
    }
    html {
        margin: 0;
        padding: 0;
    }
    body {
        margin: 0;
        padding: 0;
    }
This will override whatever you set with setPaper(). Either remove it, or edit it.

24 декабря 2018 г.

Setting Apple Photos exported file created and modified times to match capture date using EXIFTool on Mac OS

I exported a few originals from the Mac Photos app. The resulting photos had Date Modified and Date Created set to the time of export. However, the EXIF capture time contained the actual capture time. Need to set file creation and modification times to match the capture time using the EXIF Tool.
exiftool "-DateTimeOriginal>FileModifyDate" /Users/admin/PhotosTest
Few things were confusing to me initially as those don't seem to be clarified in the documentation.
  • DateTimeOriginal actually stands for the capture date
  • FileModifyDate represents not only the Date Modified (file modification time), but also the Date Created (file creation time), though won't change the Date Added time. I'm referring to the Finder column names here.
  • Be careful with AllDates shortcut which you may notice in the docs, as it will alter the original capture date as well, and you'll lose it if you don't have the backup.
P.S. This works both ways: you can swap the parameters to set the EXIF capture date to match the file modification date.
exiftool "-FileModifyDate>DateTimeOriginal" /Users/admin/PhotosTest
Reference

14 декабря 2018 г.

raspberry pi openbox screen resolution

Sometimes a monitor won't report it's largest available screen resolution correctly. In such a case, you'll have to set it manually. My first hit on Google suggested some xrandr trickery which didn't work for me. Here's what did.
sudo raspi-config
Go to Advanced Options -> Resolution and choose yours. Both DMT and CEA modes worked on multiple devices, just make sure you got the right screen ratio and refresh rate.

29 августа 2018 г.

ssh tunnel systemctl systemd service

sudo vi /lib/systemd/system/mytunnel@.service:
[Unit]
Description=My Tunnel Service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=username
ExecStart=/usr/bin/autossh -f -N %i
 
[Install]
WantedBy=multi-user.target
/home/username/.ssh/config:
Host myhost
Hostname my-ssh-host.example.com
User username
RemoteForward 0.0.0.0:22022 localhost:22
IdentityFile /home/username/.ssh/id_rsa
ServerAliveInterval 30
ServerAliveCountMax 32
# warning: MITM
UserKnownHostsFile=/dev/null
StrictHostKeyChecking no
Replace username with actual user name. Usage: sudo systemctl start mytunnel@myhost sources:

15 августа 2018 г.

cakephp debug_kit table doesnt exist

Warning (512): Fixture creation for "panels" failed "SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes" [CORE/src/TestSuite/Fixture/TestFixture.php, line 313] Warning (512): Fixture creation for "panels" failed "SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes" [CORE/src/TestSuite/Fixture/TestFixture.php, line 313] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cakephp_debug_kit.panels' doesn't exist
Solved by changing the database/schema collation from utf8mb4 to utf8/utf8_unicode_ci

14 августа 2018 г.

Leafpad: lightweight GUI text editor for rox-filer on Openbox / Raspberry PI

I needed a lightweight file manager for an Openbox machine. rox-filer seemed like a decent option. But in order to look for and manage some config files, I needed the ability to quickly view their contents, so rox-filer alone wasn't enough, I needed a lightweight file editor too. Looking through the officially suggested options, I found leafpad. I ran most of those suggestions against apt-get install --no-install-recommends, and even with the no-recommends flag there were about 50MB of required dependencies. However, leafpad (as well as rox-filer itself) required no additional packages to be installed.

apt-get install --no-install-recommends -y rox-filer leafpad

Then go to $HOME/.config/rox.sourceforge.net/MIME-types/text and put the following inside:

#!/bin/sh
LEAFPAD="$(which leafpad)"
"${LEAFPAD}" "$@"
Then you can right click pretty much any file, then choose "File 'example'" and then "Open As Text".