Skip to content

Instantly share code, notes, and snippets.

View pgolding's full-sized avatar
🎯
Focusing

Oberon Dude pgolding

🎯
Focusing
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgolding
pgolding / embeddings.ipynb
Created February 23, 2024 04:13
Demo of embeddings file sizes for OpenAI Embeddings
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgolding
pgolding / bayesian_testing.py
Last active June 22, 2020 22:12
Bayesian A/B testing implementation in Python
from scipy.stats import beta
from scipy.special import betaln
# based upon https://www.evanmiller.org/bayesian-ab-testing.html#binary_ab_implementation
def prob_B_beats_A(alpha_A, beta_A, alpha_B, beta_B):
total = 0
for i in range(0,alpha_B-1):
total += np.exp(betaln(alpha_A + i, beta_B + beta_A) - \
np.log(beta_B + i) - betaln(1+i, beta_B) - betaln(alpha_A, beta_A))
return total
@pgolding
pgolding / snippet.js
Last active February 10, 2020 22:07
# Instapage Snippet
// ** THIS VARIATION DOES NOT USE A FORM **
// The two possible endpoints for production and staging
var production_endpoint = 'https://prosper.com';
var staging_endpoint = 'https://www.stage.circleone.com';
// The current endpoint.
// For staging set this to: current_endpoint = staging_endpoint + '/borrower/api/v1'
// For production set this to: current_endpoint = production_endpoint + '/borrower/api/v1'
var current_endpoint = staging_endpoint + '/borrower/api/v1';
// The APIs that we need to call at the base current_endpoint
var alt_key_api = current_endpoint + '/user/alt_key/';
@pgolding
pgolding / snippet.js
Created February 4, 2020 21:23
# Instapage Snippet
// The two possible endpoints for production and staging
var production_endpoint = 'https://prosper.com';
var staging_endpoint = 'https://www.stage.circleone.com';
// The current endpoint.
// For staging set this to: current_endpoint = staging_endpoint + '/borrower/api/v1'
// For production set this to: current_endpoint = production_endpoint + '/borrower/api/v1'
var current_endpoint = staging_endpoint + '/borrower/api/v1';
// The APIs that we need to call at the base current_endpoint
var alt_key_api = current_endpoint + '/user/alt_key/';
var slug_api = current_endpoint + '/content?wordpress_slug=legalfootnote';
@pgolding
pgolding / snippet.js
Created February 4, 2020 21:23
# Instapage Snippet
// The two possible endpoints for production and staging
var production_endpoint = 'https://prosper.com';
var staging_endpoint = 'https://www.stage.circleone.com';
// The current endpoint.
// For staging set this to: current_endpoint = staging_endpoint + '/borrower/api/v1'
// For production set this to: current_endpoint = production_endpoint + '/borrower/api/v1'
var current_endpoint = staging_endpoint + '/borrower/api/v1';
// The APIs that we need to call at the base current_endpoint
var alt_key_api = current_endpoint + '/user/alt_key/';
var slug_api = current_endpoint + '/content?wordpress_slug=legalfootnote';
@pgolding
pgolding / snippet.js
Created February 4, 2020 21:23
# Instapage Snippet
// The two possible endpoints for production and staging
var production_endpoint = 'https://prosper.com';
var staging_endpoint = 'https://www.stage.circleone.com';
// The current endpoint.
// For staging set this to: current_endpoint = staging_endpoint + '/borrower/api/v1'
// For production set this to: current_endpoint = production_endpoint + '/borrower/api/v1'
var current_endpoint = staging_endpoint + '/borrower/api/v1';
// The APIs that we need to call at the base current_endpoint
var alt_key_api = current_endpoint + '/user/alt_key/';
var slug_api = current_endpoint + '/content?wordpress_slug=legalfootnote';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgolding
pgolding / readme.md
Last active August 17, 2023 08:34
How to use pyjwt to decode RS256-signed JWT tokens (e.g. for Auth0) and run it on AWS Lambda with Python 3.6 (e.g. custom authorizers for serverless)

PyJWT with Python AWS Lambda Functions (LF)

If you are using Auth0 (or some OAuth authorization service) then you will most likely be interested in using JWT tokens via some kind of grant. Auth0 discusses how to call an API with such a token.

Perhaps you wish to use a custom authorizer for your serverless project.

To do so, you must write code to decode the JWT token before creating a policy (or not) to grant invoke permissions on your LF. Per various recommendations, the best method to protect your JWT tokens is to use RS256 signing.

However, if you are using pyjwt to decode RS256 tokens, this library depends upon cryptography and that, in turn, has compiled dependencies

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.