Skip to content

Instantly share code, notes, and snippets.

View dengjonathan's full-sized avatar

Jon Deng dengjonathan

View GitHub Profile
@dengjonathan
dengjonathan / server.js
Created October 12, 2016 02:59
Express Server for React project
const path = require('path')
const express = require('express')
module.exports = {
app: function () {
const app = express();
const indexPath = path.join(__dirname, 'indexDep.html');
const publicPath = express.static(path.join(__dirname, '../dist'));
app.use('/dist', publicPath);
@dengjonathan
dengjonathan / app.js
Created October 12, 2016 03:00
App.js file to instantiate a server and allow hot module reloading
const Server = require('./server.js')
const port = (process.env.PORT || 8080)
const app = Server.app()
if (process.env.NODE_ENV !== 'production') {
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const config = require('../webpack.deployment.config.js')
const compiler = webpack(config)
@dengjonathan
dengjonathan / Gulpfile.js
Created October 15, 2016 02:15
Gulpfile
'use strict';
var gulp = require('gulp');
var clean = require('gulp-clean');
var babel = require('gulp-babel');
var nodemon = require('gulp-nodemon');
var KarmaServer = require('karma').Server;
var browserSync = require('browser-sync').create();
// The paths to our app files
var paths = {
@dengjonathan
dengjonathan / angularWrongWay.js
Created October 15, 2016 19:09
Angular Factory wrong way
angular.module('shortly.services', [])
// use of arrow functions seems to break the Angular API
.factory('Links', ($http) => {
const addOne = url => $http({
method: 'POST',
url: '/api/links',
data: {
url: url
}
@dengjonathan
dengjonathan / angularRightWay.js
Created October 15, 2016 19:10
angular factory Right way
angular.module('shortly.services', [])
// use of arrow functions seems to break the Angular API
.factory('Links', function($http){
const addOne = url => $http({
method: 'POST',
url: '/api/links',
data: {
url: url
}
@dengjonathan
dengjonathan / .eslintrc
Created October 17, 2016 15:40 — forked from glennr/.eslintrc
ESLint config for React + Redux projects
{
"parser": "babel-eslint", // I want to use babel-eslint for parsing!
"rules": {
"comma-dangle": 0, // dangling commas are ok
"indent": [2, 2, {
"SwitchCase": 1
}],
"jsx-quotes": 1,
"linebreak-style": [2, "unix"],
"quotes": [2, "single"],
@dengjonathan
dengjonathan / .eslintrc
Created October 17, 2016 15:45
eslintrc for React/ ES6 dev
{
"parser": "babel-eslint", // I want to use babel-eslint for parsing!
"rules": {
"comma-dangle": 0, // dangling commas are ok
"indent": [2, 2, {
"SwitchCase": 1
}],
"jsx-quotes": 1,
"linebreak-style": [2, "unix"],
"quotes": [2, "single"],
@dengjonathan
dengjonathan / package.json
Created October 28, 2016 14:59
Webpack/ React package.json
{
"name": "how_far_hr",
"version": "1.1.0",
"engines": {
"node": "5.12.0"
},
"description": "A small toy app showing HR progress with React and ES6",
"author": "Jon Deng <jondeng.com>",
"license": "MIT",
"private": false,
@dengjonathan
dengjonathan / .babelrc
Last active May 1, 2018 20:36
Webpack/ Babel/ Express Env for React
{
"plugins": ["react-hot-loader/babel"],
"ignore":[]
}
@dengjonathan
dengjonathan / package.json
Created October 28, 2016 15:24
package.json with dependencies
{
"name": "how_far_hr",
"version": "1.1.0",
"engines": {
"node": "5.12.0"
},
"description": "A small toy app showing HR progress with React and ES6",
"author": "Jon Deng <jondeng.com>",
"license": "MIT",
"private": false,