Categoria: english

21 aprile 2018 / / english

HTTP/2 is the volution of the HTTP/1.1 protocol, originally  developed by  Google as SPDY it’s now a standard, and gives webserver faster responses to  visitors.

First of all make sure your webserver is HTTP/2 enabled.

14 aprile 2018 / / english

I’ve installed a brand new RaspberriPi3 with Raspbian, based on Debian 9.4 Stretch.

At first I tried LiberELEC, but I didn’t find myself comfortable with not having full ssh freedom. Some commands were missing, and some packages the same.

So I turned back and installed Raspbian 9.4 Stretch, also to be  able to remotely  access the mediacenter via VNC and other stuff.

Since I didn’t mean to have keyboard and mouse connected to the Raspberry I wanted to have Kodi started at boot.

13 febbraio 2018 / / english
29 gennaio 2018 / / english

Last year we moved from a traditional Samba based network to a Nextcloud based one. Despite having some more space taken on the local disk we have the advantage of being able to work everywhere, having files backed up immediately (or at least as soon as there’s a network connection) and still being able to limit file access through groups selection.

With the old Samba configuration we had ssh access to the main server where we hold the office ssh key, and from which we start most of our remote sessions. When the file was on the filesystem it was rather easy to adapt permissions to allow unprivileged user to read the key, but now with Nextcloud the files are not accessible anymore (because the storage is encrypted! Otherwise you can access it in Nextcloud data dir).

But we still have the chance to mount Nextcloud via webdav. This is easily achievable by following Nextcloud user manual about mounting from command line.

But in the past, at least with Ubuntu 12.04, davfs mounts weren’t very much stable… Also it’s annoying to remember to mount the share when you need, but most of all remembering to unmount it before logging out (or when your session terminates unexpectedly). So I had the goal to use autofs to mount user’s Nextcloud share automatically, and of course leave them unmounted when not needed.

22 dicembre 2017 / / english

Quick tip for managing postfix’s mail queues. A customer uses an old mailing software and he got subscription of unknown domains, which then remains in queue for long time. To purge a single domain from your mail queue use the following command:

mailq | grep -B3 "\.ovh$" | grep "^[0-9A-Z]" | cut -f 1 -d ' ' | xargs -n 1 postsuper -d

this will delete all mails in queue for the TLD .ovh.

13 dicembre 2017 / / english

To debug email sending in Yii2 you have the useFileTransfer option, enabled by default, on the component configuration. With this option you can control whether mail is delivered to a MTA (Mail Transport Agent) or instead written to file.

It’s a convenient way for developers to check the content of an email, or to do tests: mails are written to @runtime/mail as .eml files which can be opened with a text editor or an email client.

But it doesn’t fit the situation where you want your customer to testdrive the application, maybe with real email addresses but of course you don’t want these emails to be delivered to the real email address? I wanted a solution which allowed me to collect all the emails generated from the application to a single email address.

17 novembre 2017 / / english

Requirement: use a local custom string for a core Yii2 message.

Since of course I didn’t want to  touch files into @vendor (which wouldn’t survive an upgrade, and are out of git control) I worked it out by customizing the i18n core component of Yii2.

Open up config/web.php (if you created the app from the basic template) and add the following into the components section:

13 novembre 2017 / / english

Today I had to convert a PDF into a web embeddable image. In the past we used to run Ghostscript via exec()/system() calls, but that’s annoying because you have to deal with temporary files, if you don’t intend to keep them for archive. So I wanted to try a more decent way: convert the PDF using PHP’s Imagick libraries and display the image inline, using data-uri. This is the code I came up with:

try {
    // [0] means pick just the first page of the PDF
    $img = new \Imagick(Yii::getAlias("@app/documenti/pdf/{$this->telaio}-{$this->id}.pdf[0]"));
} catch (\ImagickException $e) {
    Yii::trace($e->getMessage(), __METHOD__);
    // If there's an error, most likely missing file, display a transparent PNG
    // If you want smaller image you can use GIF, but I had to display it in a mPDF document and it didn't like it 
return 'data:image/png;base64,'.base64_encode($img->getimageblob());

Unfortunately the exception I got was not about a missing file (which of course could have been properly checked), but:

ImagickException FailedToExecuteCommand ‘gs’

Ok, given that you have GhostScript installed (maybe via Homebrew), and gs command is in your path, let’s see why it’s not working.

17 ottobre 2017 / / english

Checking a Zimbra Network Edition server I found out backups were not running for some time. Nobody noticed because reports email were not delivered.

When running

zmbackup -f -a all

I got this error message:

Error occurred: system failure: unable to retrieve latest session-account, account name-id maps

Talking in IRC Tonster suggested that the main Zimbra backup file, accounts.xml, could have been corrupted.

13 ottobre 2017 / / english

When I purchased the new Macbook Pro last year, one big issue was the lack of widely used interface ports. In order not to purchase many dongles (and spend too much on the Apple Store) I had a look on the usual sites and found a nice one from Cable Matters (no, sadly I have no sponsorship from them) which had them all: ethernet, USB-A, VGA and HDMI. Fantastic!

Coming from Linux, where 99% of the drivers are already provided in the kernel, the first odd thing I had to do is install the drivers for these ports! Even if I manage Windows computers daily, I wasn’t used anymore on my laptop!

Luckily drivers are not hard to find:

  • USB-A port uses ASM1153 chipset (55aa:174c), but works out of the box
  • Ethernet uses AX88179 from Asix (1790:0b95)

When I first installed the drivers I was using Sierra, and no problems arise. Now that I reinstalled with High Sierra the ethernet driver wasn’t working. Why? User-Approved Kernel Extension Loading.