Skip to content

Instantly share code, notes, and snippets.

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

Matt Nguyen mattn9x

🤹‍♂️
Research !
View GitHub Profile
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.showName = function () {
console.log(this.firstName + '- ' + this.lastName);
}
}
var psn1 = new Person('manh', 'nguyen');
psn1.showName(); // I'm manh- nguyen
@mattn9x
mattn9x / initObjectVsPrototype.js
Created July 2, 2017 06:56
Khởi tạo đối tượng với prototype
function Student() {}
Student.prototype.firstName = "Manh"; Student.prototype.lastName = "Nguyen";
Student.prototype.showName = function () {
console.log("I'm " + this.firstName + '- ' + this.lastName);
};
var student = new Student();
console.log('Test Protoype'); console.log(student.firstName);// Manhstudent.showName(); //I'm Manh- Nguyen
@mattn9x
mattn9x / sample.js
Created July 2, 2017 07:05
Vooc vạch đôi chút
// Vooc vạch đôi chút về các cách khai báo key trong JS nào :D
// ----------------------^_^----------------------------------
// Xem 2 cách khai báo đối tượng theo 2 cách
var person = { 'firstName': 'Nguyen', 'lastName': 'Manh' }
var person = { firstName: 'Nguyen', lastName: 'Manh' };
// => 2 cách khai báo trên là giống nhau nhưng với cách 1 có ưu điêm hơn cách 2 khi có thể khai báo
// thuộc tính có dấu cách. Chẳng hạn tôi thêm 1 thành phần city-address vào đối tượng như sau
var person = {
'firstName': 'Nguyen',
'lastName': 'Manh',
@mattn9x
mattn9x / customData.json
Created July 3, 2017 08:11
Pushmigh example platform
{
"item": "Value item",
"alert":"Thanh Le has new message from NguyenManh!",
"title":"Notify vmodev platform",
"message":"That ko thể tin nổi"
}
@mattn9x
mattn9x / customRole.js
Last active July 8, 2017 19:19
Custom user role in mongodb
use admin
var role = {
'role' : 'develop',
'privileges' : [
{
'resource': {'db' : 'company', 'collection' : 'users'},
'actions': ['find']
}
],
'roles' : [
@mattn9x
mattn9x / initData.js
Last active July 8, 2017 17:00
init data test
use phone_solution
db.people.insert({'name': 'ThuyNgan', 'age': 24});
db.people.insert({'name': 'NguyenManh', 'age': 24});
db.work.insert({'title': 'Travel agent', 'location': 'HaNoi'});
db.work.insert({'title': 'It Develop', 'location': 'HaNoi'});
use company
db.users.insert({'name': 'admin_company', address: 'GiaLam'});
db.users.insert({'name': 'employee', address: 'VietNam'});
@mattn9x
mattn9x / promasterRole.js
Last active September 6, 2018 06:59
Custom role with role promaster
use admin
var role = {
'role' : 'promaster',
'privileges' : [
{
'resource': {'db' : 'company', 'collection' : 'users'},
'actions': ['find']
},
{
'resource': {'db' : 'demo', 'collection' : 'chat'},
@mattn9x
mattn9x / strutureExcelNode.js
Last active July 9, 2017 07:39
cấu trúc project excel example nodejs
model
--user.model.js // model User sử dụng để query với mongoose
--init.js // Khởi tạo một số dữ liệu user để tiện cho export data
public
exports
--file_excel_export.xlsx // lưu trữ file excel được export
view
--index.ejs // Trang chủ
--receive.ejs // Trang nhận liên kết link download từ server gửi về và hiển thị lên
-app.js // cấu hình ứng dụng
@mattn9x
mattn9x / package.json
Created July 9, 2017 07:10
package example excel nodejs
{
"name": "excel_node_sample",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"ejs": "^2.5.6",
"express": "^4.15.3",
@mattn9x
mattn9x / router.js
Last active July 9, 2017 07:53
config router export data
let express = require('express');
let router = express.Router();
let nodeXlsx = require('node-xlsx');
let User = require('./model/user.model');
let fs = require('fs');
/* GET home page. */
router.get('/', function (req, res) {
res.render('index', {title: 'Express'});
});