Quickly Switch Between HTML and Plain Text in mu4e

Last updated on December 29, 2024

Mu4e defaults loading messages in HTML with shr. While this works well most of the time, sometimes a plain text version is more readable. Therefore, it is desirable to create a key binding to switch between these two versions.

I have the following in my Emacs configuration:

;; Quickly switching between plain text and HTML mime type.
(keymap-set mu4e-view-mode-map (kbd "K")
            (lambda ()
              (interactive)
              (gnus-article-jump-to-part 1)
              (gnus-article-press-button)
              (gnus-article-press-button)))

This binds key Shift+K to switch between plain text and HTML versions of a message, if the message has both versions available.

Convert PNG Images To WebP Images Losslessly Using cweb in GNU/Linux

Last updated on October 18, 2024

To losslessly convert a PNG image to a WebP image on GNU/Linux, run the following command:

cwebp -z 9 input.png -o output.webp

9 indicates the best effort to compress the image, resulting in the smallest image size. You can replace 9 with a smaller number if you prefer a less aggressive compression effort.

If you haven't installed cwebp yet, it is available in the webp package in Debian and Ubuntu.

View the TLS Certificate Details of a Website on the Command Line Using GnuTLS

Last updated on December 27, 2023

With GnuTLS, we can view the certificate details of a website with the following commands (replace "example.com" with the website of your interest):

gnutls-cli --print-cert example.com < /dev/null | certtool --certificate-info

In the command above, gnutls-cli --print-cert example.com < /dev/null prints the certificate of the website in PEM format to the standard output. Its output is then sent as the standard input to certtool --certificate-info, which prints information on the given certificate.

Continue reading

Platform Dependent Python Coverage Test with Tox

Last updated on December 20, 2020

When testing Python programs, coverage.py is often used in measuring code coverage, and enforcing 100% code coverage is regarded as a good practice:

# .coveragerc
[coverage:report]
# Enforce 100% coverage test
fail_under = 100
show_missing = True

However, if there are some lines of code that are platform dependent (i.e., they are never executed on at least one platform), code coverage tests usually fail. For example, the following code snippet would always lead to a coverage that is less than 100% on a platform other than Windows:

if os.name != 'nt':
    # Do something if the OS is not Windows...

You can ask coverage.py to ignore this block by adding a comment # pragma: no cover, but then coverage.py would ignore it on all platforms, including all non-Windows platforms. If you use tox for testing, this issue can be resolved cleanly.

Continue reading

5 Misconceptions Web Developers Believe About Mobile App Development

Last updated on October 29, 2020

Mobile apps have emerged as a competitive alternative to websites. Although websites are still irreplaceable parts of digital presence for business brands, mobile apps have been forcing them to change. The emergence of Progressive Web Apps (PWA) showcases this shift.

In spite of this overwhelming popularity of mobile apps, many web developers still hesitate to improve their skills and extend their focus on mobile app development. What misconceptions the web developers mostly harbor regarding app development? Well, this is what we are going to explain here.

Continue reading