Skip to content

Instantly share code, notes, and snippets.

View pfrazee's full-sized avatar

Paul Frazee pfrazee

View GitHub Profile
@pfrazee
pfrazee / gist:4173942
Created November 30, 2012 05:35
hateoas
// HATEOAS
// if it's going to be the engine of application state........
// simple example
// ==============
var localStorage = link('httpl://localstorage.api');
var settings = localStorage.collection('settings');
settings.record('user').get(function(user) {
//...
});
@pfrazee
pfrazee / gist:4235975
Created December 7, 2012 19:49
implementing other framework examples
<form action="httpl://helloworld.ui" onchange="patch">
  <div>
  <p>First name: <input name="firstName" /></p>
  <p>Last name: <input name="lastName" /></p>
  </div>
  <output name="out"><h2>Hello, {{firstName}} {{lastName}}!</h2></output>
</form>
@pfrazee
pfrazee / gist:4945450
Last active December 13, 2015 17:08
Non-performant JS Patterns

It pains me to write this, because I prefer the more robust, function-composition-focused features of Javascript, but there's a threshold of performance where speed overrides elegance. After all, performance is half the reason that programming is skilled labor. So here we have it-- my list of performance benchmarks and advice.

The Unusable

Try / Catch -- Use conditionals instead

Try/Catch Performance may be pitting try/catch against an easy-to-optimize opponent, but it still makes a strong case.

Function Bind -- Use closure variables instead

@pfrazee
pfrazee / gist:5024177
Last active December 14, 2015 03:49
release notes for local 0.2

Local 0.2 release notes

2012/02/24 pfraze

Making meaningful interactions between distributed networks is an interesting problem. There are a couple existing projects, including shared protocols like tent.io, and shared software like diaspora. Local is focused on an approach that hasn't received a lot of attention yet: the browser's program model.


Browsers strongly isolate

<!DOCTYPE HSML>
<hsml>
<environment>
<!-- primitives -->
<camera type="perspective"></camera>
<plane edges="8">
<surface><h1>An octogon</h1></surface>
<!DOCTYPE HSML>
<hsml>
<environment>
<!-- complex shapes -->
<cube style="texture-color: rgba(255,255,255,0.5)">
<surface orient="bottom">
<pyramid sides="4" style="direction: 0,-1,0; texture-color: rgba(255,0,0,1.0); scale: 0.75%">
<surface>
this pyramid is inside the half-translucent cube
@pfrazee
pfrazee / configserver.js
Created April 19, 2013 18:03
A general-purpose configuration server which allows programs to define custom schemas, serves a standard config interface, and retains settings in a storage service
function ConfigServer() {
Environment.Server.call(this);
this.schemas = {};
this.values = {};
this.validators = {};
this.broadcasters = {};
var loc = window.location.pathname;
if (loc == '/') loc = '/index.html';
this.configNamespace = 'config'+(loc.replace(/\/|\./g,'_'));
@pfrazee
pfrazee / old-workerserver.js
Created April 19, 2013 18:18
Worker server from an early version of grimwire
Grim = (typeof Grim == 'undefined') ? {} : Grim;
(function(exports) {
// App Server
// ============
// EXPORTED
// an isolated region of the DOM
function AppServer(id) {
Environment.Server.call(this);
this.serversBroadcast = Link.broadcaster();
@pfrazee
pfrazee / gist:5436436
Last active December 16, 2015 12:39
should I unify the namespace?

When I started on Local, it wasn't clear what all was needed -- originally, it was just the LinkJS project. Then I had to make a Worker manager: MyHouse. Then I had to create client behaviors: CommonClient. Not to mention the promises lib and the couple of prototypes that Local added under the Environment namespace. So now, here's a quick overview of what's getting used in a Local deployment:

Local.Promise // yeah, the ONE thing under the Local namespace. Brilliant.
Link.dispatch()
Link.subscribe()
Link.Navigator
Link.Router
Link.Responder
Link.Headerer // it...helps you build response headers
@pfrazee
pfrazee / persona-server.js
Created April 22, 2013 20:59
old env server for mozilla's persona
// persona.js
// user-session controls using mozilla's persona
// current user (likely an email)
Environment.user = null;
// Widgets
// =======
// "log in / <username> log out"
function addPersonaCtrls(elem) {