Options of Webpack Dll Plugin

The DllPlugin and DllReferencePlugin provide means to split bundles in a way that can drastically improve build time performance.

Read More

Optimize Web App

Optimizing All Assets

One of the most powerful, but under-utilized ways to significantly improve performance starts with understanding hwo the browser analyzes and serves assets. It turns out that browsers are pretty great at discovering resources while parsing and determing their priority of the fly. Here’s where the critical Request comes in:

Read More

Concept on BlockChain

A Blockchain is

A distributed database that is used to maintain a continuously growing list of records, called block.

Read More

Build Node CLI

Dependencies

  • chalk: colorize the output

Read More

Build a Node Command Line Interface

Read More

Start Up With Ts, React, Router, Redux, Rxjs

The Repo

Dependencies

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"devDependencies": {
"@types/react": "^16.0.5",
"@types/react-dom": "^15.5.4",
"@types/react-redux": "^5.0.6",
"@types/redux-actions": "^1.2.8",
"@types/webpack": "^3.0.10",
"@types/webpack-dev-server": "^2.4.1",
"autoprefixer": "^7.1.3",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"bundle-loader": "^0.5.5",
"eslint": "^4.6.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.3.0",
"html-webpack-plugin": "^2.30.1",
"node-sass": "^4.5.3",
"precss": "^2.0.0",
"redux-devtools": "^3.4.0",
"redux-devtools-dock-monitor": "^1.1.2",
"redux-devtools-log-monitor": "^1.3.0",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.6",
"ts-loader": "^2.3.4",
"typescript": "next",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.5.5",
"webpack-dashboard": "^1.0.0-5",
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0"
},
"dependencies": {
"@types/node": "^8.0.26",
"@types/react-router-dom": "^4.0.7",
"babel-plugin-transform-runtime": "^6.23.0",
"extract-text-webpack-plugin": "^3.0.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"redux-actions": "^2.2.1",
"redux-observable": "^0.16.0",
"rxjs": "^5.4.3"
}

Read More

Notes on TS + React + Redux

Add Explicit Props Interface from Store

When I use react-redux, the TS Compiler always throw an error:

Read More

AsyncRoute With React-Router-V4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// AsyncRoute.jsx
import React, { Component } from 'react'

class Bundle extends Component {
constructur () {
super()
this.state = {
mod: null,
}
}
componentWillMount () {
this.load(this.props)
}
componentWillReceiveProps (nextProps) {
if (nextProps.load !== this.props.load) {
this.load(nextProps)
}
}
load (props) {
this.setState({
mod: null,
})
props.load((mod) => {
this.setState({
mod: mod.default || mod,
})
})
}
render () {
return this.state.mod ? this.props.children(this.state.mod) : null
}
}

export default module => routerProps => (<Bundle load={module}>
{Comp => Comp ? <Comp {...routerProps} /> : null}
</Bundle>
)

Read More

Note of Sw-Precache

A node module to generate service worker code that will precaches specific resource so they work offline.

Serving your local static resources cache-first means that you can get all the crucial scaffolding for your web app – your app shell – on the screen without having to wait for any network responses.

Read More

Service-Worker With Webpack

1
yarn add --dev sw-precache-webpack-plugin

Read More

Snippets of Nginx

nginx.conf

One server{} for a site service.

Read More

Manipulate Data in D3

Use data imported from a csv file with spaces in the header

When importing data from a csv file(dataSpace.csv) that has headers with spaces in the middle of some of the fields there is need to address the data slightly differently in order for it to be used easily in your JavaScript.

Read More

Styles in D3

fill

The fill style will fill the element being presented with a specifed color.

Read More

Attributes in D3

x/y

The x and y attributes are used to designate a position on the web page. Use the x and y attributes places the anchor points for these elements at a specified location.

Read More

Basic Elements in D3

Circle

  • cx: The position of the center of the circle in the x direction.

Read More

Things We Can Do With the Simple Graph of D3

origin

Setting up and configuring the Axes

Change the text size

The default size is 10px with the font type of sans-serif.

Read More

Simple Example of Line Chart With D3v4

Import D3

1
<script src="https://d3js.org/d3.v4.min.js"></script>

Read More

Usage of Mock

Installation

1
yarn add mockjs

Read More

Start at Pug

Install Pug

1
yarn add pug

Read More

Mix-Blend-Mode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
mix-blend-mode: normal;
mix-blend-mode: multiply;
mix-blend-mode: screen;
mix-blend-mode: overlay;
mix-blend-mode: darken;
mix-blend-mode: lighten;
mix-blend-mode: color-dodge;
mix-blend-mode: color-burn;
mix-blend-mode: soft-light;
mix-blend-mode: hard-light;
mix-blend-mode: difference;
mix-blend-mode: exclusion;
mix-blend-mode: hue;
mix-blend-mode: saturation;
mix-blend-mode: color;
mix-blend-mode: luminosity;
mix-blend-mode: initial;
mix-blend-mode: inherit;
mix-blend-mode: unset;
}

Read More

Start at Headless

Run Chrome without chrome, it brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line.

A headless browser is a great tool for automated testing and server environments where you don’t need a visible UI shell.

Read More

Node.js Child_process

Node.js runs in single-threaded, event-driven mode, which is good for improving performance via multiple child process.

Each child process has three stream objects:

Read More

Node Child Process

Single-threaded, non-blocking performance in Node works great for a single process. But eventually, one process in one CPU is not going to be enough to handle the increasing workload of your application.

Read More

Scaling Node.js App

Strategies of Scalability

The workload is the most popular reason we scale our applications, but it’s not the only reason. We also scale our applications to increase their availability and tolerance to failure.

Read More

Mock Data for Node.js

