24th November 2022
Coding⚑
Languages⚑
Pytest⚑
-
You can use the
tmp_path
fixture which will provide a temporary directory unique to the test invocation, created in the base temporary directory.tmp_path
is apathlib.Path
object. Here is an example test usage:def test_create_file(tmp_path): d = tmp_path / "sub" d.mkdir() p = d / "hello.txt" p.write_text(CONTENT) assert p.read_text() == CONTENT assert len(list(tmp_path.iterdir())) == 1 assert 0
-
Correction: Deprecate the tmpdir fixture.
Warning: Don't use
tmpdir
usetmp_path
instead becausetmpdir
usespy
which is unmaintained and has unpatched vulnerabilities.
GitPython⚑
- Correction: Deprecate tmpdir in favour of tmp_path.
-
>>> length = 1 >>> print(f'length = {length:03}') length = 001
DevOps⚑
Continuous Integration⚑
-
New: Issues.
- It doesn't yet support admonitions
- You can't ignore some files, nor some part of the file
Operating Systems⚑
Linux⚑
Linux Snippets⚑
-
New: Df and du showing different results.
Sometimes on a linux machine you will notice that both
df
command (display free disk space) anddu
command (display disk usage statistics) report different output. Usually,df
will output a bigger disk usage thandu
.The
du
command estimates file space usage, and thedf
command shows file system disk space usage.There are many reasons why this could be happening:
-
To remove unused
docker
data you can rundocker system prune -a
. This will remove:- All stopped containers
- All networks not used by at least one container
- All images without at least one container associated to them
- All build cache
Sometimes that's not enough, and your
/var/lib/docker
directory still weights more than it should. In those cases:- Stop the
docker
service. - Remove or move the data to another directory
- Start the
docker
service.
In order not to loose your persisted data, you need to configure your dockers to mount the data from a directory that's not within
/var/lib/docker
.
aleph⚑
-
New: Problems accessing redis locally.
If you're with the VPN connected, turn it off.
-
New: PDB behaves weird.
Sometimes you have two traces at the same time, so each time you run a PDB command it jumps from pdb trace. Quite confusing. Try to
c
the one you don't want so that you're left with the one you want. Or put thepdb
trace in a conditional that only matches one of both threads.
elasticsearch⚑
-
New: Get documents that match a string.
bash curl \ -H 'Content-Type: application/json' \ -XPOST "https://localhost:9200/_search" \ -d' { "query": { "query_string": {"query": "test company"} }}'