Skip to content

Instantly share code, notes, and snippets.

@michaelneale
Created December 30, 2021 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneale/f870c2ac1de88220737513dee3010b97 to your computer and use it in GitHub Desktop.
Save michaelneale/f870c2ac1de88220737513dee3010b97 to your computer and use it in GitHub Desktop.

Explain code

This uses AI to read and try and understand the code, and explain it back to you:

example:

curl --request POST --header 'Content-Type: application/json' \
--url https://us-east1-micprojects.cloudfunctions.net/ai-code-explainer 
--data '{"code":"    history = model.fit(X_train, y_train, epochs=100, batch_size=32, validation_split=0.1,\ncallbacks=[keras.callbacks.EarlyStopping(monitor='val_loss', patience=3, mode='min')], shuffle=False)\nprint(model.evaluate(X_test, y_test))"}'

Sample response:

The model is trained using the training data, and the validation data is used to check the accuracy of the model. The model is trained for 100 epochs, with a batch size of 32 and 10 percent of the data being used for validation. The early stopping callback is used to stop training when the validation loss has not decreased for 3 epochs.

Security source code scanner (SAST)

Using AI with GPT-3 and codex and more to scan for problems. Examples:

curl --request POST --header 'Content-Type: application/json' 
--url https://us-east1-micprojects.cloudfunctions.net/ai-security-scan  
-d '{"code": "class Log:\ndef __init__(self, path):\n        dirname = os.path.dirname(path)\n       os.makedirs(dirname, exist_ok=True)\n "}'

Sample response:

The code is vulnerable to directory traversal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment