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 MY_ID = ".."; | |
reactor.use({ | |
queried: function (rpc) { | |
rpc.quering = new Peer(rpc.queryingAddress, rpc.params.id); | |
rpc.onComplete(function(peers) { | |
rpc.response = rpc.response || {}; | |
rpc.response.nodes = peers.toRawArray(); |
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 assert = require('assert'); | |
var reg = /\b(?:0x)?([A-Fa-f0-9])+\b/g; | |
assert.deepEqual('0x5f ff56'.match(reg), ['0x5f', 'ff56']); | |
assert.deepEqual('0x5f plain0x5ftext'.match(reg), ['0x5f']); | |
assert.deepEqual('0x5F DD52'.match(reg), ['0x5F', 'DD52']); | |
assert.deepEqual('Z4FD'.match(reg), null); | |
var Rectangle = function(l,h) { |
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
case 'FIND_VALUE': | |
if(args[1] !== null) { | |
html = [ | |
'<ul>', | |
'<i>FOUND</i><br>', | |
'<li><b>Value : </b><code>'+args[1].value+'</code></li>', | |
'<li><b>Expiration : </b>', | |
(args[1].exp<0) ? | |
'<i>never</i>': | |
'<time rel=\'tooltip\' datetime=\''+(new Date(args[1].exp)).toISOString()+'\' data-placement=\'bottom\'>'+(new Date(args[1].exp).toString())+'</time>', |
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
queried: function(rcp) { | |
switch(rpc.getMethod()) { | |
case 'PING': | |
rpc.resolve(); | |
break; | |
case 'FIND_NODE': | |
rpc.resolve( | |
this.routingTable.getClosePeers( | |
rpc.getTarget(), | |
BETA, |
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 util = require('util'); | |
var events = require('events'); | |
var io = require('socket.io-client'); | |
function Socket(type, listener, host, io_options) { | |
events.EventEmitter.call(this); | |
if (typeof listener === 'function') | |
this.on('message', listener); |
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 StateEventEmitter = require('./util/state-eventemitter'), | |
Deferred = require('./util/deferred'), | |
Crypto = require('./util/crypto'), | |
PeerArray = require('./util/peerarray'), | |
XORSortedPeerArray = require('./util/xorsorted-peerarray'), | |
IterativeDeferred = require('./util/iterative-deferred'), | |
globals = require('./globals.js'), | |
RoutingTable = require('./dht/routing-table'), |
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
Deferred = require('./util/deferred'); | |
var linked_list = function(key) { | |
return { | |
value : key*key, | |
nextKey : (key <10) ? (key)+1 : false | |
}; | |
}; | |
var GetNext = Deferred.extend({ |
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 Deferred = require('./deferred'); | |
var IterativeMapReduce = module.exports = Deferred.extend({ | |
initialize: function() { | |
this.supr(); | |
this._mapOnFly; | |
//default finish function | |
this.finish_function = function(end_value, reducer_result) { | |
this.resolve(reducer_result); |
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
httpProxy = require('http-proxy'); | |
httpProxy.createServer({ | |
router: { | |
//UI | |
'kadoh.fr.nf' : '127.0.0.1:8080', | |
//bosh | |
'bosh.kadoh.fr.nf' : '127.0.0.1:5280', |
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
/* | |
* Classic example grammar, which recognizes simple arithmetic expressions like | |
* "2*(3+4)". The parser generated from this grammar then computes their value. | |
*/ | |
start | |
= additive | |
additive | |
= left:multiplicative tail:(additive_op multiplicative)* { return tail.reduce(function(n,t){return t[0](n,t[1])},left); } |