Skip to content

Instantly share code, notes, and snippets.

View harrisonmalone's full-sized avatar

Harrison Malone harrisonmalone

View GitHub Profile
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const myUniqueValidator = async (username) => {
const doc = await User.findOne({username: username})
if (doc) {
return false
} else {
return true
}
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const myValidator = (username) => {
return username === "harrison"
}
const userSchema = new Schema({
username: {
type: String,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="characters"></div>
@harrisonmalone
harrisonmalone / webpack.config.js
Last active October 23, 2019 23:40
this was my webpack config for a webpack react deployment, theres an index.html in build and in the root directory, i think one of them is automatically created
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/App.js',
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '/',
filename: 'bundle.js'

Sequelize Challenge

Use the lesson for reference as well as the documentation.

In the lesson, we did not cover many to many associations. You will use appointments as a model to split each association into 1:N

Perhaps look at the documentation on Commentable?

Objective:

@harrisonmalone
harrisonmalone / index.js
Created October 18, 2019 23:30
example of an express session
const express = require("express");
const morgan = require("morgan");
const expressSession = require("express-session");
const mongoose = require('mongoose');
const MongoStore = require('connect-mongo')(expressSession);
const app = express();
const dbOptions = { useNewUrlParser: true, useUnifiedTopology: true }
mongoose.connect("mongodb://localhost:27017/test-with-mongo-store", dbOptions, (err) => {
@harrisonmalone
harrisonmalone / app.js
Last active October 5, 2019 04:59
mongodb driver example, shows how mongoose works somewhat
const express = require('express')
const app = express();
const morgan = require('morgan');
const ObjectID = require('mongodb').ObjectID;
const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://harrisonmalone:jHuIZ0tli^&r4quG%5RT3sWMEeoKmp@my-first-cluster-vk1sm.mongodb.net/test?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
# what is a block?
# [1,2,3].each { |number| p number }
# what is yield?
# def hello
# name = "harrison"
# yield(5)
# puts name
@harrisonmalone
harrisonmalone / app.js
Created October 2, 2019 11:14
using react hooks
import React, { useState, useEffect } from 'react';
import axios from 'axios';
function App() {
// same as setting up state
const [count, setCount] = useState(0)
const [pokemon, setPokemon] = useState([])
// same as componentDidMount
useEffect(() => {