This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file may be used to create an environment using: | |
# $ conda create --name <env> --file <this file> | |
# platform: osx-64 | |
beautifulsoup4=4.6.3=py36_0 | |
ca-certificates=2018.03.07=0 | |
certifi=2018.10.15=py36_0 | |
libcxx=4.0.1=h579ed51_0 | |
libcxxabi=4.0.1=hebd6815_0 | |
libedit=3.1.20170329=hb402a30_2 | |
libffi=3.2.1=h475c297_4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const createComparisonSignature = (body) => { | |
const hmac = crypto.createHmac('sha1', process.env.OCTO_WIZARD_HOOK_SECRET); | |
const self_signature = hmac.update(JSON.stringify(body)).digest('hex'); | |
return `sha1=${self_signature}`; // shape in GitHub header | |
} | |
const compareSignatures = (signature, comparison_signature) => { | |
const source = Buffer.from(signature); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request, redirect, render_template, session, flash | |
import cgi | |
from app import app, db | |
from models import Movie, User | |
# a list of movie names that nobody should have to watch | |
terrible_movies = [ | |
"Gigli", | |
"Star Wars Episode 1: Attack of the Clones", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mapAttributes = (model, { fieldNodes }) => { | |
const columns = new Set(Object.keys(model.rawAttributes)); // to prevent column doesnt exist error | |
const rawAttributes = fieldNodes[0].selectionSet.selections.map(({ name: { value } }) => value); | |
return rawAttributes.filter(attribute => columns.has(attribute)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mapAttributes = (model, { fieldNodes }) => { | |
// get the fields of the Model (columns of the table) | |
const columns = new Set(Object.keys(model.rawAttributes)); | |
const requested_attributes = fieldNodes[0].selectionSet.selections | |
.map(({ name: { value } }) => value); | |
// filter the attributes against the columns | |
return requested_attributes.filter(attribute => columns.has(attribute)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_name_as_caps(name): | |
""" | |
raise ValueError and pass respective message | |
""" | |
if name.upper() != name: | |
raise ValueError("Name is not capitalized") | |
return name | |
validators = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you call conda deactivate this script will be executed | |
# removes the environment variables automatically on environment deactivation | |
# this goes in /anaconda3/envs/ENVIRONMENT-NAME/etc/conda/deactivate.d | |
unset DEBUG SECRET_KEY DB_HOST DB_PORT DB_NAME DB_USER DB_PASSWORD STATIC_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you call conda activate <env name> this script will be executed | |
# loads the environment variables automatically on environment activation | |
# this goes in /anaconda3/envs/ENVIRONMENT-NAME/etc/conda/activate.d | |
# note: you must create etc/conda in the environment directory to place this file | |
# for windows users: https://conda.io/docs/user-guide/tasks/manage-environments.html#windows | |
# spread across multiple lines for readability | |
# you can write them space-separated in one export statement if you want | |
export DEBUG='True' # "converted" to boolean in settings.py line 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python | |
# the PROJECT-DIRECTORY is the one with settings.py and wsgi.py | |
entrypoint: gunicorn -b :$PORT PROJECT-DIRECTORY.wsgi # specific to a GUnicorn HTTP server deployment | |
env: flex # for Google Cloud Flexible App Engine | |
# any environment variables you want to pass to your application. | |
# accessible through os.environ['VARIABLE_NAME'] | |
env_variables: | |
# the secret key used for the Django app (from PROJECT-DIRECTORY/settings.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
DEBUG = os.environ['DEBUG'] == 'True' # environment vars are strings. "convert" to boolean. lol, Python | |
SECRET_KEY = os.environ['SECRET_KEY'] | |
ALLOWED_HOSTS = [ | |
# TODO: add your Google Cloud Project-ID here | |
'PROJECT-ID.appspot.com', # must add the app engine (project-id) domain here |