Skip to content

Instantly share code, notes, and snippets.

View andrewhheller's full-sized avatar
🎯
Learning the sorcery of Linux commands.

Andrew Heller andrewhheller

🎯
Learning the sorcery of Linux commands.
  • New York City
View GitHub Profile
// hide email address in pieces to avoid spam
const klingonCloak = (a, b) => {
return a + "@" + b;
}
const birdOfPrey = klingonCloak("info", "listservenyc.com");
@andrewhheller
andrewhheller / gist:5ff2b7c37d84015878468a3770af33ea
Last active November 8, 2018 02:58
brcrypt compare in login route
// auth.js (authentication route file)
const bcrypt = require('bcrypt');
router.post('/login', (req, res, next) => {
const { username, password } = req.body;
User.findOne({
where: {
username: req.body.username
}
// User.js (model file)
const conn = require('./conn');
const bcrypt = require('bcrypt');
const saltRounds = 12;
const User = conn.define('user', {
id: {
type: conn.Sequelize.UUID,
defaultValue: conn.Sequelize.UUIDV4,
primaryKey: true
// route.js (route file)
const { User } = require('../db');
router.post('/user/create', (req, res, next) => {
User.create(req.body)
.then(officer => res.status(201).send(officer))
.catch(error => next(error))
})
@andrewhheller
andrewhheller / gist:ac773276e73c36414ef054510fbe5c84
Last active November 8, 2018 02:55
bcrypt hash logic in route
// route.js
const { User } = require('../db');
router.post('/user/create', (req, res, next) => {
bcrypt.hash(req.body.password, saltRounds, (error, hash) => {
User.create({
firstName: req.body.firstName,
lastName: req.body.lastName,
// route.js
const bcrypt = require('bcrypt');
const saltRounds = 12;
npm install bcrypt
@andrewhheller
andrewhheller / gist:b193f10fb5ecef4711dfdd7ea514ffa7
Last active October 29, 2018 21:48
React Search / Display Results in Table
import React, { Component, Fragment } from 'react'
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
// sample data structure
// const users = [
// { firstname: 'Jean-Luc', lastname: 'Picard', username: 'jpicard' },
// { firstname: 'William T.', lastname: 'Riker', username: 'jpicard' },
// { firstname: 'Data', lastname: 'Data', username: 'jpicard' },
// ]