Skip to content

December of 2022

Life Management

Life review

  • New: How to review your life.

    Sometimes is good to stop, get into your cave and do an introspection on how is your life going.

    I like to do this exercise the last week of the year. Although I'd like to do it at least twice a year.

    This article is the checklist I follow to do my life review, it may seem a lot to you or maybe very simple. You can take it as a base or maybe to get some ideas and then create your own that fits your needs.

    The process then has many phases:

Coding

Languages

Libraries

  • New: Introduce python gnupg.

    python-gnupg is a Python library to interact with gpg taking care of the internal details and allows its users to generate and manage keys, encrypt and decrypt data, and sign and verify messages.

    Installation:

    pip install python-gnupg
    

    Usage:

    ```python gpg = gnupg.GPG(gnupghome="/path/to/home/directory")

    gpg.decrypt("path/to/file")

    public_keys = gpg.list_keys() private_keys = gpg.list_keys(True)

  • Correction: Use decrypt_file instead of decrypt for files.

    gpg.decrypt_file("path/to/file")
    

    Note: You can't pass Path arguments to decrypt_file.

Pytest

  • Correction: Remove warning that pytest-random-order can't be used with pytest-xdist.

    The issue was fixed

Python Snippets

  • New: Get common elements of two lists.

    >>> a = ['a', 'b']
    >>> b = ['c', 'd', 'b']
    >>> set(a) & set(b)
    {'b'}
    
  • New: Recursively find files.

    from pathlib import Path
    
    for path in Path("src").rglob("*.c"):
        print(path.name)
    
  • New: Print an exception using the logging module.

    Logging an exception can be done with the module-level function logging.exception() like so:

    import logging
    
    try:
        1 / 0
    except BaseException:
        logging.exception("An exception was thrown!")
    
    ERROR:root:An exception was thrown!
    Traceback (most recent call last):
    File ".../Desktop/test.py", line 4, in <module>
        1/0
    ZeroDivisionError: division by zero
    

    Notes

    • The function logging.exception() should only be called from an exception handler.

    • The logging module should not be used inside a logging handler to avoid a RecursionError.

    It's also possible to log the exception with another log level but still show the exception details by using the keyword argument exc_info=True, like so:

    logging.critical("An exception was thrown!", exc_info=True)
    logging.error("An exception was thrown!", exc_info=True)
    logging.warning("An exception was thrown!", exc_info=True)
    logging.info("An exception was thrown!", exc_info=True)
    logging.debug("An exception was thrown!", exc_info=True)
    
    logging.log(level, "An exception was thrown!", exc_info=True)
    
  • New: Print an exception with the traceback module.

    The traceback module provides methods for formatting and printing exceptions and their tracebacks, e.g. this would print exception like the default handler does:

    import traceback
    
    try:
        1 / 0
    except Exception:
        traceback.print_exc()
    
    Traceback (most recent call last):
      File "C:\scripts\divide_by_zero.py", line 4, in <module>
        1/0
    ZeroDivisionError: division by zero
    

Elasticsearch

  • New: Introduce python elasticsearch library.

    Python elasticsearch is the Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in Python; because of this it tries to be opinion-free and very extendable.

    Installation:

    pip install elasticsearch
    

    Usage:

    from elasticsearch import Elasticsearch
    
    client = Elasticsearch("http://localhost:9200")
    
    +client.indices.get(index="*")
    
    resp = client.search(index="test-index", query={"match_all": {}})
    documents = resp.body["hits"]["hits"]
    
    doc = {"partial_document": "value"}
    resp = client.update(index=INDEX, id=id_, doc=doc)
    

Git

  • New: Revert a commit.

    git revert commit_id
    
  • New: Get interesting stats of the repo.

    Number of commits of the last year per user:

    git shortlog -sne --since="31 Dec 2020" --before="31 Dec 2021"
    

    You can also use git-fame to extract a more detailed report:

    $: git-fame --since 1.year --cost hour --loc ins -w -M -C
    
    | Author          |   hrs |   loc |   coms |   fils |  distribution   |
    |:----------------|------:|------:|-------:|-------:|:----------------|
    | Lyz             |    10 | 28933 |    112 |    238 | 64.1/33.3/75.8  |
    | GitHub Action   |     2 | 16194 |    220 |     73 | 35.9/65.5/23.2  |
    | Alexander Gil   |     2 |     9 |      1 |      1 | 0.0/ 0.3/ 0.3   |
    | n0rt3y5ur       |     2 |     1 |      1 |      1 | 0.0/ 0.3/ 0.3   |
    | Guilherme Danno |     2 |     1 |      1 |      1 | 0.0/ 0.3/ 0.3   |
    | lyz-code        |     2 |     0 |      1 |      0 | 0.0/ 0.3/ 0.0   |
    

    You can use pipx install git-fame to install it.

DevOps

Hardware

CPU

  • New: Installation tips for CPU.

    When installing an AM4 CPU in the motherboard, rotate the CPU so that the small arrow on one of the corners of the chip matches the arrow on the corner of the motherboard socket.

Operating Systems

Linux

Linux Snippets

  • New: Download TS streams.

    Some sites give stream content with small .ts files that you can't download directly. Instead open the developer tools, reload the page and search for a request with extension .m3u8, that gives you the playlist of all the chunks of .ts files. Once you have that url you can use yt-dlp to download it.

qBittorrent

Torrents

  • New: Compare the different torrent clients.

    BitTorrent is a communication protocol for peer-to-peer file sharing (P2P), which enables users to distribute data and electronic files over the Internet in a decentralized manner.

    Each of us seeks something different for a torrent client, thus there is a wide set of software, you just need to find the one that's best for you. In my case I'm searching for a client that:

    • Scales well for many torrents

    • Is robust

    • Is maintained

    • Is popular

    • Is supported by the private trackers: Some torrent clients are banned by the tracker because they don't report correctly to the tracker when canceling/finishing a torrent session. If you use them then a few MB may not be counted towards the stats near the end, and torrents may still be listed in your profile for some time after you have closed the client. Each tracker has their list of allowed clients. Make sure to check them.

    Also, clients in alpha or beta versions should be avoided.

    • Can be easily monitored

    • Has a Python library or an API to interact with

    • Has clear and enough logs

    • Has RSS support

    • Has a pleasant UI

    • Supports categories

    • Can unpack content once it's downloaded

    • No ads

    • Easy to use behind a VPN with IP leakage protection.

    • Easy to deploy

    I don't need other features such as:

    • Preview content
    • Search in the torrent client

    The winner has been qBittorrent

Android

GrapheneOS

  • New: Installation.

    I was not able to follow the web instructions so I had to follow the cli ones.

    Whenever I run a fastboot command it got stuck in < waiting for devices >, so I added the next rules on the udev configuration at /etc/udev/rules.d/51-android.rules

    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0600", OWNER="myuser"
    

    The idProduct and idVendor were deduced from lsusb. Then after a restart everything worked fine.

Arts

Writing

Forking this garden

  • Correction: Update forking instructions.

    I recommend against forking the repository via Github. If you do that, you'll have all the history of my repository, which will make your repository more heavy than it should (as I have a lot of images), and it will make it hard for me to make pull requests to your digital garden.

    Furthermore, you'll always see a message in your repo similar to This branch is 909 commits ahead, 1030 commits behind lyz-code:master. like you can see in this fork. Also if you don't want to keep all the content I've made so far and want to start from scratch then the only thing that is useful for you is the skeleton I've made, and I don't need any attribution or credit for that :P.

    If on the other hand you do want to keep all my content, then wouldn't it be better to just make contributions to this repository instead?

    Therefore the best way to give credit and attribution is by building your garden (the more we are writing the merrier :) ), and then if you want to spread the word that my garden exists within your content then that would be awesome.

    If you end up building your own, remember to add yourself to the digital garden's list.

Video Gaming

Age of Empires

  • New: Introduce the Age of Empires videogame.

Other

  • New: Introduce the Alder tree.

    Alders are trees comprising the genus Alnus in the birch family Betulaceae (like the birch). The genus parts are "al" which means "close by" and "lan" which means "side of the river", so they are trees that grow close to rivers or creeks.

  • Correction: Give more details of the beech tree.

     The leaves of beech trees are elliptic, a little pointy at the end, flat, and with a short petiole. They are big and wide leaves ranging from 4-9 cm long. Very abundant, they have a light green colour with a darker tone and glossy on the upper side.

    The fruit is a small, sharply three-angled nut 10-15 mm long, borne singly or in pairs in soft-spined husks 1.5-2.5 cm long, known as cupules. The husk can have a variety of spine- to scale-like appendages, the character of which is, in addition to leaf shape, one of the primary ways beeches are differentiated. The nuts are edible, though bitter (though not nearly as bitter as acorns) with a high tannin content, and are called beechnuts or beechmast.

    They are big trees easily going between 30 and 45 meters. It looks very different if its isolated or being part of a forest. The first one the branches grow from the middle of the trunk and are horizontal, in the second, the branches go up and start over the half of the trunk. The principal root is very powerful, with very strong secondary roots, developing lateral superficial roots.

    The trunk is right with a grayish-cinder bark, smooth until it's old, usually covered by moss an lichen. Smaller branches are zigzagging with reddish-brown pointy buds.

    The canopy is big, dense, rounded and semi spheric, giving a lot of shadow.

    It grows slow in the first years, being the most active between the tenth and twelve year, reaching it's maximum height when it's twenty five, although it lives around three hundred years.

  • Correction: Give more details of the birch tree.

    The simple leaves are rhomboidal, between 3 and 6 cm, singly or doubly serrate except at the base, feather-veined, petiolate and stipulate. Although they are alternate, many leaves spawn from each side of the branch, making some think that they are not alternate. They often appear in pairs, but these pairs are really borne on spur-like, two-leaved, lateral branchlets.

    The canopy is rounded and irregular giving few shadow.

    The fruit is a small samara, although the wings may be obscure in some species. They differ from the alders in that the female catkins are not woody and disintegrate at maturity, falling apart to release the seeds, unlike the woody, cone-like female alder catkins.

    The bark of all birches is characteristically smooth and white, although in older ones the lower part is usually cracked and takes blackish brown colours. It's marked with long, horizontal lenticels, and often separates into thin, papery plates, especially upon the paper birch.

  • New: How to tell apart the different trees.

    Alder vs Beech:

    Property Beech Alder
    Leaf border flat sparsely toothed
    Leaf form elliptic rounded
    Same colour both sides no (darker and glossy up) yes
    Sticky leafs no yes
    Size 30-45m 10-12m (in Europe)
    Knots on the roots with fungi no yes
    Where they grow everywhere close to rivers or creeks

    Alder vs Birch:

    Property Birch Alder
    Leaf border heavy toothed sparsely toothed
    Leaf form rhomboidal rounded
    Sticky leafs no yes
    Where they grow very close to each other close to rivers or creeks

    Beech vs Birch:

    Property Beech Birch
    Leaf border flat heavy toothed
    Leaf form elliptic rhomboidal
    Size 30-45m 10-15m (in Europe)
    Same colour both sides no (darker and glossy up) yes
    Where they grow everywhere very close to each other