I got curious about what actually is a blocker in terms of time complexity, for python. I’ve always known that the smaller the complexity the better, but it’s never quantitative. How bad is n^2
? How bad is n^n
? How much of an improvement is sqrt(n)
or log(n)
? What is outrageous to write and is absolutely no-go?
Author Archives: lucia
How To Install Non Tagged Version of Pip Packages
Either with pip:
pip install git+https://github.com/psf/black.git@1aa4d5b
Or with pipx, which looks like a python equivalent of npx, and allows direct runs without installation, or for multiple versions to co-exist:
pipx install git+https://github.com/psf/black.git@1aa4d5b
Ref: [1]
How to Set pytest-vcr to autouse=True
A bit of a hack. So that whenever there is a request, its response will be recorded:
@pytest.fixture(autouse=True)
def stripe_vcr(vcr, request):
filename = f"{request.function.__module__}/{request.node.name}.yaml"
with vcr._use_cassette(path=filename):
yield
https://pytest-vcr.readthedocs.io/en/latest/configuration/#vcr
SQLAlchemy: Difference between Flush and Commit
In simple terms:
- Similarity: after both
flush
andcommit
, later queries will be able to retrieve these changes. - Difference:
flush()
changes are in a pending state (no db statements are issued yet), and can be undone byrollback()
; commits are persisted to db and non-reversible.
Why use flush:
- To have atomicity–making sure that a group of transactions either all succeed or all fail.
Expected — Waiting for status to be reported
Github actions getting stuck in limbo, never starting. No fear! There is a solution!
Continue readingAn error has occurred: InvalidManifestError
Error running pre-commit:
Type tag 'jupyter' is not recognized. Try upgrading identify and pre-commit?
Continue reading Python Function Fun Facts
A string identifier is attached to every function at creation time
- Which is nice for debug:
>>> dance.__name__
'dance'
Functions capture local state
- Just like JavaScript, (lexical) closure:
- A closure remembers the values from its enclosing scope when it was created
To check whether something is callable
- Objects can be made callable, by being assigned function as value
- So, to check whether an object is callable:
>>> callable(foo)
True/False
Benefit of functions being first class
- We are able to abstract and pass around behaviours
JWT Apple Signin Errors: raise ValueError(“Could not deserialize key data.”)
2 Errors that were painful to debug.
Continue readingHow to Reset Docker Container DB
Sometimes data is corrupted, and you just want to nuke the whole world and start a new life. In which case do:
$ docker container prune
$ docker volume prune