Skip to content

Instantly share code, notes, and snippets.

View bluepnume's full-sized avatar

Daniel Brain bluepnume

  • OneText
  • San Jose
View GitHub Profile
@bluepnume
bluepnume / gist:4384862
Last active December 10, 2015 04:58 — forked from anonymous/gist:4384810
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
from twisted.internet import reactor
from autobahn.websocket import WebSocketClientFactory, \
WebSocketClientProtocol, \
connectWS
from twisted.internet import stdio
class MessageBasedHashClientProtocol(WebSocketClientProtocol):
var util = require('util');
/**
* Generate a new class
* --------------------
*
* - When attached to an existing class, generates a new class
* which inherits from the prototype of the existing class
*
* - Otherwise, generates a new, clean class.
// Let's create a class with some abstract methods
var Animal = Class.extend({
init: function() {
console.log('A new', this.name, 'is born!')
},
talk: function() {
console.log('The', this.name, 'goes', this.action)
var util = require('util');
// Let's create a class with some abstract methods
function Animal() {
console.log('A new', this.name, 'is born!')
}
Animal.prototype.talk = function() {
'use strict';
var _ = require('underscore');
var data = {};
var timing = require('./timing');
console.log('generating');
for (var i = 1; i < 100000; i++) {
data['item' + i.toString(10)] = i;
}
'use strict';
var _ = require('underscore');
var data = {};
var timing = require('./timing');
console.log('generating');
for (var i = 1; i < 100000; i++) {
data['item' + i.toString(10)] = i;
}
q.makePromise.prototype.attachNodeStyleCallback = function(callback) {
if (!callback)
return this;
return this.then(function(result) {
callback(null, result);
return result;
var q = require('q');
q.sequential = function(promises) {
var results = [];
return promises.reduce(function(aggregate, promise) {
return aggregate.then(function() {