I got the ability to work with Heroku using my Debian Stretch system

The other day I found that:

  1. Heroku needs Python 3.6 or later to work (as of June 22, 2018). See: Getting Started on Heroku with Python.
  2. Debian Stretch (Debian Stable as of June 22, 2018) and its backports have only Python 3.5.

The solution was to build a Docker image based upon Ubuntu 18.04, which does have Python 3.6. See the project https://gitlab.com/TDDPirate/heroku_on_debian in GitLab.

July 15, 2018 update:

After I complained about flakiness of Selenium-based tests when the Selenium server is running outside of the Docker container while the application runs inside the container, Udi Oron suggested another way to run Python 3.6 on a Debian Stretch system: use pyenv.

Turns out that pyenv solves the pain point of running Python 3.6 on Debian Stretch without having to use a container. So Selenium-based tests are now stable.

The following is an excellent article about using pyenv:
Pyenv – Python Version Management Made Easier

And the following is a link to the GitHub repository:

I suspect that pyenv is the reason why people are not in a hurry to backport new Python versions to Debian.

How to visually compare two PDF files? (cont’d)

When I asked the above question in a Telegram group, people proposed also other tools, which I am summarizing below.
Amiad Bareli, Amit Aronovitch, Meir Gil and Yehuda Deutsch – thanks.

  1. ImageMagick compare
  2. matplotlib testing framework – supports also PDF:
    >>> import matplotlib.testing.compare
    >>> matplotlib.testing.compare.comparable_formats()
    ['png', 'eps', 'svg', 'pdf']
  3.  pHash – The open source perceptual hash library.

To get more PDF tips and updates, subscribe to my mailing list

How to visually compare two PDF files?

I have an application written in Python, which uses the ReportLab package for exporting PDF files.

Of course, the application needs to be tested. Among other tests, the PDF export function needs to be tested to ensure that the visual rendering of PDF files did not unexpectedly change.

Since it is possible to create and save an expected-results PDF file using fabricated test data, the above implies the need to compare two PDF files. It turns out that two PDF files created from the same data at two different dates – are different, due to embedded timestamps.

Hence, the need to compare visual renderings of the PDF files. ImageMagick’s convert knows how to convert PDF files into PNG. However, one needs to set the background and remove the alpha channel.

convert knows also to perform bitwise XOR on two image files, but it must be told how to compute the bitwise XOR. This is documented in StackOverflow: Searching for a way to do Bitwise XOR on images.

The script in  https://gitlab.com/TDDPirate/compare_pdfs implements all the above.

To get more PDF tips and updates, subscribe to my mailing list

The “Unable to locate WordPress root directory.” error when trying to update WordPress or install a plugin

If you encounter the “Unable to locate WordPress root directory.” error when trying to update your WordPress installation and/or plugins, and your blog is running on a PHP 7 version, installing the SSH SFTP Updater Support plugin may solve your problem. It worked for me.

Reference: DigitalOcean: WordPress SSH2 Updates, msmarcal’s answer .

Outputting PDFs with your own fonts from your Django application

Do you use reportlab for creating PDF files from your Django application, as instructed in Outputting PDFs with Django?
Do you wish to add your own font files?
Do you need to render Hebrew text?

If yes, the following information will help you.

When installed in a virtualenv, as recommended by good working practices, reportlab searches for font files it uses in your virtualenv/lib/python3.x/site-packages/reportlab/fonts and it is not good idea to add your own font files there.

Instead, add your font files to your_project_root_directory/reportlab_extra_fonts where your_project_root_directory is where your project’s manage.py is located. Add the following to any Python script that uses reportlab (usually views.py), after all regular reportlab import and configuration statements.
# The following configures extra reportlab fonts.
import os
from django.conf import settings
reportlab.rl_config.TTFSearchPath.append(os.path.join(settings.BASE_DIR, 'reportlab_extra_fonts'))
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
HEBREW_FONT_NAME = 'your_font_name'
pdfmetrics.registerFont(TTFont(HEBREW_FONT_NAME, 'your_font_file_name.ttf'))
# The above configures extra reportlab fonts.

If you want to properly display Hebrew in your PDF file (the probable reason why you needed to add your own fonts in the first place), you need to convert the text yourself from logical ordering to visual ordering, because reportlab (as of version 3.4.0) does not currently process BiDi text. For this purpose, install the python-bidi package in your virtualenv (using pip install python-bidi) and add the following import statement to your views.py script:
from bidi.algorithm import get_display
Now, get_display() will reorder your BiDi text.

To get more PDF tips and updates, subscribe to my mailing list

Information on notetaking in events

The following are links to documents about notetaking in events in Israel. The documents are in Hebrew.

דלעיל מופיעים קישורים למסמכים על תמלול באירועים בישראל. המסמכים כתובים בעברית.

