Associate a new Authenticator device to a Microsoft account

Go to https://mysignins.microsoft.com/security-info and Add sign-in method

Fixing Process finished with exit code 138 (interrupted by signal 10: SIGBUS) when debugging in PyCharm

Apparently this has something to do with the Cython optimizations. Disable them by adding PYDEVD_USE_CYTHON=NO;PYDEVD_USE_FRAME_EVAL=NO to your run configuration.

– via YouTrack

Linux directory ACL write permissions

Give an admin user write permissions to a directory, without making them owner of the directory and without giving all other users write permissions. So no chown stuff.

I’ve used the ACL tools, setfacl and getfacl

# install the ACL tools if they're not installed
sudo apt-get update
sudo apt-get install acl

# check existing entries
getfacl /mydir/mysubdir

# set it as default for new items
sudo setfacl -d -m u:myusername:rwx /mydir/mysubdir

# and apply it recursively
sudo setfacl -R -m u:myusername:rwx /mydir/mysubdir

Restart mlflow ui

A significant number of times, when closing MLFlow UI with Ctrl+C, the port will remain occupied and you won’t be able to start a new instance of the UI. Or, to be exact, you will be able to start it but nothing will happen when opening up localhost:5000.

Ways to fix this:

  • lsof -iTCP -sTCP:LISTEN -n -P and check which processes listen to port 5000, then pkill -15 <PID>
  • Or pkill -f gunicorn
  • Or, ps -A | grep gunicorn then kill <PID>

Decode the ContentMD5 hash set by Azure Storage Explorer when uploading files

echo "<ContentMD5>" | base64 --decode | xxd -p

# compare it with
md5 <your_file>

Setting up mitmproxy and monitoring i.e. OpenAI API Calls

A simplified version of Hamel’s opinionated setup.

  • Download and install mitmproxy using something like brew install mitmproxy
  • Run mitmweb, to start the proxy on port 8080 and the ui on 8081
  • Download the .pem certificate from http://mitm.it so you can make https://* api calls
import os, requests
os.environ['HTTP_PROXY']='http://127.0.0.1:8080'
os.environ['HTTPS_PROXY']='https://127.0.0.1:8080'

requests.get('http://mit.it') # just to try it out, you can also make sure that it actually links to `cert/pem`
pem_content = requests.get('http://mitm.it/cert/pem').text

# write the certificate to your home directory
with open(os.path.expanduser('~/mitm.pem'), 'w') as f:
    f.write(pem_content)
  • Use the cert and make all the https:// api calls you like
os.environ['REQUESTS_CA_BUNDLE'] = os.path.expanduser('~/mitm.pem')
os.environ['SSL_CERT_FILE'] = os.path.expanduser('~/mitm.pem')

requests.get('https://google.com')

Copy-pasteable snippet for impromptu monitoring

Don’t forget to fire up mitmweb first.

import os
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:8080'
os.environ['HTTPS_PROXY'] = 'https://127.0.0.1:8080'
os.environ['REQUESTS_CA_BUNDLE'] = os.path.expanduser('~/mitm.pem')
os.environ['SSL_CERT_FILE'] = os.path.expanduser('~/mitm.pem')