Autore: maxxer

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:

15 novembre 2017 / / italiano
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 http://php.net/manual/en/imagick.construct.php#113801
    $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/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfhCw0MIjeCY5EAAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==';
}
$img->setImageFormat("png");
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.

12 ottobre 2017 / / english

Since I’m oldskool (and since Time Machine stopped working nearly one month after I started using my new Mac), I was compelled to do a manual backup of my system before reinstalling it.

Yes, I reinstalled a MacOS system in less than one year. I remember doing this just when I was reinstalling Ubuntu from scratch after the release of a new version. Not really what I was expecting from a Mac.

Anyway… What I did was just an rsync of my whole home to an external disk, but then I had to recover the most I could. Reinstalling is fun, but reconfiguring everything not as much!

22 settembre 2017 / / italiano

In breve: vendendo le nostre informazioni alle agenzie di marketing!

Tempo fa sono stato contattato telefonicamente per una campagna di raccolta fondi da Unicef.

Li conosco bene, ma non ho mai avuto contatti in precedenza con loro, e non li ho mai sovvenzionati. L’operatrice che mi ha contattato mi ha chiamato per nome e cognome, con mia grande sorpresa. Le ho chiesto immediatamente come facesse ad avere i miei dettagli, e lei molto cortesemente mi ha spiegato che hanno acquisito tutti i nominativi da una società di marketing di nome Italia Mobile. Dopo che mi ha spiegato in modo chiaro da dove provenisse il mio nome e numero di cellulare le ho fatto esporre la sua richiesta, ed abbiamo concluso la telefonata.

Mi sono allora incuriosito da dove avesse acquisito Italia Mobile il mio nominativo. Non trovando dettagli su come fare questa richiesta sul sito ho inviato tramite il form di contatto una richiesta per la rimozione dei miei dati dal loro database.

13 settembre 2017 / / italiano

Non sono un amante del genere, ma tool come WeTransfer sono molto apprezzati.

Oramai sono rassegnato ad impostare ai server di posta dei limiti imbarazzanti sulle dimensioni dei messaggi, da 30 a 50MByte. È anche vero che non siamo più ai tempi dei modem, quindi trasferire quella mole di dati non è più così oneroso. Certo è che mediamente nessuno (me incluso) cancella la posta o comunque gli allegati, nemmeno dopo che sono stati archiviati e/o gestiti, quindi le caselle di posta crescono a dismisura in dimensione.

11 settembre 2017 / / english

Yesterday I released a new version (thus introducing the concept of versions) of the certbot-zimbra script.

One of the most notably change is the removal of the patches/ subdirectory, which I personally hated. Now patches are embedded inside the script. Less crap around to manage!

Also the patching method was changed: instead of having a single patch file (or variable, with the new method) for every Zimbra version now I do version comparison. So now there’s an if (version < 8.6) apply patch 1, otherwise if lower than X.Y apply patch 2 and so on. Simpler and less problematic for users.

8 settembre 2017 / / english