Each DAT has a large hex id (chosen at random), which has several purposes:
- it inequivocally identifies the DAT archive itself
- it is used to encrypt the archive along the wire between peers
- it remains the same during DAT changes
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
function sleep2(n) { | |
return new Promise(resolve => { | |
console.log('FIRED ' + n); | |
sleep(500).then(() => {console.log(n); resolve(n); }); | |
}); | |
} |
Each DAT has a large hex id (chosen at random), which has several purposes:
Allows one to preview MPEG ISO BMFF atoms in JS. ISO BMFF MPEG4 Atom Registry
Assumes the mp4lib from Orange though shouldn't differ much in other impls.
Example output:
/
ftyp 28
moov 679
mvhd 120
Renders binary content such as Uint8Arrays to an hex layout similar to hex editor such as Hex Fiend and Frhed
Example output:
0000 0000001c 66747970 69736f36 00000001 69736f6d 69736f36 6d736468 000002a7
0020 6d6f6f76 00000078 6d766864 01000000 00000000 00000000 00000000 00000000
0040 00989680 00000000 53291000 00010000 01000000 00000000 00000000 00010000
0060 00000000 00000000 00000000 00010000 00000000 00000000 00000000 40000000
0080 00000000 00000000 00000000 00000000 00000000 00000000 00000002 000001ff
const CHARS = `αβγδϵζηθικλμνξοπρστυϕχψωΓΔΘΛΞΠΣΦΨΩ`; | |
function replaceAll(txt, a, b) { | |
return txt.split(a).join(b); | |
} | |
function generateCrunchedCode(code, replacements) { | |
let a = code; | |
let b = ''; |
// HAND MADE JSCRUNCH | |
ORIGINAL_CODE = '-que tal está isso asd? quero que fiques comigo querida asd.' | |
// naive approach | |
// 1) replace 'que' with '' | |
_ = '- tal está isso asd? ro fis comigo rida asd.' | |
_.split('').join('que') |
'use strict'; | |
// call something before the method(s) | |
function toArr(arrLike) { | |
return Array.prototype.slice.apply(arrLike); | |
} | |
function beforeMethod(parent, methodName, beforeFn) { |
'use strict'; | |
function parseTime(s) { | |
let t = 0; | |
const p = s.split(':'); | |
let ss = p.pop().replace(',', '.'); | |
t += parseFloat(ss); | |
ss = parseInt( p.pop() || '0', 10); | |
t += ss * 60; | |
ss = parseInt( p.pop() || '0', 10); |
Verifying that "josepedrodias.id" is my Blockstack ID. https://onename.com/josepedrodias |
'use strict'; | |
const fs = require('fs'); | |
const http = require('http'); | |
const os = require('os'); | |
const HEADERS = { | |
'Content-Type': 'application/json', |