Skip to content

Instantly share code, notes, and snippets.

View ngnguyen1's full-sized avatar

Nga Nguyen ngnguyen1

  • FPT - Silicon Labs
  • Hà Nội
  • 09:12 (UTC +07:00)
  • LinkedIn in/nga-nguyen
View GitHub Profile
@ngnguyen1
ngnguyen1 / password.js
Created December 27, 2015 03:05 — forked from soplakanets/password.js
Password hashing for node.js
var crypto = require('crypto');
var SaltLength = 9;
function createHash(password) {
var salt = generateSalt(SaltLength);
var hash = md5(password + salt);
return salt + hash;
}
@ngnguyen1
ngnguyen1 / test.js
Created November 29, 2014 17:30
Async example
function doSomethingOnceAllAreDone(){
console.log("Everything is done.");
}
function Item(delay){
this.delay = delay;
}
Item.prototype.someAsyncCall = function(callback){
setTimeout(function(){
console.log("Item is done.");
if(typeof callback === "function") callback();
@ngnguyen1
ngnguyen1 / index.html
Last active August 29, 2015 14:08
index file
<!DOCTYPE html>
<html>
<head>
<script src="nga.js"></script>
</head>
<body>
<div id="txtCDInfo">
<button onclick="loadXMLDoc()">Get from locations</button>
</div>
@ngnguyen1
ngnguyen1 / project.js
Created November 5, 2014 15:15
project.js
var debug = require('debug')('boot:create-model-instances');
module.exports = function(app) {
var User = app.models.user;
var Role = app.models.Role;
var RoleMapping = app.models.RoleMapping;
var Team = app.models.Team;
User.create([
{username: 'John', email: '[email protected]', password: 'opensesame'},
@ngnguyen1
ngnguyen1 / Role
Created November 5, 2014 12:28
Role
{ "name" : "teacher", "description" : null, "created" : { "$date" : 1414991300446 }, "modified" : { "$date" : 1414991300446 }, "_id" : { "$oid" : "54570dc4a4b45b194d0b5885" } }
{ "name" : "admin", "description" : null, "created" : { "$date" : 1414991412700 }, "modified" : { "$date" : 1414991412700 }, "_id" : { "$oid" : "54570e349a721b4f4d86573f" } }
{ "name" : "teacher", "description" : null, "created" : { "$date" : 1415188791938 }, "modified" : { "$date" : 1415188791938 }, "_id" : { "$oid" : "545a11378f748c4a578be4ab" } }
@ngnguyen1
ngnguyen1 / log.txt
Created October 24, 2014 17:23
log
/home/abc/loopback-connector-soap/node_modules/soap/lib/wsdl.js:538
this.parts[part.$name].namespace = nsName.namespace;
^
TypeError: Cannot set property 'namespace' of undefined
at MessageElement.postProcess (/home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:538:40)
at OperationElement.postProcess (/home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:619:13)
at PortTypeElement.postProcess (/home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:639:11)
at BindingElement.postProcess (/home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:653:14)
at ServiceElement.postProcess (/home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:688:15)
at /home/chris/.Trash/test/test/loopback-connector-soap/node_modules/soap/lib/wsdl.js:978:26
@ngnguyen1
ngnguyen1 / cmd.sh
Created October 21, 2014 12:48
info request
#!/bin/sh
curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:GetServices" --data @soap_getservices.xml http://bus.hlink.vn/webservice/Server.php
@ngnguyen1
ngnguyen1 / error.log
Created October 21, 2014 10:42
Error soap request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>DATA_EMPTY</faultcode>
<faultstring>Không tìm thấy danh sách địa điểm!</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
var fs = require("fs"),
a;
fs.stat("filename.txt", function(err, stat) {
a = stat.size;
console.log(a);
});
@ngnguyen1
ngnguyen1 / Xdefault
Created June 26, 2014 06:49
.Xdefault
! vim: set filetype=xdefaults :
URxvt.perl-ext-common : default,keyboard-select,url-select,clipboard
URxvt.keysym.M-x : perl:keyboard-select:activate
URxvt.keysym.M-u : perl:url-select:select_next
URxvt.keysym.M-c : perl:clipboard:copy
URxvt.keysym.M-v : perl:clipboard:paste
URxvt.keysym.M-s : perl:keyboard-select:search
URxvt.keysym.M-C-v : perl:clipboard:paste_escaped