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
/** | |
* Socket.IO server (single process only) | |
*/ | |
var io = sio.listen(app); | |
io.set('transports', [ | |
'websocket' | |
, 'flashsocket' | |
, 'htmlfile' |
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
/** | |
* The sample usage of ECMA 5 Mozilla Features Implemented in V8 | |
* https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8 | |
* You can use thease new feature of ECMA5 on Node.js as you like. | |
* because there is no IE :) | |
* Order is deferent form original wiki. | |
* Sources are Checked on Node.js v0.5.0(unstable), v0.4.9(stable) | |
* | |
* you can execute this file. | |
* $ node ecma5_on_v8.js |
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 noop(){}; | |
function para() { | |
var list = arguments; | |
return function(req, res, next) { | |
var current = 0; | |
var len = list.length; | |
for (var i = 0; i < len; ++i) { | |
var fun = list[i]; | |
fun(req, res, 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
# alias | |
alias ls='ls -la --col' | |
# JST time | |
sudo cp /usr/share/zoneinfo/Japan /etc/localtime | |
# package for build | |
sudo yum install -y git gcc-c++ openssl-devel make | |
# install nodebrew | |
wget https://raw.github.com/hokaccha/nodebrew/master/nodebrew | |
perl nodebrew setup | |
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> .bashrc |
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 hoge = { | |
num: 10, | |
twi: function(n, cb){ | |
cb(n * 2); | |
}, | |
add: function(a, cb){ | |
this.twi(a, function(ans) { | |
cb(ans + this.num); | |
}.bind(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
.DS_Store |
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') | |
, util = require('util') | |
, log = console.log.bind(console) | |
; | |
// 本来は 'drain','error','close','pipe' イベントが必要 | |
function MyStream() { | |
this.writable = true; | |
this.buf = []; | |
} |
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 mongoose = require('mongoose'); | |
mongoose.connect('localhost', 'testing_invalidate'); | |
var schema = new mongoose.Schema({ | |
name: { type: String, required: true }, | |
pass: { type: String, required: true }, | |
}); | |
schema.methods.setPassword = function setPassword (pwd, confirm) { | |
if (pwd === confirm) { |
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
みてもいいよ。 |
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
node_modules |