Skip to content

39th Week of 2023

Life Management

Task Management

Org Mode

  • New: Refile from the capture window.

    If you refile from the capture window, until this issue is solved, your task will be refiled but the capture window won't be closed.

    Be careful that it only refiles the first task there is, so you need to close the capture before refiling the next

Coding

Languages

Libraries

  • New: Receive keys from a keyserver.

    import_result = gpg.recv_keys('server-name', 'keyid1', 'keyid2', ...)
    

BeautifulSoup

  • New: Searching by attribute and value.

    soup = BeautifulSoup(html)
    results = soup.findAll("td", {"valign" : "top"})
    
  • New: Install a specific version of Docker.

    Follow these instructions

    If that doesn't install the version of docker-compose that you want use the next snippet:

    VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')
    DESTINATION=/usr/local/bin/docker-compose
    sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
    sudo chmod 755 $DESTINATION
    

    If you don't want the latest version set the VERSION variable.

Python Snippets

Pydantic

questionary

  • New: Autocomplete answers.

    If you want autocomplete with fuzzy finding use:

    import questionary
    from prompt_toolkit.completion import FuzzyWordCompleter
    
    questionary.autocomplete(
        "Save to (q to cancel): ",
        choices=destination_directories,
        completer=FuzzyWordCompleter(destination_directories),
    ).ask()
    

DevOps

Infrastructure as Code

Ansible Snippets

  • New: Ansible add a sleep.

    - name: Pause for 5 minutes to build app cache
      ansible.builtin.pause:
        minutes: 5
    

Storage

OpenZFS

  • New: Repair a DEGRADED pool.

    First let’s offline the device we are going to replace:

    zpool offline tank0 ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx
    

    Now let us have a look at the pool status.

    zpool status
    
    NAME                                            STATE     READ WRITE CKSUM
    tank0                                           DEGRADED     0     0     0
      raidz2-1                                      DEGRADED     0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx            ONLINE       0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx            ONLINE       0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx            ONLINE       0     0     0
        ata-WDC_WD80EFZX-68UW8N0_xxxxxxxx           ONLINE       0     0     0
        ata-TOSHIBA_HDWG180_xxxxxxxxxxxx            ONLINE       0     0     0
        ata-TOSHIBA_HDWG180_xxxxxxxxxxxx            ONLINE       0     0     0
        ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx  OFFLINE      0     0     0
        ata-ST4000VX007-2DT166_xxxxxxxx             ONLINE       0     0     0
    

    Sweet, the device is offline (last time it didn't show as offline for me, but the offline command returned a status code of 0).

    Time to shut the server down and physically replace the disk.

    shutdown -h now
    

    When you start again the server, it’s time to instruct ZFS to replace the removed device with the disk we just installed.

    zpool replace tank0 \
        ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx \
        /dev/disk/by-id/ata-TOSHIBA_HDWG180_xxxxxxxxxxxx
    
    zpool status tank0
    
    pool: main
    state: DEGRADED
    status: One or more devices is currently being resilvered.  The pool will
            continue to function, possibly in a degraded state.
    action: Wait for the resilver to complete.
      scan: resilver in progress since Fri Sep 22 12:40:28 2023
            4.00T scanned at 6.85G/s, 222G issued at 380M/s, 24.3T total
            54.7G resilvered, 0.89% done, 18:28:03 to go
    NAME                                              STATE     READ WRITE CKSUM
    tank0                                             DEGRADED     0     0     0
      raidz2-1                                        DEGRADED     0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx              ONLINE       0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx              ONLINE       0     0     0
        ata-TOSHIBA_HDWN180_xxxxxxxxxxxx              ONLINE       0     0     0
        ata-WDC_WD80EFZX-68UW8N0_xxxxxxxx             ONLINE       0     0     0
        ata-TOSHIBA_HDWG180_xxxxxxxxxxxx              ONLINE       0     0     0
        ata-TOSHIBA_HDWG180_xxxxxxxxxxxx              ONLINE       0     0     0
        replacing-6                                   DEGRADED     0     0     0
          ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx  OFFLINE      0     0     0
          ata-TOSHIBA_HDWG180_xxxxxxxxxxxx            ONLINE       0     0     0  (resilvering)
        ata-ST4000VX007-2DT166_xxxxxxxx               ONLINE       0     0     0
    

    The disk is replaced and getting resilvered (which may take a long time to run (18 hours in a 8TB disk in my case).

    Once the resilvering is done; this is what the pool looks like.

    zpool list
    
    NAME      SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
    tank0    43.5T  33.0T  10.5T     14.5T     7%    75%  1.00x  ONLINE  -
    

    If you want to read other blogs that have covered the same topic check out 1.

  • New: Stop a ZFS scrub.

    zpool scrub -s my_pool
    

Monitoring

Grafana

  • Correction: Improve installation method.

    Add more configuration values such as:

    GF_SERVER_ENABLE_GZIP="true"
    
    GF_AUTH_GENERIC_OAUTH_ALLOW_ASSIGN_GRAFANA_ADMIN="true"
    
    GF_LOG_MODE="console file"
    GF_LOG_LEVEL="info"
    
  • Correction: Warning when configuring datasources.

    Be careful to set the timeInterval variable to the value of how often you scrape the data from the node exporter to avoid this issue.

Operating Systems

Linux

Linux Snippets

Arts

Maker

Vial

  • New: Introduce Vial.

    Vial is an open-source cross-platform (Windows, Linux and Mac) GUI and a QMK fork for configuring your keyboard in real time.

    Even though you can use a web version you can install it locally through an AppImage

    • Download the latest version
    • Give it execution permissions
    • Add the file somewhere in your $PATH

    On linux you need to configure an udev rule.

    For a universal access rule for any device with Vial firmware, run this in your shell while logged in as your user (this will only work with sudo installed):

    export USER_GID=`id -g`; sudo --preserve-env=USER_GID sh -c 'echo "KERNEL==\"hidraw*\", SUBSYSTEM==\"hidraw\", ATTRS{serial}==\"*vial:f64c2b3c*\", MODE=\"0660\", GROUP=\"$USER_GID\", TAG+=\"uaccess\", TAG+=\"udev-acl\"" > /etc/udev/rules.d/99-vial.rules && udevadm control --reload && udevadm trigger'
    

    This command will automatically create a udev rule and reload the udev system.

Gardening

  • New: Fertilizing with manure.

    Manure is one of the best organic fertilizers for plants. It's made by the accumulation of excrements of bats, sea birds and seals and it usually doesn't contain additives or synthetic chemical components.

    This fertilizer is rich in nitrogen, phosphorus and potassium, which are key minerals for the growth of plants. These components help the regeneration of the soil, the enrichment in terms of nutrients and also acts as fungicide preventing plagues.

    Manure is a fertilizer of slow absorption, which means that it's released to the plants in an efficient, controlled and slow pace. That way the plants take the nutrients when they need them.

    The best moment to use it is at spring and depending on the type of plant you should apply it between each month and a half and three months. It's use in winter is not recommended, as it may burn the plant's roots.

    Manure can be obtained in dust or liquid state. The first is perfect to scatter directly over the earth, while the second is better used on plant pots. You don't need to use much, in fact, with just a pair of spoons per pot is enough. Apply it around the base of the plant, avoiding it's touch with leaves, stem or exposed roots, as it may burn them. After you apply them remember to water them often, keep in mind that it's like a heavy greasy sandwich for the plants, and they need water to digest it.

    For my indoor plants I'm going to apply a small dose (one spoon per plant) at the start of Autumn (first days of September), and two spoons at the start of spring (first days of March).