Skip to content

7th Week of 2023




  • New: Custom file generation.

    During the build, you may want to generate other files or download resources from the internet. You can achieve this by the setup-script build configuration:

    ``toml [] setup-script = ""

    In the `` script, pdm-pep517 looks for a build function and calls it with two arguments:
    * `src`: the path to the source directory
    * `dst`: the path to the distribution directory
    def build(src, dst):
        target_file = os.path.join(dst, "mypackage/myfile.txt")
        os.makedirs(os.path.dirname(target_file), exist_ok=True)

    The generated file will be copied to the resulted wheel with the same hierarchy, you need to create the parent directories if necessary.


  • New: List the recipients that can decrypt a file.

    def list_recipients(self, path: Path) -> List['GPGKey']:
        """List the keys that can decrypt a file.
           path: Path to the file to check.
        keys = []
        for short_key in self.gpg.get_recipients_file(str(path)):
        return keys
    feat(requests#Use a proxy): Use a proxy

    http_proxy  = ""
    https_proxy = ""
    ftp_proxy   = ""
    proxies = {
      "http"  : http_proxy,
      "https" : https_proxy,
      "ftp"   : ftp_proxy
    r = requests.get(url, headers=headers, proxies=proxies)


  • New: Tree console view.

    Rich has a Tree class which can generate a tree view in the terminal. A tree view is a great way of presenting the contents of a filesystem or any other hierarchical data. Each branch of the tree can have a label which may be text or any other Rich renderable.

    The following code creates and prints a tree with a simple text label:

    from rich.tree import Tree
    from rich import print
    tree = Tree("Rich Tree")

    With only a single Tree instance this will output nothing more than the text “Rich Tree”. Things get more interesting when we call add() to add more branches to the Tree. The following code adds two more branches:


    The tree will now have two branches connected to the original tree with guide lines.

    When you call add() a new Tree instance is returned. You can use this instance to add more branches to, and build up a more complex tree. Let’s add a few more levels to the tree:

    baz_tree = tree.add("baz")


  • New: Solve element isn't clickable in headless mode.

    There are many things you can try to fix this issue. Being the first to configure the driver to use the full screen. Assuming you're using the undetectedchromedriver:

    import undetected_chromedriver.v2 as uc
    options = uc.ChromeOptions()
    driver = uc.Chrome(options=options)

    If that doesn't solve the issue use the next function:

    def click(driver: uc.Chrome, xpath: str, mode: Optional[str] = None) -> None:
        """Click the element marked by the XPATH.
            driver: Object to interact with selenium.
            xpath: Identifier of the element to click.
            mode: Type of click. It needs to be one of [None, position, wait]
        The different ways to click are:
        * None: The normal click of the driver.
        * wait: Wait until the element is clickable and then click it.
        * position: Deduce the position of the element and then click it with a javascript script.
        if mode is None:
           driver.find_element(By.XPATH, xpath).click()
        elif mode == 'wait':
            WebDriverWait(driver, 20).until(
                EC.element_to_be_clickable((By.XPATH, xpath))
        elif mode == 'position':
            element = driver.find_element(By.XPATH, xpath)
            driver.execute_script("arguments[0].click();", element)


Automating Processes


  • Correction: Suggest to use copier instead.

    copier looks a more maintained solution nowadays.



  • Correction: Configure the invitation flow with terraform.
  • New: Hide and application from a user.

    Application access can be configured using (Policy) Bindings. Click on an application in the applications list, and select the Policy / Group / User Bindings tab. There you can bind users/groups/policies to grant them access. When nothing is bound, everyone has access. You can use this to grant access to one or multiple users/groups, or dynamically give access using policies.

    With terraform you can use authentik_policy_binding, for example:

    resource "authentik_policy_binding" "admin" {
      target = authentik_application.gitea.uuid
      group  =
      order  = 0

Operating Systems


Linux Snippets

  • New: Measure the performance, IOPS of a disk.

    To measure disk IOPS performance in Linux, you can use the fio tool. Install it with

    apt-get install fio

    Then you need to go to the directory where your disk is mounted. The test is done by performing read/write operations in this directory.

    To do a random read/write operation test an 8 GB file will be created. Then fio will read/write a 4KB block (a standard block size) with the 75/25% by the number of reads and writes operations and measure the performance.

    fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=testfio --bs=4k --iodepth=64 --size=8G --readwrite=randrw --rwmixread=75

Last update: 2023-02-20