Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ansible_snippets#Ansible add a sleep): Ansible add a sleep
```yaml - name: Pause for 5 minutes to build app cache ansible.builtin.pause: minutes: 5 ``` feat(beautifulsoup#Searching by attribute and value): Searching by attribute and value ```python soup = BeautifulSoup(html) results = soup.findAll("td", {"valign" : "top"}) ``` fix(pydantic#Initialize attributes at object creation): Initialize attributes at object creation `pydantic` recommends [using root validators](pydantic.md#using-root-validators), but it's difficult to undestand how to do it and to debug the errors. You also don't have easy access to the default values of the model. I'd rather use the [overwriting the `__init__` method](pydantic.md#overwriting-the-__init__-method). ```python class fish(BaseModel): name: str color: str def __init__(self, **kwargs): super().__init__(**kwargs) print("Fish initialization successful!") self.color=complex_function() ``` feat(python_snippets#Read file with Pathlib): Read file with Pathlib ```python file_ = Path('/to/some/file') file_.read_text() ``` feat(python_snippets#Get changed time of a file): Get changed time of a file ```python import os os.path.getmtime(path) ``` feat(docker#Installation): Install a specific version of Docker Follow [these instructions](https://docs.docker.com/engine/install/debian/) If that doesn't install the version of `docker-compose` that you want use [the next snippet](https://stackoverflow.com/questions/49839028/how-to-upgrade-docker-compose-to-latest-version): ```bash 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. feat(gardening#Fertilizing with manure): 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). fix(grafana): 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" ``` fix(grafana#Configure datasources): 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](rfmoz/grafana-dashboards#137). feat(zfs#Repair a DEGRADED pool): Repair a DEGRADED pool First let’s offline the device we are going to replace: ```bash zpool offline tank0 ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx ``` Now let us have a look at the pool status. ```bash 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. ```bash 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. ```bash zpool replace tank0 \ ata-WDC_WD2003FZEX-00SRLA0_WD-xxxxxxxxxxxx \ /dev/disk/by-id/ata-TOSHIBA_HDWG180_xxxxxxxxxxxx ``` ```bash 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. ```bash 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](https://madaboutbrighton.net/articles/replace-disk-in-zfs-pool). feat(zfs): Stop a ZFS scrub ```bash zpool scrub -s my_pool ``` feat(linux_snippets#Limit the resources a docker is using): Limit the resources a docker is using You can either use limits in the `docker` service itself, see [1](https://unix.stackexchange.com/questions/537645/how-to-limit-docker-total-resources) and [2](https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html). Or/and you can limit it for each docker, see [1](https://www.baeldung.com/ops/docker-memory-limit) and [2](https://docs.docker.com/config/containers/resource_constraints/). feat(orgmode): Refile from the capture window If you refile from the capture window, [until this issue is solved](joaomsa/telescope-orgmode.nvim#4), 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 feat(python_gnupg): Receive keys from a keyserver ```python import_result = gpg.recv_keys('server-name', 'keyid1', 'keyid2', ...) ``` feat(questionary#Autocomplete answers): Autocomplete answers If you want autocomplete with fuzzy finding use: ```python import questionary from prompt_toolkit.completion import FuzzyWordCompleter questionary.autocomplete( "Save to (q to cancel): ", choices=destination_directories, completer=FuzzyWordCompleter(destination_directories), ).ask() ``` feat(vial): Introduce Vial [Vial](https://get.vial.today/) 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](https://vial.rocks/) you can install it locally through an [AppImage](https://itsfoss.com/use-appimage-linux/) - Download [the latest version](https://get.vial.today/download/) - Give it execution permissions - Add the file somewhere in your `$PATH` On linux you [need to configure an `udev` rule](https://get.vial.today/manual/linux-udev.html). 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): ```bash 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.
- Loading branch information