Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
TAP version 13
# start test server
connecting to http://127.0.0.1:8080
ok 1 undefined
# share test-dat
Wed, 28 Dec 2016 02:26:26 GMT rabin chunks []
created dat cf1df1995f7e99f97efcbb0f0a1e4691904f1a5bfd3c53e25a74d1fb7d26f2a6 from /Users/paulfrazee/pubpeer/hypercloud/test/scaffold/testdat1
ok 2 null
Wed, 28 Dec 2016 02:26:26 GMT discovery-channel chan=af36f8..8f join()
Wed, 28 Dec 2016 02:26:26 GMT dns-discovery announce() af36f8c56f7b0182a39ea5d0de657a82fb7cb2e7
@pfrazee
pfrazee / 1-summary.md
Created December 22, 2016 18:27
replication issue in dat

Ive got a hypercloud server running on my localhost

in the same thread, I run the following code:

exports.downloadDatFromSwarm = function (key, { timeout = 5e3 }, cb) {
  var dir = fs.mkdtempSync(os.tmpdir() + path.sep + 'beaker-test-')
  Dat(dir, { key, db: memdb() }, (err, dat) => {
    if (err) return cb(err)
archive.metadata.peers.forEach((peer) => {
console.log('resetting', upload, peer)
archive.unreplicate(peer.stream)
archive.replicate({ stream: peer.stream, upload })
})
// this is the initial setup of the hosted archives
bittorrent-dht [3a8d6f7] new DHT 3a8d6f73a9d03bf56c75d6d47b4697a8c6666dd9
bittorrent-dht [3a8d6f7] received find_node query from 76.30.122.143:42107
discovery-channel whoami() succeeded, I am: { port: 3282, host: '72.182.50.76' }
dat Swarming archive 0ff7d4c7644d0aa19914247dc5dbf502d6a02ea89a5145e7b178d57db00504cd
discovery-channel chan=cb85b9..aa join()
discovery-channel chan=cb85b9..aa dns announce
discovery-channel chan=cb85b9..aa dht announce

Dat file-path duck-typing

In the /log reader, I'm using pathnames to infer the content-types, and schemas, of data-files stored in dats. It will assume that files which match against /log/*.txt are text/plain files which should be listed in this application's feed.

My thinking is, this is a 1) convenient 2) simple and 3) descriptive-enough way to handle data meta-information. It's more convenient than writing out explicit metadata in the dat.json file, and it's also easy to write path-matching rules for (using unix path-globs).

Some example duck-typing rules:

  • /dat.json - the dat metadata file
@pfrazee
pfrazee / 1-git-tips.md
Last active November 2, 2016 19:07
Some git tips

Two quick tips that I use all the time.

Tip 1: Shortcuts.

Put this file in your home directory somewhere (eg ~/.git-shortcuts):

Process: Electron [1091]
Path: /Users/USER/*/Electron.app/Contents/MacOS/Electron
Identifier: com.github.electron
Version: 1.4.4 (1.4.4)
Code Type: X86-64 (Native)
Parent Process: ??? [1090]
Responsible: Electron [1091]
User ID: 501
Date/Time: 2016-10-24 19:28:03.324 -0500

Keybase proof

I hereby claim:

  • I am pfrazee on github.
  • I am pfrazee (https://keybase.io/pfrazee) on keybase.
  • I have a public key whose fingerprint is 6085 F316 33C8 9FEF A9D9 BDDD FCA2 2EAB B025 7791

To claim this, I am signing this object:

@pfrazee
pfrazee / link-checker.js
Created September 17, 2016 20:02
Quick link-checker script for Jekyll sites
bundle exec jekyll build --watch &
cd _site; browser-sync start --server --files ./*