Skip to content

Instantly share code, notes, and snippets.

@krpeacock
krpeacock / problem.js
Created April 13, 2016 23:08
This could be a way of asking questions
if(I = have.a(problem)) {
one.might: "produce";
a = solution(2, "my " + problem);
}

##Authorization


Authorization Setup

  • take passport_app
  • touch app.js
  • npm init -y
  • npm i -S express jade knex pg passport passport-local body-parser method-override cookie-session morgan locus dotenv bcrypt flash
process.env.NODE_ENV = "test";
const request = require('supertest');
const expect = require('chai').expect;
const app = require('../app');
const knex = require('../db/knex');
beforeEach(done => {
return Promise.all([
knex('sloths').insert({id: 1, name: 'Jerry', age: 4, image: 'https://gifts.worldwildlife.org/gift-center/Images/large-species-photo/large-Three-toed-Sloth-photo.jpg'}),
var App = React.createClass({
getDefaultProps: function() {
console.log("PARENT GETTING DEFAULT PROPS");
return {
foo: "bar"
};
},
getInitialState: function() {
@krpeacock
krpeacock / index.jsx
Created May 10, 2016 16:51
Index to my wedding react page
"use strict";
var Page = React.createClass({
displayName: "Page",
getInitialState: function getInitialState (){
return {
allGuests: [],
guests: []
}
},
@krpeacock
krpeacock / react.jade
Created May 10, 2016 16:53
Generic setup for a react document in Jade
extends ./layout
block content
<div id="container"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.js"></script>
<script src ="https://fb.me/react-15.0.0-rc.1.js"></script>
<script src="https://fb.me/react-dom-15.0.0-rc.1.js"></script>
<script type="text/babel" src="/javascripts/index.jsx"></script>
@krpeacock
krpeacock / guests.js
Created May 10, 2016 16:55
Route handling for react wedding page
var express = require('express')
var router = express.Router({mergeParams: true});
var knex = require('../db/knex');
router.get("/", function(req, res){
res.render("react");
})
router.get('/guests', function(req, res){
knex('guests').orderBy("id", "asc").then(function(guests){
<!DOCTYPE html>
<html lang="en" ng-app="postApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body ng-controller="FirstController">
<form ng-submit="view.submitForm(view.post)" action="javascript:void(0)">
<input type="text" ng-model="view.post.title">
<input type="text" ng-model="view.post.author">
Hello, world!
from flask import Flask, render_template, request, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
# Flask - class used to initialize an app
# render_template - render a template
# request - getting form data via POST request
# redirect - respond with location header
# url_for - shorthand for using function name instead of name of route
from flask_modus import Modus