Monday, August 23, 2021

Python Hints

Python hints

Untrusted target

If you get untrusted cert error when trying to download library because your firewall, you can do this (only if you really trust the source).
python -m pip install --upgrade pip --trusted-host files.pythonhosted.org --trusted-host pypi.org

You can also put the untrusted cert in the location defined by this environment variable: REQUESTS_CA_BUNDLE

Working with venv

1. Create a new environment, this will create a directory named some_name from where you execute this
python -m venv some_name
You should see Include, Lib, and Scripts folders and pyvenv.cfg file in this directory
2. Go into that directory then activate the environment
./Scripts/activate
3. Now you should see (some_name) in from of your prompt. Any python code (and Pip) action taken here is isolated to this venv. 
4. To exit just type deactivate from this directory


Sorting a List of Dictionary

sorted(ListOfDict, key=(lambda item: item['SomeKeyName']))






No comments:

Post a Comment

AWS WAF log4j query

How to query AWS WAF log for log4j attacks 1. Setup your Athena table using this instruction https://docs.aws.amazon.com/athena/latest/ug/wa...