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 / 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 / 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 / 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 / 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 / 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 / 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
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 / initObjectConstructer.js
Created July 2, 2017 06:54
Khởi tạo object theo cách ObjectConstructer
var psn = new Object(); // hoặc var psn = {};
psn.firstName = 'Nguyen';
psn.lastName = 'Manh';
psn.showName = function () {
console.log(this.firstName + ', ' + this.lastName);
}
var person = {
firstName: 'Nguyen',
lastName: 'Manh',
50: 'professional',
showName: function () {
console.log(this.firstName + ', ' + this.lastName);
}
};
@mattn9x
mattn9x / serialize_deserialize.js
Created July 2, 2017 06:46
Deserialize và serialize object trong javascript
// object person
var person = {
firstName: 'Nguyen',
lastName: 'Manh',
50: 'professional',
showName: function () {
console.log(this.firstName + ', ' + this.lastName);
}
};