Journal of my recent activities

Renew:

$ certbot renew

list certbot certificates:

$ certbot certificates

remove:

$ certbot delete --cert-name domain-name

#certbot #letsencrypt

Save RAM memory using generators which return a lazy iterator.

Optimizing Memory Usage in Python Applications

#python

Setting up a default shell / Midnight Commander editor and viewer:

sudo update-alternatives --config editor

or

  1. Turn off in mc > Configuration "Builtin editor an viewer"
  2. Add to ~/.zshrc:
export EDITOR=nvim
export VIEWER=nvim

#linux #zsh #mc

Opening odt files in Midnight Commander on MacOS

regex/\.(.*)$
    Open=(open %f &)

#mac #mc

Resize all images in dir

for file in *.jpeg; do convert $file -resize 500x $file; done

#linux #bash

LibreOffice transpose rows to columns

  1. Copy to clipboard the cell range that you want to transpose.
  2. Paste Special, in the dialog, mark Paste all and Transpose.

Rotating Tables (Transposing) - LibreOffice Help

#libreoffice

Automatic change of linux configuration files

sed -i 's/#Port 22/Port 123/' /etc/ssh/sshd_config

#linux

Dictionary of values with choices for select.


from enum import Enum


class ResourceType(Enum):
    HTML = 0
    VIDEO = 1
    AUDIO = 2
    IMAGE = 3
    PDF = 4
    HTTP = 5
    EPUB = 6


def get_choices():
    return [(r.value, r.name) for r in ResourceType]

Creating unit tests for Flask.

import unittest

from app import create_app, db
from config_tests import Config


class MmTestCase(unittest.TestCase):
    def setUp(self):
        self.app = create_app(Config)
        self.appctx = self.app.app_context()
        self.appctx.push()
        db.create_all()
        self.client = self.app.test_client()

    def tearDown(self):
        db.drop_all()
        self.appctx.pop()
        self.app = None
        self.appctx = None
        self.client = None

How to Write Unit Tests in Python, Part 3: Web Applications