Skip to content

Instantly share code, notes, and snippets.

View mattn9x's full-sized avatar
🤹‍♂️
Research !

Matt Nguyen mattn9x

🤹‍♂️
Research !
View GitHub Profile
@mattn9x
mattn9x / router.js
Created July 9, 2017 08:01
config router với trường hợp create link
router.get('/create-link', function (req, res) {
let domain = "http://localhost:82";
let dataExcel = [];
User.find({})
.then(users => {
let demo2 = [];
Object.keys(users[0]['_doc']).forEach(key => {
"use strict";
demo2.push(key);
});
@mattn9x
mattn9x / plugin_validate_password.txt
Created July 30, 2017 11:17
Show plugin validate password
# SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
let webpack = require('webpack');
// import module cùng các plugin phục vụ cho webpack và webpack-dev-server
module.exports = {
/*entry: nới nạp các file cần xử lý, hay còn gọi là nơi tình yêu bắt đầu*/
entry: {
app: './client/sources/app.js'
},
/*output: Nơi tình yêu kết thúc, các file được xuất ra*/
output: {
@mattn9x
mattn9x / package.json
Created September 10, 2017 16:01
custom script build
"scripts": {
"build": "webpack --process --color --config webpack.config.prod.js",
"dev": "webpack-dev-server --inline --process --color --config webpack.config.dev.js"
}
@mattn9x
mattn9x / loader.js
Last active September 10, 2017 16:50
Config loader for webpack
loaders: [
  /*loader css*/
  {
    test: /\.css$/,
    exclude: /node_module/,
    loader: 'style-loader!css-loader'
  },
  /*loader babel transform es6 => es5*/
  {
    test: /\.js$/,
@mattn9x
mattn9x / option-loader.js
Created September 10, 2017 17:06
Custom và sử dụng nhiều loại loader khác nhau trong webpack
// Sử dụng với 1 loader: loader (sử dụng query parameter)
{
  test: /\.(png|jpg)$/,
  loader: 'url-loader?name=[path][name].[ext]&limit=10240'
}
// Sủ dụng với nhiều loader trong 1 lần load ví dụ: loaders
{
  test: /\.css$/,
  // loader: extractCSS.extract(["css"])
@mattn9x
mattn9x / webpack-plugin.js
Created September 10, 2017 17:40
custom plugin webpack
new HtmlWebpackPlugin({
  template: path.resolve(root, 'src/index.html'),
  hash: true, //them thẻ <script> với đường link đính kèm 1 mã hash
  cache: true, //cache file nếu có ko co thay đổi thì ko bundle lại
  showErrors: false, //neu co loi sẽ ghi vào file html
  minify: false, //false: ko minify html ngước lại tru: minify html
  filename: 'index.html',
  favicon: 'src/favicon.ico', //them file favicon vào trang html
  /*nạp các nhánh javascript bundle vào file html*/
  chunks: ['app', 'publicJS/ex-common', 'publicJS/ex2', 'publicJS/ex1', 'app-home'],