Faker.js

It’s a wonderful node module to create fake/mock data.

Read More

Analyzing Runtime Performacne With Chrome DevTools

Get Started

  • Open Chrome in Incognito Mode. Incognito Mode ensures that Chrome runs in a clean state. For example, if you have a lot of extensions installed, those extensions might create noise in you performance meaturements.

Read More

Requiring Modules in Node.js

1
const config = require('/path/to/file')

Read More

Concurrency and Parallelism: Understanding I/O

Original Post

Concurrency is much border, genral problem than parallelism. If you have tasks having inputs and outputs, and you want to schedule them so that they produce correct results, you are solving a concurrency problem.

Read More

Advanced Topics of TS

Iterators and Generators

Iterators are basically objects that can be hold more than one item. Iterators are collections of objects or variables or items that can be iterated on to do some sort of processing on each item in the collection. Arrays are an exmaple of iterators.

Read More

Note(2) on TS2 of edX

Modules

Modules are used for code organization as well as code sharing.

Read More

Note on TS2 of edX

Classification of types in TypeScript

Types are classified into two main classes in TypeScript:

Read More

Build GraphQL Server With Koa

Here is the example Build GraphQL Server with Express

Read More

Build GraphQL Server With Express

Read More

History API

The DOM window object provides access to the browser’s history through the history object.

Moving Forward and Backward

1
2
window.history.back()
window.history.forward()

Read More

Note on Sequelize

Sequelize is a promise-based ORM for Node.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const Sequelize = require('sequelize')
const sequelize = new Sequeslize('database', 'username', 'password')

const User = sequelize.define('user', {
username: Sequelize.STRING,
birthday: Sequelize.DATE,
})

sequelize.sync().then(() => {
User.create({
username: 'Jane',
birthday: new Date(1980, 5, 2),
})
}).then(jane => {
console.log('create successfully')
})

Read More

Build GraphQL Server With Express

Step 1 - Connect to Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// db.js
const Sequelize = require('sequelize')
const _ = require('lodash')
const Faker = require('faker')

const Conn = new Sequelize(
'test',
'postgres',
'postgres',
{
dialect: 'postgres',
host: 'localhost',
}
)

const Person = Conn.define('person', {
firstName: {
type: Sequelize.STRING,
allowNull: false,
},
lastName: {
type: Sequelize.STRING,
allowNull: false,
},
email: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isEmail: true,
}
}
})

const Post = Conn.define('post', {
title: {
type: Sequelize.STRING,
allowNull: false,
},
content: {
type: Sequelize.STRING,
allowNull: false,
},
})

// Relationships
Person.hasMany(Post)
Post.belongsTo(Person)

Conn.sync({
force: true,
}).then( () => {
_.times(10, () => {
return Person.create({
firstName: Faker.name.firstName(),
lastName: Faker.name.lastName(),
email: Faker.internet.email(),
}).then(person => {
return person.createPost({
title: `Sample title by ${person.firstName}`,
content: 'This is a sample article',
})
})
})
})

module.exports = Conn

Read More

Koa-Graphql

Create a GraphQL HTTP server with Koa.

Usage with Koa-Router

1
2
3
4
5
6
7
8
9
10
11
12
13
const Koa = require('koa')
const Router = require('koa-router')
const GraphqlHTTP = require('koa-graphql')

const app = new Koa()
const router = new Router()

router.all('/graphql', graphqlHTTP({
schema: MyGraphQLSchema,
graphiql: ture,
}))

app.use(router.routes()).use(router.allowedMethods())

Read More

Note on GraphQL(2)

Execution

After being validated, a GraphQL query is executed by a GraphQL server which returns a result that mirrors the shape of the requested query, typically as JSON.

Read More

Note on GraphQL(1)

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data.

A GraphQL service is created by defining types and fields on those types, then providing functions for each field on each type.

Read More

List of HTTP Status Code

1xx

  • 100 (continue)

  • 101 (Switching Protocols)

Read More

Short Clip of RxJS

Creation

Rx.Observable.create is an alias for the Observable constructor, and it takes one argument: the subscribe function.

Read More

Http Cache: Etag, Last-Modified, Cache-Control

Cache-Control

Cache-Control general-header field is used to specify deirectives that MUST be obeyed by all caching mechanisms along the request/response chain.

Read More

WS on Node

Create WS Server

1
2
3
4
5
6
7
8
// get WS Object
const WebSocket = require('ws')

// Create new Server Instance
const ws = new WebSocket.Server({
port: 80, // port
verifyClient: socketverify // (optional)function to verify connection
})

Read More

Short Clip of TypeScript(1)

Basic Types

Boolean, Number, String, Array, Tuple, Enum, Any, Void, Null, Undefined, Never

Read More

Web App Manifest

The web app manifest provides information about an application(such as name, author, icon and description) in a JSON text file. The purpose of the manifest is to install web application to the homescreen of a device, providing users with quicker access and a richer experience.

Read More

Cache Object

The Cache interface provides a storage mechanism for Request / Response object pairs that are cahced, for example as part of the ServiceWorker lifecycle. Note that the Cache Interface is exposed to windowed scopes as well as workers. You don’t have to use it in conjunction with service workers, even though it is defined in the service worker spec.

Read More

Some Concepts on BlockChain

Getting BlockChain Data:

    Read More

    Some Note on Blockchain

    Getting BlockChain Data:

      Read More

      Five Models in Smart Contract

      Database Contracts

      These are used only as data storage. The only logic they need is functions that allow other contracts to write, update and get data, and some simple way of checking caller permissions.

      Read More

      Tutorial Part 4 of Dapp

      Calling Contracts

      Contract API basically comes in three pieces.

      Read More