This file contains hidden or 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 WsServer = require('ws').Server; | |
var ws = new WsServer({host: 'localhost', port: 9005}); | |
var con = { | |
clientLen : function() { | |
return ws.clients.length; | |
}, | |
broadcast: function(msg) { | |
ws.clients.forEach(function(client) { | |
client.send(JSON.stringify(msg)); | |
}); |
This file contains hidden or 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 fs = require('fs'); | |
var npm = require("npm"); | |
var npmCntData = []; | |
var yyyymmAry = []; | |
var fileName = __dirname + '/npm-pkg-ym.txt'; | |
npm.load(function(err, npm) { | |
if (err) throw err; |
This file contains hidden or 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 argv2 = process.argv[2] || 10000; | |
var dly = (argv2 > 20000) ? 2000 : argv2; | |
setTimeout(function() { | |
process.send('作業終了。' + dly + 'ミリ秒かかりました。'); | |
}, dly); |
This file contains hidden or 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="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script> | |
var host = 'localhost'; | |
var port = 3032; | |
var url = 'ws://' + host + ':' + port + '/'; | |
var WebSocket = window.WebSocket || window.MozWebSocket; | |
var ws = new WebSocket(url); | |
$(function() { | |
var logs = $('#logs'); |
This file contains hidden or 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="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script> | |
var host = 'localhost'; | |
var port = 3030; | |
var url = 'ws://' + host + ':' + port + '/'; | |
var WebSocket = window.WebSocket || window.MozWebSocket; | |
var ws = new WebSocket(url); | |
$(function() { | |
var logs = $('#logs'); |
This file contains hidden or 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 Parent(name){ | |
this.name = name || 'Adam'; | |
} | |
Parent.prototype.say = function(){ | |
return this.name; | |
} | |
function Child(name){ | |
Parent.apply(this, arguments); |
This file contains hidden or 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 Sale(price){ | |
this.price = price; | |
this.decorators_list = []; | |
} | |
Sale.decorators = {}; | |
Sale.decorators.fedtax = { | |
getPrice: function(price){ | |
return price * 2 |
This file contains hidden or 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 agg = (function(){ | |
var index = 0, | |
data = [1, 2, 3, 4, 5], | |
length = data.length; | |
return { | |
next: function(){ | |
var element; | |
if(!this.hasNext()){ | |
return null; |
This file contains hidden or 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 CarMaker(){} | |
CarMaker.prototype.drive = function(){ | |
return "Vroom, I have " + this.doors + " doors"; | |
}; | |
CarMaker.factory = function(type){ | |
var constr = type, newcar; | |
if(typeof CarMaker[constr] !== "function"){ |
This file contains hidden or 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 Universe(){ | |
var instance = this; | |
this.start_time = 0; | |
this.bang = "Big"; | |
Universe = function(){ | |
return instance; | |
}; |