Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Frazee pfrazee

  • Austin, TX
View GitHub Profile
@pfrazee
pfrazee / videos.js
Created May 27, 2021
Script for encoding & compressing MP4s in the browser
View videos.js
import bytes from '../../vendor/bytes/index.js'
const MAX_WIDTH = 600
const MAX_HEIGHT = 600
const { createFFmpeg, fetchFile } = FFmpeg
let ffmpeg
export async function compressAndGetThumb (file, maxVideoSize, progressCb) {
const objectUrl = URL.createObjectURL(file)
const videoEl = document.createElement('video')
videoEl.addEventListener('error', console.log)
@pfrazee
pfrazee / index.html
Created Oct 5, 2020
HPM app source (MVP of the app)
View index.html
<!doctype html>
<html>
<head>
<title>HPM</title>
<style>
body {
max-width: 800px;
margin: 0 auto;
padding: 0 10px;
}
@pfrazee
pfrazee / index.js
Last active Jun 17, 2020
Using SharedArrayBuffer and Atomics to do synchronous messaging from a Web Worker to the main thread
View index.js
const RES_SIZE = 256
const encoder = new TextEncoder('utf8')
var myWorker = new Worker('/worker.js')
console.log(myWorker)
const exportedMethods = {
hello (str) {
return `hello ${str}`
}
View webterm.peg
// Webterm Input Grammar (PEG.js)
// ==============================
Expression
= Term+
Term
= term:Switch _? { return {type: 'param', key: term.key, value: term.value} }
/ term:String _? { return {type: 'token', value: term} }
@pfrazee
pfrazee / theme.css
Created Jan 31, 2020
Simple Wiki Theme
View theme.css
body {
--light-gray: #f7f7fc;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
margin: 0;
display: grid;
grid-gap: 10px;
grid-template-columns: 300px 1fr;
grid-template-rows: 100px 1fr;
min-height: 100vh;
@pfrazee
pfrazee / DatArchive.dream.js
Last active Aug 27, 2019 — forked from RangerMauve/DatArchive.dream.js
Dream DatArchive API for extensions / peers
View DatArchive.dream.js
const archive = await DatArchive.load('someurl')
var fooExt = archive.extension('foo')
// listen to 'foo' messages from all peers
fooExt.addEventListener('message', ({detail}) => {
const {message, peer} = detail
// send to one peer:
await peer.extension('bar').send('Hello World')
View 0-about.md

For the theme, I'm leaning toward using a template file.

  • The "theme dat" has been mounted to the site's /theme directory.
  • User visits /index.html on the site
    • The /theme/template.html file is loaded.
    • The /index.html file is loaded.
  • Output is constructed:
    • The template <!-- TEMPLATE-CONTENT --> string gets replaced with the content of /index.html
    • The resulting string is served.
View notes-on-dns-in-beaker.md

DNS handling in beaker

Dat site "Primary URL" (pURL)

Within Beaker, all Dat sites have a "Primary URL" (pURL). This is dat://{key} by default. Dat sites can assign multiple DNS short names, but the pURL will only be changed to a DNS shortname if the site's dat.json assigns a "domain" value. This value will be confirmed against the DNS record.

Therefore the "Primary URL" can be visualized as:

var hostname = key
View dat-simple-directory.md

Dat Simple Directories (DSD)

The premise of Dat Simple Directories (DSD) is that organizations such as companies, schools, agencies, and communities can act as the backbone of global identity.

Organizations will typically have the following desirable properties:

  • The resources to deploy websites with DNS and SSL
  • A need to maintain and publish their membership
  • An interest in maintaining their reputation
View beaker-dat-modules-proposal.md

Beaker/Dat code modules proposal

Like node and other platforms, Beaker will need a way to share modules of code and other assets. The Web's ES Modules give us a lot of the tooling for importing and exporting javascript, but we still need solutions for publishing, versioning, and "installing" dependencies.

This is a proposal to use Dat archives and ES Modules in Beaker to solve code-sharing.

Overview

"Module" dat archives have a folder structure that includes the current development code in /dev and any frozen versions in /v. A trivial example of that folder structure: