Skip to content

Instantly share code, notes, and snippets.

View dengjonathan's full-sized avatar

Jon Deng dengjonathan

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / .eslintrc.json
Created October 7, 2016 15:52
eslintrc for ES6, react, node dev
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"parserOptions": {
@dengjonathan
dengjonathan / webpack.config.js
Created October 5, 2016 01:58
Webpack Config for React/ ES6
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './app/index.js',
output: {
path: __dirname,
filename: 'bundle.js',
publicPath: '/app/assets/'
},
@dengjonathan
dengjonathan / webpack.deployment.config.js
Created October 5, 2016 01:58
Webpack Dev Server Config for ES6/ React
const path = require('path');
const webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: [
'./app/index.js'
],
output: {
@dengjonathan
dengjonathan / webpack.deployment.config.js
Created October 5, 2016 01:57
Webpack Production Config with ES6/ React
const path = require('path');
const webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: [
'./app/index.js'
],
output: {
@dengjonathan
dengjonathan / .eslintrc.js
Last active October 7, 2016 15:38 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {