This file contains 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 proc = require('child_process'); | |
var stream = require('stream'); | |
var DELIMITER = new Buffer('\n---------------\n'); | |
var phantom = proc.spawn('phantomjs', ['phantom2.js']); | |
var urls = [ | |
'http://sorribas.org', | |
'http://e-conomic.com', |
This file contains 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
IEUser@IE9WIN7 ~/test | |
$ npm i leveldown-prebuilt | |
npm http GET https://registry.npmjs.org/leveldown-prebuilt | |
npm http 304 https://registry.npmjs.org/leveldown-prebuilt | |
npm http GET https://registry.npmjs.org/node-pre-gyp | |
npm http GET https://registry.npmjs.org/bindings | |
npm http GET https://registry.npmjs.org/nan | |
npm http GET https://registry.npmjs.org/abstract-leveldown | |
npm http 304 https://registry.npmjs.org/bindings | |
npm http 304 https://registry.npmjs.org/node-pre-gyp |
This file contains 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 storage = require('...') | |
var st = storage('./directory', torrent) | |
// the files will be stored as ./directory/file1.ext | |
// ./directory/file2.ext | |
// etc | |
st.put(index, piece, callback) | |
st.get(index, {start:0, end:10}, function(err, buffer) { |
This file contains 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 osmdata = protobuf([{ | |
name: 'stringtable', | |
type: 'bytes', | |
tag: 1 | |
}, { | |
name: 'primitivegroup', | |
type: 'bytes', | |
tag: 2 | |
}, { | |
name: 'granularity', |
This file contains 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 torrentStream = require('torrent-stream') | |
var engine = torrentStream(require('fs').readFileSync('osm.torrent')) | |
engine.connect('172.16.16.162:61000') | |
engine.on('ready', function() { | |
console.log(engine.files[0].name) | |
engine.files[0].select() | |
}) |
This file contains 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 replication = require(...) | |
var r = replication(datInstance) | |
var socket = net.connect(9090, 'localhost') | |
socket.pipe(r.createPushStream()).pipe(socket) |
This file contains 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 replicator = require('dat-replicator') | |
var request = require('request') | |
var Dat = require('dat') | |
var dat = new Dat('./', function(err) { | |
if (err) throw err | |
var req = request.post('http://localhost:6461/api/replicator/send') | |
var receive = replicator(dat).receive() |
This file contains 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
BinaryEncoding { | |
string key = 1 | |
uint32 version = 2 | |
Schema document = 3 | |
} | |
Schema { | |
// whatever is defined by the dat schema | |
} |
This file contains 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 progress = replicator.createPullStream(remote) | |
progress.bytes // how many bytes transferred | |
progress.documents // how many documents ... | |
progress.blobs // how many blobs | |
progress.on('update', function() { | |
// something has changed | |
}) |
This file contains 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 stream = require('stream') | |
var rs = new stream.Readable() | |
rs.push('hello') | |
rs.push('world') | |
rs._read = function() {} | |
var sameTick = true | |
rs.on('data', function() { |