Skip to content

Instantly share code, notes, and snippets.

@Jxck
Jxck / app.js
Created June 21, 2011 00:45
very simple socket.io@0.7 echo server
/**
* Socket.IO server (single process only)
*/
var io = sio.listen(app);
io.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
@Jxck
Jxck / ecma5_on_v8.js
Created July 9, 2011 12:02
The sample usage of ECMA 5 Features Implemented in V8
/**
* 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
@Jxck
Jxck / config.js
Created August 27, 2011 08:48
I want to configuration like this..
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() {
@Jxck
Jxck / nodeinstall.sh
Created September 9, 2011 07:29
install node.js in ec2 micro instance
# 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
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));
}
@Jxck
Jxck / .gitignore
Created September 24, 2011 07:01
show repository status of modules listed on https://github.com/joyent/node/wiki/modules
.DS_Store
@Jxck
Jxck / 01.mystream.js
Created December 3, 2011 06:27
Stream Sample for blog
var stream = require('stream')
, util = require('util')
, log = console.log.bind(console)
;
// 本来は 'drain','error','close','pipe' イベントが必要
function MyStream() {
this.writable = true;
this.buf = [];
}
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) {
みてもいいよ。
@Jxck
Jxck / .gitignore
Created February 27, 2012 15:39
Test WebSocket/Socket.IO over ELB
node_modules