Of Dark Themes and Cookies

I’ve thought of implementing a toggle-able Dark Theme for bhtooefr‘s WP-Web1.0 theme; it could work by using a checkbox to toggle the appearance with a combination of CSS selectors and @keyframes … then I got to thinking that I may need to store the preference (when browsing in my phone, and in the dark it’s pretty upsetting to see a very bright screen).  However, that’d require … cookies … and that’d imply a possible breach of the Cookie Law … and using JavaScript, thus defeating the purpose of Web1.0.

I recognize my memory was a bit hazy, because I forgot that it the law seems to encompass other forms of storage, and not only cookies. At first I was looking for alternatives to Cookies, and I had found that IndexedDB seems to have an overall good support across browsers.

But, as I read about the spirit of the law, as indicated in this StackOverflow answer, I understood that it may be interpreted to only imply personal identifiable data, and not about personal or session preferences. So, other forms of storage of state are covered under the law, but the opinion is that it wouldn’t be a breach if no information is being transferred.

I think it may be better to err on the safe side, and perhaps just change the style directly.



Multiple PNGs to PDF in Command-Line

Note: Keep in mind that this was written during the Covid-19 Pandemic.

So, I found myself having to send a signed and scanned document… but paranoid enough to not want to break quarantine to print, sign, and scan a document; I was also doubting that I could simply overlay a copy-pasted signature (because it’s probable that older generations want the document to ‘seem’ that it was scanned).

Long story short… I wanted to create a print-less scan-less signed and scanned document.

Long story long… I went through a lengthy process that consisted of roughly:

  • converting PDF to PNG
  • adding paper background texture; and whitening (scanners seem to perform some image processing to improve contrast)
  • manually signing with GIMP’s ink tool the date and signature for each page
  • applying GIMP’s Photocopy effect to make the document seem printed
  • slightly rotating each layer to make the document seem that it had some alignment issues
  • adding fake scanned frame (paper edges and shadow) from another document I had previously scanned

The only limitation was that the largest paper background texture I found was only 1600×1200 px in size, so my images were a bit small for an A4 document; this allowed for a 136 ppi (around 53.5 dot/cm) A4 document..

Once all that was done,  I had to convert the several png images into a single pdf. On my first attempt, after reading the documentation on ImageMagick’s Convert and its convert command-line options, I was trying to do the conversion as follows:

convert -verbose \
    -units PixelsPerInch \
    -page A4 \
    -density 136x136 \
    -size 1123x1590 \
    -resample 136 \
    *.png \
    output.pdf

But I was obtaining a document with a reduced size (a B9 document in paper size according to Ubuntu’s Document Viewer, evince). After reading this discussion in the ImageMagick Forum, there seemed to be a 13-year-old bug that was still causing problems. The fix turned out to be:

convert -verbose \
    *.png \
    -resize 1123x1590 \
    -units 'PixelsPerInch' \
    -density 136x136 \
    output.pdf

That worked like a charm.


Hello, Sick World!

So, being sequestered in the midst of a global pandemic has prompted me to re-take writing again. At least in some form.

I had been thinking of dusting off this blog for a while… but I’ll be the first to admit that the dust layers are dauntingly thick: I would need to import a very old backup (it may not be compatible with current WordPress), try to convert the multiple encodings of old posts, pages, and comments into UTF8, prune the cringe-worthy stuff, keep the decent rants and ramblings…

After that is done, I have been wanting to harden my WordPress installation by implementing tighter CSP measures, among other things… for now, I’m disabling comments (as Akismet would require to have an ‘unsafe-inline’ policy).

I have, for the time being, decided to document what I’m doing on a day-to-day basis and, every now and then, restore some content whenever possible.


Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!