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
Last active September 24, 2016 12:50
simple express node server
var express = require('express');
var app = express();
var path = require('path');
// make express look in the public directory for assets (css/js/img)
app.use(express.static(path.join(__dirname)));
app.use("/styles", express.static(__dirname + '/css'));
app.use("/scripts", express.static(__dirname + '/scripts'));
app.use("/images", express.static(__dirname + '/img'));
app.use("/components", express.static(__dirname + '/bower_components'));
@dengjonathan
dengjonathan / index.js
Last active February 20, 2017 10:26
minimal express.js server
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname)));
app.use("/styles", express.static(__dirname));
app.use("/images", express.static(__dirname + '/images'));
app.use("/scripts", express.static(__dirname + '/scripts'));
// viewed at based directory http://localhost:8080/
@dengjonathan
dengjonathan / OOP.js
Last active September 28, 2016 02:28
OOP style
const hasLegsMaker = num => ({ legs: num });
const noiseMaker = noise => {
return { makeNoise: () => { console.log(`All day I just ${noise}`) } };
};
var fido = Object.assign({}, hasLegsMaker(4), noiseMaker('woof!'));
fido.makeNoise(); //All day I just woof!
@dengjonathan
dengjonathan / functional.js
Last active September 28, 2016 02:42
Functional style through composition
class Animal {
constructor(name, legs) {
this.name = name;
this.legs = legs;
}
}
class Dog extends Animal {
constructor(name) {
super(name, 4)
@dengjonathan
dengjonathan / oop.js
Created September 28, 2016 02:43
OOP style
class Animal {
constructor(name, legs) {
this.name = name;
this.legs = legs;
}
}
class Dog extends Animal {
constructor(name) {
super(name, 4)
@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": {
@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 / 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.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 / .eslintrc.json
Created October 7, 2016 15:52
eslintrc for ES6, react, node dev
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"parserOptions": {