Skip to content

Instantly share code, notes, and snippets.

View jaybaker's full-sized avatar

Jay Baker jaybaker

View GitHub Profile
@jaybaker
jaybaker / load_secret.py
Last active April 23, 2023 16:28
Load Google Cloud Secrets from python notebook
"""
This gist is intended to be loaded into a python notebook via wget.
It is used to retrieve a secret from the google cloud.
See https://cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-python
Usage:
1. !wget
2. !pip install google-cloud-secret-manager
3. import load_secret
# concat files but just keep header from first file
awk '
FNR==1 && NR!=1 { while (/^header/) getline; }
1 {print}
' file*.txt >all.txt
import os
GB1 = 1024*1024*1024 # 1GB
size = 50 # desired size in GB
with open('large_file', 'wb') as fout:
for i in range(size + 1):
fout.write(os.urandom(GB1))
@jaybaker
jaybaker / NN Training Recipe.md
Created June 22, 2019 23:57
A recipe for ML model training

Neural Network Training Recipe

I loved this "recipe" from Andrej Karpathy. Read the whole thing at the source. I summarized the key points.

  1. Make sure to analyze the data
  2. Set up the end-to-end training/evaluation skeleton + get dumb baselines
  3. Overfit
  4. Regularize
  5. Tune
@jaybaker
jaybaker / Weekly Review.md
Last active June 5, 2019 14:16
Weekly Review

A brief review of the last week or so can be a useful habit.

Add some regimen to make this weekly.

That review may include items such as these.

  1. What was the most enjoyable work activity of the week?

  2. What was the most boring or dreary?

# from http://www.rackspace.com/knowledge_center/article/generate-a-csr-with-openssl
# create key
openssl genrsa -out ~/domain.com.ssl/domain.com.key 2048
# create csr
openssl req -new -sha256 -key ~/domain.com.ssl/domain.com.key -out ~/domain.com.ssl/domain.com.csr
@jaybaker
jaybaker / catchall.py
Created October 31, 2015 13:23
Flask catch-all url
# Taken from http://flask.pocoo.org/snippets/57/
from flask import Flask
app = Flask(__name__)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return 'You want path: %s' % path
if __name__ == '__main__':