13th February 2023
Coding⚑
Languages⚑
PDM⚑
-
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
[tool.pdm.build] setup-script = "build.py"In the `build.py` 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 Example: ```python def build(src, dst): target_file = os.path.join(dst, "mypackage/myfile.txt") os.makedirs(os.path.dirname(target_file), exist_ok=True) download_file_to(dst)
The generated file will be copied to the resulted wheel with the same hierarchy, you need to create the parent directories if necessary.
rich⚑
-
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") print(tree)
With only a single
Tree
instance this will output nothing more than the text “Rich Tree”. Things get more interesting when we calladd()
to add more branches to theTree
. The following code adds two more branches:tree.add("foo") tree.add("bar") print(tree)
The
tree
will now have two branches connected to the original tree with guide lines.When you call
add()
a newTree
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") baz_tree.add("[red]Red").add("[green]Green").add("[blue]Blue") print(tree)
DevOps⚑
Automating Processes⚑
cruft⚑
-
Correction: Suggest to use copier instead.
copier looks a more maintained solution nowadays.
Authentication⚑
Authentik⚑
- 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 = authentik_group.admins.id order = 0 }
Operating Systems⚑
Linux⚑
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 withapt-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.bash fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=testfio --bs=4k --iodepth=64 --size=8G --readwrite=randrw --rwmixread=75