What worked for me was updating the “Refresh Rate” from 30HZ to 60HZ:
Continue readingUseful Commands for Cleaning up Storage
To sort folders by their size, recursively:
$ du -h | sort -h
Then, to delete any folder of the name to_delete
:
$ rm -rf `find . -type d -name to_delete`
How to Run Long Production Scripts in the Background
This is not a happy situation to begin with, but what if you have to? Someone has to do the dirty job. In order for you to not have your laptop connected to the production environment for 10 hours just to run a job, you need:
Continue readingHow To Bypass Chrome’s “Your connection is not private” Screen
Two steps [1]:
- Click on the page, anywhere
- Type
thisisunsafe
Funny that Google doesn’t provide a button anywhere on the page for this. Guess you’ll only be able to find a solution if you know how to “Google”.
Poetry equivalent of `python setup.py develop`
To use the package you’re working on directly in the project itself. Go to the directory where your package is being developed, where the pyproject.toml
file resides:
poetry install
poetry shell
I fought days with it and it ended up being that simple. *Facepalm*.
If necessary, remove the previously created venv first.
To use it in a different project though, you’d probably need something like this.
What Takes 1 Second To Execute in Python
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?
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.