Skip to content

Instantly share code, notes, and snippets.

View coryhouse's full-sized avatar

Cory House coryhouse

View GitHub Profile
@coryhouse
coryhouse / mockDataSchema.js
Last active October 7, 2016 22:50
Mock Data Schema for "Building a JavaScript Development Environment" on Pluralsight
export const schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
{
"firstName": "Cory",
"lastName": "House
}
@coryhouse
coryhouse / mockData.json
Last active October 7, 2016 10:12
Mock data for API call in "Building a JavaScript Development Environment" on Pluralsight
[
{"id": 1,"newMpg":24,"tradeMpg":18,"pricePerGallon":"$1.34","milesDrivenPerMonth":954},
{"id": 2,"newMpg":28,"tradeMpg":39,"pricePerGallon":"$2.96","milesDrivenPerMonth":298},
{"id": 3,"newMpg":44,"tradeMpg":31,"pricePerGallon":"$3.72","milesDrivenPerMonth":264}
]
@coryhouse
coryhouse / webpack.config.dev.js
Last active April 15, 2023 15:08
Development Webpack config for "Building a JavaScript Development Environment" on Pluralsight
import path from 'path';
export default {
debug: true,
devtool: 'inline-source-map',
noInfo: false,
entry: [
path.resolve(__dirname, 'src/index')
],
target: 'web',
@coryhouse
coryhouse / mockDataSchema.js
Last active April 15, 2023 15:09
Mock Data Schema for "Building a JavaScript Development Environment" on Pluralsight
export const schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
@coryhouse
coryhouse / srcServer.js
Created October 27, 2016 20:52
Using import for webpack libs
import express from 'express';
import webpack from 'webpack';
import path from 'path';
import config from '../webpack.config.dev';
import open from 'open';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
/* eslint-disable no-console */
@coryhouse
coryhouse / mockDataSchema.js
Last active April 7, 2019 04:50
Mock data schema for randomized user data
var schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
@coryhouse
coryhouse / generateMockData.js
Last active November 12, 2016 17:54
Script for generating mock data using json-schema-faker and a mock data schema
/* This script generates mock data for local development.
This way you don't have to point to an actual API,
but you can enjoy realistic, but randomized data,
and rapid page loads due to local, static data.
*/
var jsf = require('json-schema-faker');
var mockDataSchema = require('./mockDataSchema');
var fs = require('fs');
@coryhouse
coryhouse / badSetStateExample.js
Last active June 13, 2017 13:46
Bad example of updating state in React by mutating it before calling setState
updateState(event) {
 const {name, value} = event.target;
 let user = this.state.user; // this is a reference, not a copy...
 user[name] = value; // so this mutates state 🙀
 return this.setState({user});
}
@coryhouse
coryhouse / objectAssignExample.js
Last active June 11, 2017 19:24
Update state using Object.assign
updateState(event) {
const {name, value} = event.target;
let user = Object.assign({}, this.state.user);
user[name] = value;
return this.setState({user});
}