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 express = require('express'), | |
site1 = express.createServer(), | |
site2 = express.createServer(), | |
site_vhosts = [], | |
vhost; | |
site_vhosts.push(express.vhost('domain1.com', site1)); | |
site_vhosts.push(express.vhost('domain2.com', site2)); | |
vhost = express.createServer.apply(this, site_vhosts); |
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
/** | |
* express 처음에 init 하시면 app.js 를 비롯하여 여러 디렉토리가 생기는데 | |
* logs 디렉토리에 아무것도 안남는다고 의문을 가지신 분에게 도움이 될거 같습니다. | |
* connect의 middleware logger 는 기본이 stdout 으로 출력하고 있었네요. | |
* http://senchalabs.github.com/connect/middleware-logger.html | |
* manual을 살펴보니 stream options 이 있었군요. | |
* 한번 생각나서 fs core module의 createWriteStream 을 사용하여 해봤더니 잘되네요. | |
* 다른 방법도 있으신분은 알려주세요 | |
*/ | |
var fs = require('fs'), |
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 params = qs.parse(url.parse(req.url).query) | |
, id = params.id | |
, BreakException = {}; | |
try { | |
tweets.forEach(function(element, index) { | |
if(element.id == id) { | |
res.send({tweets:tweets.slice(index+1, index+21)}); | |
throw BreakException; | |
} |
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
script(src='/socket.io/socket.io.js') | |
script | |
window.onload = function() { | |
var socket = io.connect('/test'); | |
socket.on('connect', function() { | |
console.log('connected'); | |
socket.send('test message'); | |
}); | |
socket.on('message', function(msg) { |
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
script(src='/socket.io/socket.io.js') | |
script | |
window.onload = function() { | |
var socket = io.connect('/test'); | |
socket.on('connect', function() { | |
console.log('connected'); | |
socket.emit('mock', 'test message'); | |
}); | |
socket.on('mock', function(msg) { |
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
// jquery | |
$(document).ready(function(){ | |
}); | |
// prototype.js | |
document.observe("dom:loaded", function() { | |
}); | |
// vanilla javascript (it's not dom loaded) | |
window.onload = function() { |
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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
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
task 'epub', -> | |
exec 'pandoc -S --epub-stylesheet style.css -o output/nodebook.epub ' + | |
'chapters/prologue.md ' + | |
'chapters/overview.md ' + | |
'chapters/history.md ' + | |
'chapters/installation.md ' + | |
'chapters/gettingstarted.md ' + | |
'chapters/tcpchat.md ' + | |
'chapters/twitter.md ' + | |
'chapters/npm.md ' + |
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
sed -n '/패턴/p' # 패턴의 라인만 출력 | |
sed 's/패턴/치환문자/g' # 문자열 바꾸기 | |
#정규식 | |
\n # new line | |
\+ # 1개 이상 | |
\{n\} # n개이상 |
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
$ openssl des3 -salt -in plain.txt -out encrypted.txt |
OlderNewer