View compile.js
var browserify = require('browserify')
var fs = require('fs')
var concat = require('concat-stream')
var createHash = require('crypto').createHash
var b = browserify('main.js').bundle()
var pending = 2, hash = null
b.pipe(fs.createWriteStream('bundle.js'))
.once('finish', done)
View grid.js
var PI = Math.PI
var sin = Math.sin, asin = Math.asin
module.exports = function compute (opts) {
var nx = opts.xcount
var ny = opts.ycount
var xmin = opts.xmin
var xmax = opts.xmax
var ymin = opts.ymin
var ymax = opts.ymax
View scrub.js
#!/usr/bin/env node
var minimist = require('minimist')
var argv = minimist(process.argv.slice(2), {
alias: { i: 'ignore' },
string: [ 'ignore' ]
})
var to = require('to2')
var ignore = [].concat(argv.ignore)
var osmdb = require('osm-p2p')
View hmac_capability_system.md

hmac capability system

We can use HMACs to implement a distributed capability system.

var crypto = require('crypto')

var rootkey = crypto.randomBytes(32)
var propkey1 = hmac(rootkey, 'propname1')
var propkey2 = hmac(rootkey, 'propname2')
View hyperdrive.js
var level = require('level')
var hyperdrive = require('hyperdrive')
var db = level('/tmp/whatever.db')
var drive = hyperdrive(db)
var link = Buffer(process.argv[4], 'hex')
var archive = drive.createArchive(link, { live: true })
//console.log(archive.key.toString('hex'))
if (process.argv[2] === 'write') {
View digest.js
var hyperdrive = require('hyperdrive')
var memdb = require('memdb')
var drive = hyperdrive(memdb())
var archive = drive.createArchive({ live: true })
console.log(archive.key.toString('hex')) // stays the same
var digests = {}
commit0(function () {
commit1(function () {
View drive.js
var hyperdrive = require('hyperdrive')
var level = require('level')
var db = level('/tmp/test.db')
var drive = hyperdrive(db)
var cmd = process.argv[2]
var link = process.argv[3]
if (link) link = Buffer(link, 'hex')
View neocities_headers.txt
$ curl https://mafintosh.neocities.org -i
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 17 May 2016 09:56:06 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
X-Cached: EXPIRED
<body>
View drive.js
var hyperdrive = require('hyperdrive')
var memdb = require('memdb')
var drive = hyperdrive(memdb())
var archive = drive.createArchive()
archive.createFileWriteStream('hello.txt').end('BEEP BOOP\n')
archive.finalize(function () {
archive.createFileReadStream('hello.txt').pipe(process.stdout)
})
View server.js
var router = require('routes')();
router.addRoute("GET /articles/:title?", function (req, res, params) {
// perform some IO...
res.end('article content goes here...\n');
});
router.addRoute("POST /articles/:title", function (req, res, params) {
// perform some IO...
res.setHeader('content-type', 'text/plain');
res.end('updated ' + params.title + '\n');