Skip to content

Instantly share code, notes, and snippets.

View leonguyen's full-sized avatar

Nam Nguyen leonguyen

View GitHub Profile
@leonguyen
leonguyen / gist:9359771
Last active August 29, 2015 13:57
msdbA
async.each(cfg.msdbA, function(config, cb){
var connection = new sql.Connection(config, function(err){
var request = new sql.Request(connection);
var queryStr = "";
request.query(queryStr, function(err, rows) {
if(err) console.log(err);
//Code here
});
});
}, function(err){
@leonguyen
leonguyen / gist:9320092
Last active August 29, 2015 13:56
ad_tpl list search
*View
<label class="control-label" for="txtName">Username</label>
<input type="text" class="form-control" id="txtName" name="txtName" value="<%=typeof(sess.search)!='undefined'&&typeof(sess.search.uName)!='undefined'?sess.search.uName:''%>" placeholder="Username" autofocus autocomplete="off"></th>
---
<th>Username <a href="/ad_user/search?uName=ASC">▲</a><a href="/ad_user/search?uName=DESC">▼</a></th>
---
<td><%=ml.uName?ml.uName:''%></td>
*Route
search['name'] = req.body.txtName?req.body.txtName:'';
---
@leonguyen
leonguyen / gist:9319588
Last active August 29, 2015 13:56
ad_tpl list
<% include ../header %>
<% include ../admin/menu %>
<% include ../admin/msg %>
<div class="page-header">
<% if(typeof(sess.AuthList['N'])!='undefined'){%>
<button type="button" class="btn btn-default pull-right" id="btnAdd" name="btnAdd" onclick="location.href='/ad_user/create'"><span class="glyphicon glyphicon-plus"></span> Add new</button>
<%}//if%>
<h2><%=title%></h2>
</div>
<form id="frm" name="frm" class="form" role="form" method="post" action="/ad_user/search">
@leonguyen
leonguyen / gist:9319359
Last active August 29, 2015 13:56
list search
<table class="table">
<thead><tr>
<th width="88px;" style="border-bottom:none">
<label class="control-label" for="txtNo">No.</label>
<input type="text" class="form-control" id="txtNo" name="txtNo" value="<%=typeof(sess.search)!='undefined'?sess.search.no:''%>" placeholder="No." autofocus autocomplete="off"></th>
<th width="88px;" style="border-bottom:none">
<label class="control-label" for="btnSearch">&nbsp;</label>
<button class="form-control" type="submit" class="btn btn-default" id="btnSearch" name="btnSearch"><span class="glyphicon glyphicon-search"></span> Search</button>
</th>
</tr></thead></table>
@leonguyen
leonguyen / gist:9319271
Created March 3, 2014 06:02
ad_tpl list
<% include ../header %>
<% include ../admin/menu %>
<% include ../admin/msg %>
<div class="page-header">
<% if(typeof(sess.AuthList['N'])!='undefined'){%>
<button type="button" class="btn btn-default pull-right" id="btnAdd" name="btnAdd" onclick="location.href='/ad_user/create'"><span class="glyphicon glyphicon-plus"></span> Add new</button>
<%}//if%>
<h2><%=title%></h2>
</div>
<form id="frm" name="frm" class="form" role="form" method="post" action="/ad_user/search">
@leonguyen
leonguyen / gist:9318235
Last active August 29, 2015 13:56
ad_tpl
/*
* GET admin awb page.
*/
var _this = this,
prefix = 'sint_',
tbl = 'al', id = 'aId',
control = 'ad_awb';
var search = '';
exports.index = function(req, res) {
@leonguyen
leonguyen / gist:9317495
Created March 3, 2014 02:29
setInterval
setInterval(function() {
//Code here
}, interval);
@leonguyen
leonguyen / gist:9304841
Last active August 29, 2015 13:56
async.series
async.series([
function(callback){
// do some stuff ...
callback(null, 'one');
},
function(callback){
// do some more stuff ...
callback(null, 'two');
},
],
@leonguyen
leonguyen / gist:9303986
Created March 2, 2014 09:17
setTimeout
setTimeout(function(){
//Code here
}, 1000);
@leonguyen
leonguyen / gist:9303875
Last active August 29, 2015 13:56
async.each
async.each(list, function(item, cb){
//Code here
}, function(err){
if(err){ console.log(err); };
});//async.each