Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
@pfrazee
pfrazee / proxies.md
Last active January 3, 2016 08:59
Pro opinions plz

Background: The host page proxy

From inside a worker server, the only external hostname is "httpl://host.page"

To reach anything, the worker proxies through the hostpage.

"httpl://host.page/http%3A%2F%2Fexplorer%2F"
@pfrazee
pfrazee / gist:8545051
Last active January 4, 2016 00:59
Trying to add request bodies to the CLI

RESH, the REst SHell

A basic command:

GET foo/bar -Accept=text/html

Rewritten:

GET foo/bar [text/html]

@pfrazee
pfrazee / gist:8694739
Last active August 29, 2015 13:55
JSON DB api mockup
// DATA STORE API
importScripts('/js/guip/jsondb-1.0.0.js');
var data = guip.jsonDB();
data.select(where, { order:, limit:, offset:, groupBy: })
data.get(id)
data.getMeta(id)
data.insert(doc, meta, perms)
data.update(id|where, doc, meta, perms)
data.updateMeta(id|where, meta)
@pfrazee
pfrazee / gist:8837380
Last active August 29, 2015 13:56
how guipedia will configure

User Agents are objects which wrap URLs which are known as the "location" or the "context." They fetch and cache the index from their location, then query the index's meta-data for links to new URLs. A new Agent is created to wrap the matching URL. It maintains a back-reference to its parent, and is known as having a "relative context."

Fetching the index is known as "resolution," and is triggered by the first resolve() or dispatch() call. If the Agent is relative, its parent may need resolution first, so the full ancestry is triggered to resolve in the process. The unresolve() function will clear the cache of the Agent so that it will re-resolve on its next dispatch.

It's useful for me to think of Agents as database cursors.

RUSH (sorry bri, I have to... for the Getty) has a syntax for specifying an Agent in its requests:

  myagent> GET foobar-generator
@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 / gist:8958717
Last active February 26, 2020 11:25
Communicating with Workers using HTTP

Communicating with Workers using HTTP

A design rationale.

See first: In-Application Sandboxing with Web Workers.

Web Workers interact with their Host Pages using a messaging channel (the postMessage API). Crucially for their programming model, the messages are asyncronous. This introduces a significant challenge for implementing Page APIs within a Worker – for instance, how do you port a GUI widget from the Page (where it can access the DOM) to a Worker, where it can only send async messages?

In my experience, two categories of solutions are suggested: use code-transformations to recreate Page-native APIs in the Worker, or introduce a new interface around messaging. In this gist, I'll explain why code transformations don't address the problem fully, and present a complete messaging solution based on HTTP.

@pfrazee
pfrazee / gist:9026680
Last active August 29, 2015 13:56
Plugin-driven Web Applications
@pfrazee
pfrazee / gist:9037612
Last active August 29, 2015 13:56
Server Objects, and How VMs are Bridged

Server Objects, and How VMs are Bridged

diagram

Every VM has multiple server objects

  • they make up the httpl:// namespace
  • may be functions or objects with a handleLocalRequest method

"Bridge" servers wrap the postMessage interfaces

  • a request to httpl://the-worker is postMessageed
var myitems = [];
testserver.route('/protocol/crud-coll')
.link({ href: '/protocol/crud-coll', rel: 'self', title: 'My Collection' })
.protocol('stdrel.com/crud-coll', {
itemUrl: '/protocol/crud-coll/{id}',
validate: function(item, req, res) {
var errors = {};
if (!item.fname) errors.fname = 'Required.';
if (!item.lname) errors.lname = 'Required.';
return errors;
@pfrazee
pfrazee / webscript.js
Last active August 29, 2015 13:58
How can the underlying protocols of services be abstracted into the language itself? Looking at it here with a transpiled JS language, but a library might work as well. Best past attempt is a JS library, https://github.com/pfraze/servware, which is convenient, but still exposes the HTTP. This removes protocol details (headers, status codes) enti…
// defining services
var usersCollection = [];
service Main {
link collection = Users;
meta rel = 'service';
meta id = 'main';
}
local.hostChannel.bind(Main);