Journal of my recent activities

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

Downloading backups from remote hosts

rsync -av --delete -e 'ssh -p 223' user@host:/dir1 local_dir

#soft #linux

Symetric ant anti-symetric wave function

http://hyperphysics.phy-astr.gsu.edu/hbase/molecule/hmol.html

Google Sheets: Bulk delete

Tools > Script ediotr Set a breakpoint at console log sheet name and Debug.

function DeleteAllSheets() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  console.log("Doc: " + ss.getName());
  var sheets = ss.getSheets();
  for (i = 0; i < sheets.length; i++) {
    switch(sheets[i].getSheetName()) {
      case "21-01":  
        break;
      default:
        console.log("Delete: " + sheets[i].getSheetName());
        ss.deleteSheet(sheets[i]);
    }
  }
}

https://spreadsheetpoint.com/delete-multiple-sheets-google-sheets/

#soft

Convert ssh2 public key to openssh format

If the pub key is in the format

---- BEGIN SSH2 PUBLIC KEY ----

then you can convert it with

ssh-keygen -i -f klucz.pub >> ~/.ssh/authorized_keys

#soft #linux

Backup SD Card in Fedora

  1. Insert card
  2. Check the /dev label (fdisk -l; lsblk, df)
  3. Unmount: umount /dev/sdb1 (do not use Nautilius eject button)
  4. Backup: dd bs=4M if=/dev/sdb of=nextcloud210313.img

Update pip packages

(venv) $ pip list --outdated
(venv) $ pip list --outdated --format=freeze \
               | grep -v '^\-e' | cut -d = -f 1  \
               | xargs -n1 pip install -U

How to upgrade all Python packages with pip #python #soft

$ systemctl list-timers
$ systemctl enable --now ibm_backend.timer

in user space use --user parameter, and put your timers into ~/.config/systemd/user/

Use systemd timers instead of cronjobs

certbot timer

#linux