Skip to content

Instantly share code, notes, and snippets.

View joehand's full-sized avatar
🌳
be like tree

Joe Hand joehand

🌳
be like tree
View GitHub Profile
@joehand
joehand / example-cli.js
Last active November 7, 2016 20:58
Dat API notes
var path = require('path')
var raf = require('random-access-file')
var Dat = require('.')
var DatFs = require('dat-fs')
var dat = new Dat()
var datFs = DatFs(dir)
// These will be set in CLI via commands, opts, etc.
@joehand
joehand / lab-group.md
Last active September 22, 2016 16:19
Hypercloud Use Case Example

Dat Research Lab Group (Dat Group)

Dat Group wants to manage their data in Dat. They have to put it online somewhere with HTTP endpoint for publishing in a journal, data.datgroup.com. They also want to share it on the Dat network without keeping their computers online as peers.

The IT admin for Dat Group sets up a hypercloud on their lab servers where there is a persistent connection and lots of storage:

npm install -g hypercloud
@joehand
joehand / index.js
Created August 6, 2016 00:06
requirebin sketch
var yo = require('yo-yo')
document.body.appendChild(Component1(123))
function Component1 (counter) {
counter1 = counter2 = counter
function template () {
return yo`
<div>
<button style="background-color:blue;" onclick=${update2}>
@joehand
joehand / test_multiple.js
Created August 4, 2016 22:25
Hyperdrive Test mtime for multiple files
tape('mtime preserved', function (t) {
var drive = hyperdrive(memdb())
var archive = drive.createArchive({
file: function (name) {
return raf(path.join(__dirname, name))
}
})
fs.readdir(__dirname, function (_, files) {
consumeFile(files.shift())

Keybase proof

I hereby claim:

  • I am joehand on github.
  • I am jhand (https://keybase.io/jhand) on keybase.
  • I have a public key whose fingerprint is 0DCA 20C9 50DB D73A A63C DCFF 2232 4E3F 975F BBE6

To claim this, I am signing this object:

function kick (dir, stat, first) {
var fileStream = walker(dir)
each(fileStream, function (data, next) {
if (first) watcher.add(data.filepath)
else if (!stats[data.filepath]) {
watcher.add(data.filepath)
watcher.emit('change', data.filepath, data.stat)
}
stats[data.filepath] = data
next()
@joehand
joehand / index.js
Last active March 4, 2016 21:30
Async Hyperdrive Append
var Hyperdrive = require('hyperdrive')
var Level = require('level')
var Swarm = require('discovery-swarm')
var swarmDefaults = require('datland-swarm-defaults')
var walker = require('folder-walker')
var each = require('stream-each')
var db = Level('./dat.db')
var drive = Hyperdrive(db)
@joehand
joehand / index.js
Last active March 4, 2016 00:26
Dat Link Basic Example
var Hyperdrive = require('hyperdrive')
var Level = require('level')
var Swarm = require('discovery-swarm')
var swarmDefaults = require('datland-swarm-defaults')
var walker = require('folder-walker')
var each = require('stream-each')
var db = Level('./dat.db')
var drive = Hyperdrive(db)
@joehand
joehand / index.js
Last active January 9, 2017 00:18
Dat Download Basic
var Hyperdrive = require('hyperdrive')
var Level = require('level')
var Swarm = require('discovery-swarm')
var swarmDefaults = require('datland-swarm-defaults')
// run this like: node thisfile.js 4c325f7874b4070blahblahetc
var link = new Buffer(process.argv[2], 'hex')
var LOCAL_PORT = Number(process.argv[3]) || 3282 // specify port or use 3282
var db = Level('./dat.db')