Skip to content

Instantly share code, notes, and snippets.

View w3cj's full-sized avatar
🌱

CJ w3cj

🌱
View GitHub Profile
@w3cj
w3cj / spa-notes.md
Last active October 16, 2018 10:34
  • What does MVC stand for? What is MVC?
    • Model, View, Controller
    • Pattern - Design Pattern
    • A way to present information to a user
    • A way to seperate an application
      • Separates an application into 3 parts
      • Allow different information to be accessed by different
    • Controller manipulates Model
    • View - view and input - user interaction
app.get('/search/:location/:job', (request, response) => {
const { location, job } = request.params;
const cl = `https://${location}.craigslist.org/search/jjj?query=${job}`;
const reddit = `https://www.reddit.com/r/jobbit/search.json?q=${job}&restrict_sr=1`;
Promise.all([
fetch(cl)
.then(response => response.text()),
fetch(reddit)
<template>
<div class="container">
<div v-if="alertMessage" class="alert alert-secondary invisible" role="alert">{{alertMessage}}</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Example Chat</div>
<div class="panel-body">
<ul>
process.on('uncaughtException', (error) => {
console.log('Uncaught Exception:', error);
});
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at:', p, 'reason:', reason);
});
router.post('/signup', async (req, res, next) => {
if (validUser(req.body)) {
const user = await User.getOneByEmail(req.body.email);
if (!user) {
const hash = await bcrypt.hash(req.body.password, 5);
const user = {
email: req.body.email,
password: hash,
created_at: new Date()
};
const jwt = require('jsonwebtoken');
const payload = {
id: 2,
email: '[email protected]'
};
const token_secret = 'keyboard_cat';
jwt.sign(payload, token_secret, { expiresIn: '1h' }, (err, token) => {
const express = require('express');
const app = express();
// app.use === generic, will be called for every request
app.use((req, res, next) => {
console.log(req.originalUrl, 'Time:', new Date());
req.time = new Date();
next();
});

Heroku Cheet Sheet

heroku login # login once
heroku create [name] # Initializes heroku app and adds remote.
heroku addons:create heroku-postgresql # add a postgres db addon to your heroku app
heroku logs [--tail] # Shows heroku server terminal
heroku pg:psql # connect to heroku addon database server
heroku config # shows heroku environment variables
 - heroku config:set clown=fiesta # set a config variable
@w3cj
w3cj / app.js
Last active May 15, 2017 17:46
Disable buttons and show loading images/progress bars/ during long running activities.
$(appReady);
function appReady() {
setLoading(false);
$('form').submit(sendMessage);
}
let progressInterval = null;
function setLoading(isLoading) {