Thu 22 Aug 2019

Counting tumblelog days

In the afternoon I was curious how many days I had blogged on Plurrrr. A simple one-liner using find on the command line provided the answer: 150.

find htdocs/archive/ \
     -name '*.html'  \
     -print | grep -cv week

This one-liner finds all files ending in .html in the archive directory and prints the path and filename of each match. The grep command counts (option -c) all lines except for those containing week; the option -v inverts the match.

Note that I split the one-liner over 3 lines for clarity and to make it fit on this page by using backslashes. A backslash at the end of a line means the line continues on the next line. You can either copy paste the example as is, or glue the lines together to get a true one-liner.

Time to shed Python 2

The end of life (EOL) date for Python 2 has been a long time coming, but it's finally in sight. As of the 1st of January 2020, Python 2 will no longer be supported. There will be no more bug fixes, or security updates, from Python's core developers.

So, if you're still using 2.x, it's time to port your code to Python 3. If you continue to use unsupported modules, you are risking the security of your organisation and data, as vulnerabilities will sooner or later appear which nobody is fixing.

In the evening I read Time to shed Python 2 on the National Cyber Security Centre website.

When I wrote the Python version of tumblelog, the static site generator that creates this blog, I made sure to use a recent version of Python. Not only because of the upcoming end-of-life of Python 2 but also because of the handy new features in Python 3.

Coming soon: tumblelog 2.0.0

In the evening I worked a little on what will become tumblelog version 2.0.0. In this version the following Markdown:

A cat resting in the shadows.

will be rendered to HTML as follows:

<img src="cat.jpg" alt="photo" />
A cat resting in the shadows.

instead of the default for CommonMark, the renderer I use:

<img src="cat.jpg" alt="photo" />
A cat resting in the shadows.

This makes it possible to style the image and the caption via CSS.

Image rendering in tumblelog 2.0.0
Image rendering in tumblelog 2.0.0.

The Python version is finished, and currently used to test this feature on this site. For the Perl version I have to create a Perl module and release it on CPAN. This module will make it possible to render the CommonMark abstract syntax tree (AST) in a different way in order to get the desired HTML output.