Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
@pfrazee
pfrazee / theme.css
Created January 31, 2020 14:16
Simple Wiki Theme
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 / gist:8949363
Last active August 22, 2023 12:31
In-Application Sandboxing with Web Workers

In-Application Sandboxing with Web Workers

A design rationale.

For the past fews years, the Web has been shifting control to the client. Given the limitations of remote services, developers are now looking for ways to "unhost" static applications – that is, break the dependency on remote servers while still using the Web platform.

One untapped technology for client-side control is the Web Worker Sandbox. This API lets the Page load, execute, and destroy separate Worker threads which use their own Virtual Machines. By using Worker Sandboxes to drive behavior, the Web can give users the choice of which software they run together, shifting development from a centralized SaaS model into a distributed and free (as in freedom) script-sharing model.

Worker Sandboxes can Execute Arbitrary Code

@pfrazee
pfrazee / index.js
Last active August 18, 2023 20:20
Using SharedArrayBuffer and Atomics to do synchronous messaging from a Web Worker to the main thread
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}`
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pfrazee
pfrazee / schemas-design-doc-draft.md
Created June 8, 2022 20:22
An initial draft proposal of record schemas for Bluesky's ADX project.

Schemas Design Doc (draft)

Please note: The following document is an initial draft proposal. All decisions are subject to change. Our present goal is to collect feedback and iterate upon this document. Please feel free to share your suggestions and concerns.

Overview

ADX is a federated network for distributing data. It leverages cryptographic signatures and hashes to distribute authenticity proofs along with the data, enabling each node to transact upon the data independently of the data's origin. ADX might therefore be described as an Internet-native database in which records are replicated across nodes.

As a consequence of relying on authenticity proofs, ADX must exchange "canonical" records. That is, ADX records must be transmitted in their original encoding and structure in order to validate the signatures and hashes which comprise the proofs. This stands in contrast to the RESTful model of the Web in which "representations" of records are exchanged and therefore may be constructed at the ti

@pfrazee
pfrazee / austin-architecture.md
Created August 9, 2021 17:54
A draft architecture document for a Home Cloud project that's currently in development.

The Austin Architecture

PREFACE: This is an early draft of the still-untitled Home Cloud project's architecture. I'm sharing this as a kind of progress-report since I'm not ready to share code yet. Feedback is welcome but keep in mind that my head's still "in the details" so it may be hard to take too many suggestions at this stage. I'm sure lots of things will change as the rubber hits the road.

Since I don't have a name for the project yet, I'm using the temporary codename "Austin."

Austin uses a microservice cloud architecture with the following attributes:

  • Peer-to-peer networking
  • Strictly-defined protocols
/**
* Counter
*
* This contract maintains a single numeric value which can only be incremented.
*/
import { index } from 'contract'
// database api
// =
import bson from 'bson'
import bsonExt from 'bson-ext'
import cbor from 'cbor'
import { gzipSync, gunzipSync } from 'zlib'
const VALUES = [
{value: true},
{value: 1234},
{value: 'string'},
{foo: 'bar', thisIs: 1234, another: true},
@pfrazee
pfrazee / videos.js
Created May 27, 2021 01:28
Script for encoding & compressing MP4s in the browser
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)

Web Data Protocols ("Protos") Proposal

If you're in a rush: Skip the background material and see the proposal

I recently published a minimal Dat Identity Spec which establishes how we plan to move forward with user identities in Beaker. It establishes:

  • Identities are dat Websites (similar to Indie-Web)
  • Identifiers are domain names
  • User data is files on the dat sites
  • The browser will provide UIs and APIs to help manage access to the identities by apps. This will include a "sign in" metaphor which provides read & write access to the data.