Skip to content

Instantly share code, notes, and snippets.

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));
});
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;
var argv2 = process.argv[2] || 10000;
var dly = (argv2 > 20000) ? 2000 : argv2;
setTimeout(function() {
process.send('作業終了。' + dly + 'ミリ秒かかりました。');
}, dly);
<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');
<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');
function Parent(name){
this.name = name || 'Adam';
}
Parent.prototype.say = function(){
return this.name;
}
function Child(name){
Parent.apply(this, arguments);
function Sale(price){
this.price = price;
this.decorators_list = [];
}
Sale.decorators = {};
Sale.decorators.fedtax = {
getPrice: function(price){
return price * 2
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;
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"){
function Universe(){
var instance = this;
this.start_time = 0;
this.bang = "Big";
Universe = function(){
return instance;
};