Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
@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: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);
// helper to make an array of objects
function table(keys) {
var obj, i, j=-1;
var arr = [];
for (i=1, j; i < arguments.length; i++, j++) {
if (!keys[j]) { if (obj) { arr.push(obj); } obj = {}; j = 0; } // new object
obj[keys[j]] = arguments[i];
}
arr.push(obj); // dont forget the last one
return arr;
@pfrazee
pfrazee / gist:11199961
Last active August 29, 2015 14:00
Current status

Current status:

systems are go

@pfrazee
pfrazee / 0_basic_example.js
Last active August 29, 2015 14:01
more web -> language binding
web.export(main);
function main() {
// do nothing (returns 204 on HEAD or GET)
}
main.method(POST);
POST.Accept('json');
POST.ContentType('json');
function POST(req, res) {
if (!req.body) {
@pfrazee
pfrazee / prototype_based.js
Last active August 29, 2015 14:02
even more web -> language binding
// 0_basic_example.js#
web.export(Main);
function Main(env, req, res) {
this.Allow('GET', 'POST');
}
Main.prototype = {
get: function(params) {
return 'Hello, ' + (params.who||'World');
},
post: function(params, body) {