Update from May 10, 2022: the notetaker Tal Hyam has a blog about notetaking and transcribing (first link below). The blog is written in Hebrew. I highly recommend that you read the article about notetaking in events (second link below):

עדכון מ-10 במאי 2022: המתמלל טל חי-עם פתח בלוג על תמלול (קישור ראשון דלעיל). הבלוג כתוב בעברית. מומלץ שתקראו את המאמר על תמלול באירועים (קישור שני דלעיל).

How to manage money before registration of the Hamakor nonprofit

Hamakor – an Israeli nonprofit for Free Software and Open Code was founded at 2003 and one of its goals is to help deal with money when organizing various activities around Free Software.

Before founding Hamakor, people resorted to other solutions. In one exhibition, we wanted to distribute Linux installation CD-ROMs to the crowd. However, we wanted those CD-ROMs to reach only people who have a serious intent to install Linux. A way to ensure it was to require them to donate money in exchange for their CD-ROM. However, if we collect money, we must issue receipts and do bookkeeping.

Truly Yours had the brilliant idea of inviting other nonprofits to send a representative to collect the donations and issue receipts. It was a win-win-win solution. We get someone to issue receipts and sweat over the bookkeeping. The nonprofits get money for their operations. The people, who paid for their CD-ROMs, treat them seriously.

One of the nonprofits was the Association of the Deaf in Israel.

Thank you letter from the Association of the Deaf in Israel
Thank you from the Association of the Deaf in Israel

The 2010’s John Galt project – Artificial Photosynthesis

The 2010’s John Galt project – the most important technology to be developed this decade:

Artificial photosynthesis.

Technology for using solar energy to bind carbon dioxide with hydrogen from water, and convert them into carbohydrate fuels.

The technology will have the following benefits:

  1. Solve the problem of global heating, thanks to removal of carbon dioxide from the atmosphere.
  2. Make it possible to power everything using solar energy – directly during daytime, and indirectly (through burning the carbohydrate fuels) at night and bad weather.

The biggest drawback: drastic change in the economic power structure worldwide, because countries and companies with coal, oil or gas deposits would no longer have power over their clients.

פרויקט ג’ון גאלט של שנות ה-2010 – הטכנולוגיה החשובה ביותר לפיתוח בעשור הנוכחי:

פוטוסינתיזה מלאכותית.

טכנולוגיה לשימוש באנרגיית השמש כדי לקשור פחמן דו חמצני עם מימן מהמים, ולהמיר אותם לדלקי פחמן-מימן.

לטכנולוגיה כזו יש שני יתרונות גדולים:

  1. פתרון לבעית ההתחממות הגלובלית, הודות להסרת פחמן דו חמצני מהאטמוספירה.
  2. אפשרות להשתמש באנרגיית השמש כדי לספק כוח לכל צרכני החשמל – ישירות בשעות היום ובעקיפין (באמצעות שריפת דלקי פחמן-מימן) בלילה ובמזג אוויר סגרירי.

החסרון הגדול ביותר: שינוי דרסטי במבנה הכוחות הכלכליים בכל העולם, מכיוון שארצות וחברות שיש להן מרבצי פחם, נפט וגז, יאבדו את הכוח שלהן על לקוחותיהן.

A proposed new language construct: do/undo

There are several cases, in which a program has to do operations A,B,C. If an error occurs while doing A, the program needs to undo A. If there is an error while doing B, the program needs to undo B then A. Similarly, an error in C requires undoing of C,B,A in this sequence.
Continue reading “A proposed new language construct: do/undo”

First Contact Speculations

Given the announcements about finding more and more Earth-like planets around other Suns and potentially life-friendly regions in Jupiter and Saturn’s satellites, I would like to offer the following predictions.

  • Actual First Contact has already happened. People do not discuss the distance between Roswell and Alamogordo, which is near the site of the first A-bomb explosion, and which happens to be only 145Km by air.
  • Since First Contact among two cultures, which significantly differ in their technological sophistication, is usually harmful to the less technologically advanced culture, it was decided not to publicize this fact without preparing the Earth culture for those news.

    Furthermore, it was decided that the Earth people are to be the ones to “discover” the alien culture, rather than vice versa.

  • Several SciFi stories assumed that alien cultures would discover the existence of a technological Earth culture by radiation from its first A-bomb explosions. Arthur C. Clarke’s “2001 Space Odyssey” assumed that this would happen when a certain slab is excavated on the Moon. The Star Trek world assumed that the discovery would by detecting the radiation emitted by Zefram Cochrane‘s first FTL flight using a warp drive system.

    However, I believe that the real “Zefram Cochrane” moment would be when the Earth culture proves its ability to defend life on Earth by deflecting or destroying killer asteroids.

Hence, my prediction is that once a dangerous asteroid has been detected and successfully neutralized, it will be announced that some Earth probe ship has at last found signs of alien life.

%d bloggers like this: