This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), path = require('path'), fs = require('fs'); | |
http.createServer(function(req, res) { | |
var file = path.normalize('.' + req.url); | |
path.exists(file, function(a) { | |
if (a === false) { | |
res.writeHead(404); | |
res.end('Not found'); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stream = require('stream'); | |
var dest = new stream.Duplex, dest2 = new stream.Duplex; | |
dest._read = function(size) {}; | |
dest._write = function(chunk, encoding, cb) { | |
this.push(chunk.toString().toUpperCase()); | |
cb(); | |
}; | |
dest2._read = function(size) {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://github.com/dominictarr/split | |
* Customize for Node.js v0.10 | |
* | |
* - remove through module | |
https://github.com/dominictarr/through/blob/master/index.js | |
* - use stream.Duplex (StreamV2) | |
* | |
* @author nanhapark | |
* @twitter @nanhapark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function User() { | |
this.name = 'nanha'; | |
} | |
var Nanha = new User(); | |
var fs = require('fs'); | |
var domain = require('domain').create(); | |
domain.on('error', function(err) { | |
console.log('====='); | |
console.log(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/felixge/node-formidable#example | |
var formidable = require('formidable'), | |
http = require('http'), | |
util = require('util'); | |
http.createServer(function(req, res) { | |
if (req.url == '/upload' && req.method.toLowerCase() == 'post') { | |
// parse a file upload | |
var form = new formidable.IncomingForm(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
안녕하세요. | |
네 req.isAuthenticated() 함수를 사용하시면 됩니다. | |
위와 같이 작업하셔도 되고요. middleware 개념으로 작업을 하자면 아래와 같이도 구현할 수 있습니다. | |
app.get('/account', ensureAuthenticated, function(req, res){ | |
res.render('account', { user: req.user }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"> | |
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script> | |
<body> | |
<div> | |
<scene id="scene1"> | |
<label t="translate(0,346)"> | |
<tspan x="0" y="0em">KTH 자율출퇴근제</tspan> | |
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* GET home page. | |
*/ | |
var mysql = require('mysql'); | |
exports.index = function(req, res){ | |
var client = mysql.createConnection({ | |
host : '127.0.0.1', | |
user : '.....', | |
password : '.....', | |
database : 'Playground' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AOP = { | |
addBefore : function(obj, fname, before) { | |
var oldFunc = obj[fname]; | |
obj[fname] = function() { | |
before(true, arguments, obj); | |
return oldFunc.apply(this,arguments); | |
}; | |
}, | |
addAfter : function(obj, fname, after) { | |
var oldFunc = obj[fname]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Grailbird = function (b, a, c) { | |
Grailbird.data = Grailbird.data || {}; | |
Grailbird.data[b + "_" + a] = c | |
}; | |
(function (b) { | |
var f = {}, e = {}, a = {}; | |
var c = { | |
empty_month: Hogan.compile('<li class="without-tweets" title="" rel="tooltip" data-placement="bottom" data-date="" data-count="0"><span class="value">{{this_month}}</span></li>'), | |
month_bar: Hogan.compile('<li><a href="#" class="with-tweets" title="{{str_title}}: {{str_count}}" rel="tooltip" data-placement="bottom" data-idx="{{data_idx}}" data-date="{{str_title}}" data-count="{{this_count}}"><span class="bar" style="height: {{this_height}}%;"></span><span class="value">{{this_month}}</span></a></li>'), | |
header_str: Hogan.compile('{{title_str}} <span class="count">{{count}} {{content_type}}</span>'), |