Skip to content

Instantly share code, notes, and snippets.

View outsideris's full-sized avatar

Outsider outsideris

View GitHub Profile
@outsideris
outsideris / server.js
Last active June 22, 2022 21:26
express vhost example
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);
@outsideris
outsideris / server.js
Last active January 9, 2017 02:21 — forked from nanha/node.js express logger
node.js express middleware 중에서 logger를 사용하여 실제 파일로 logging 하는 방법
/**
* 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'),
@outsideris
outsideris / breakexception.js
Created July 6, 2011 07:54
javascript foreach break
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;
}
@outsideris
outsideris / index.jade
Created July 7, 2011 01:25
socket.io examample 1
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) {
@outsideris
outsideris / index.jade
Created July 7, 2011 01:28
socket.io examample 2
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) {
@outsideris
outsideris / dom_loaded.js
Created October 1, 2011 05:21
Dom loaded
// jquery
$(document).ready(function(){
});
// prototype.js
document.observe("dom:loaded", function() {
});
// vanilla javascript (it's not dom loaded)
window.onload = function() {
# 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:
@outsideris
outsideris / Cakefile
Created November 2, 2011 18:48
cakefile for epub
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 ' +
@outsideris
outsideris / sed_usage
Created March 23, 2012 02:58
sed usage
sed -n '/패턴/p' # 패턴의 라인만 출력
sed 's/패턴/치환문자/g' # 문자열 바꾸기
#정규식
\n # new line
\+ # 1개 이상
\{n\} # n개이상
@outsideris
outsideris / encryption.sh
Last active October 4, 2015 05:18
openssl encryption
$ openssl des3 -salt -in plain.txt -out encrypted.txt