Skip to content

Instantly share code, notes, and snippets.

View loopDelicious's full-sized avatar
🌵

Joyce Lin loopDelicious

🌵
View GitHub Profile
@loopDelicious
loopDelicious / bcrypt.py
Created June 18, 2016 21:19
salt and hash passwords
import bcrypt
class User(db.Model):
"""User of website."""
__tablename__ = "users"
user_id = db.Column(db.Integer, autoincrement=True, primary_key=True)
email = db.Column(db.String(70), nullable=False)
password_hash = db.Column(db.String(60), nullable=False)
@loopDelicious
loopDelicious / Mapbox example
Created June 21, 2016 07:10
Mapbox API formatting
import os
accessToken = os.environ["MAPBOX_API_KEY"]
@app.route('/route_directions')
def get_directions_geojson():
"""Get directions via Mapbox Directions API with all the waypoints in the session."""
waypoints = session['waypoints']
route_list = []
module.exports = {
entry: "./app/components/Main.js",
output: {
filename: "public/bundle.js"
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
<!doctype HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Getting Started with React and Webpack</title>
</head>
<body>
<div id="app"></div>
var React = require('react');
var ReactDOM = require('react-dom');
var Main = React.createClass({
render: function() {
return (
<div>
Hello World
</div>
)
@loopDelicious
loopDelicious / mlab.js
Last active November 23, 2016 20:22
CRUD example endpoints
var express = require('express');
var request = require('request');
var bodyParser = require('body-parser');
var key = require('../secrets.js');
var app = express();
// allow CORS access
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
// Load the JSON Schema
const customerSchema = JSON.parse(environment.customerSchema);
// Test whether the response matches the schema
var customer = JSON.parse(responseBody);
tests["Customer is valid"] = tv4.validate(customer, customerSchema);
var secret = require('./secrets.js');
module.exports = {
"collections": [
{
"from": "swagger",
"to": "postman-collection",
"name": "Swagger Petstore",
"collection_uid": "1559979-81f30228-c4e1-8a05-948a-da9cc9bd07db",
"collection_id": "81f30228-c4e1-8a05-948a-da9cc9bd07db"
var fs = require('fs'),
Converter = require('swagger2-postman2-converter'),
request = require('request'),
config = require('./config.js');
// ###############################################
// define functions to handle conversion and update collection
@loopDelicious
loopDelicious / .travis.yml
Last active December 12, 2019 14:17
Integrate API tests with Postman, Newman, and Travis CI
language: node_js
node_js:
- "8.2.1"
install:
- npm install newman
before_script:
- node --version
- npm --version