Skip to content

Instantly share code, notes, and snippets.

hieunguyendut hieunguyendut

Block or report user

Report or block hieunguyendut

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hieunguyendut
hieunguyendut / callback_problem.js
Created Jan 6, 2018
problem with scope of variable callback
View callback_problem.js
function getAllCity(req, res) {
var promise = Q.fcall(function() {
return City.find({}, function(err, cities) {
if(err) {
console.log(err);
return res.send(404)
}
for (let i = 0; i < cities.length; i++) {
Location.findOne({_id : cities[i].locationId}, function(err, location){
if(err) return;
View command-line.md

Some command line common

1. copy file: scp houser.png root@beta.houseseeker.vn:/root/github/HouseSeeker_Backend/vinmas_images
2. yarn remove <module-name>
3. sudo dpkg -i file.deb
4. sudo halt and sudo reboot.

Docker

1. docker-compose up run container
View question.md

package.json

1. Su khac nhau giua --save, --save-dev
2. Tai mot module ma chi su dung 1 vai lan trong code thi co nen k?
3. Tai lieu thiet ke co so du lieu noSQL
4. Lam sao de luu gia tri bien trong callback
5. _v trong database mongodb de lam gi?
6. Lam sao de day nhieu file trong angular ma multer co the parse ra va day vao req.files duoc.
7. Mot vai luu y sau khi review
View server2.js
const express = require('express');
const mongoose = require('mongoose');
const autoIncrement = require('mongoose-auto-increment');
const app = express();
mongoose.connect('mongodb://localhost/test');
var Schema = mongoose.Schema;
var personSchema = Schema({
View server.js
const express = require('express');
const mongoose = require('mongoose');
const app = express();
mongoose.connect('mongodb://localhost/test');
var Schema = mongoose.Schema;
var personSchema = Schema({
_id: Schema.Types.ObjectId,
View population.js
var Mongoose = require('mongoose');
var autoIncrement = require('mongoose-auto-increment')
var Schema = Mongoose.Schema;
// Mongoose.Promise = require('bluebird');
var db = Mongoose.connect('mongodb://localhost/Population', {
useMongoClient: true
}, (err) => {
if (err) {
console.log(`Can't connect to MongoDB`);
View sign-up.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#uploadForm").submit(function(event){
// disable the default form submission
event.preventDefault();
//grab all form data
View config-nginx.md
server {
    listen 80 default_server;

    server_name 128.199.174.129;

    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
View app.js
const express = require('express');
const fileUpload = require('express-fileupload');
const bodyParser = require('body-parser');
const app = express();
// default options
app.use(fileUpload());
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(function (req, res, next) {
View jquery-ajax.js
$(document).ready(function(){
$("#uploadForm").submit(function(event){
// disable the default form submission
event.preventDefault();
//grab all form data
var formData = new FormData($(this)[0]);
$.ajax({
url: 'http://localhost:3001/api/signup',
headers: {
You can’t perform that action at this time.