Skip to content

Instantly share code, notes, and snippets.

View morganney's full-sized avatar
🌳

Morgan Ney morganney

🌳
View GitHub Profile
@morganney
morganney / gister-app-sample.js
Last active August 29, 2015 13:55
Example Usage of Backbone PostView Employing Gister
/*
* Sample usage of the PostView.
* Note, this example assumes that the model is used outside of a collection
* and the post content contains elements with a data-gistId attribute.
* For example:
* <code data-gistId='12345'></code>
*/
require.config({/* The configuration needed for your app to work with RequireJS. */});
@morganney
morganney / start-restbus.js
Last active May 20, 2017 22:28
Example starting restbus.
// Standalone server
require('restbus').listen(3000, function() {
console.log('restbus is now listening on port 3000');
});
// Embedded
var app = require('express');
var restbus = require('restbus');
// (As express middleware)
@morganney
morganney / restbus-error-example.json
Created February 15, 2014 08:26
restbus API error.
{
"status": 404,
"statusDesc": "Not Found",
"message": "The requested URI can not be found on this server."
}
@morganney
morganney / restbus-hateoas-hypertext.js
Last active August 29, 2015 13:56
Hypertext structure for the restbus API resource "_links".
{
// ... some resource's JSON representation ...
_links: {
/**
* EVERY resource links to its own canonical representation which may
* or may not be located at the current context URI, i.e. depending on
* the current context, an actual state transition might or might not
* occur when dereferencing the link.
@morganney
morganney / restbus-full-links-example.js
Last active August 29, 2015 13:56
Hypertext links example for a restbus API agency resource.
@morganney
morganney / socoapi-server.js
Created April 20, 2014 02:13
Starting the socoapi server.
// Standalone
var socoapi = require('socoapi');
socoapi.listen('3535', 3600000, function() {
console.log('socoapi listening on port 3535');
});
// Embedded
var app = require('express')()
, socoapi = require('socoapi')
@morganney
morganney / socoapi-response.json
Last active May 30, 2016 20:46
Sample response from socoapi API
{
"facebook" : 1434,
"google" : 517,
"pinterest": 160,
"url" : "http//www.foobar.baz/?q1=v1&q2=v2"
}
@morganney
morganney / socoapi-reverse-proxy-config.apacheconf
Last active August 29, 2015 14:00
Example of an Apache reverse proxy configuration for socoapi
NameVirtualHost *:80
<VirtualHost *:80>
ServerName myapp
DocumentRoot /path/to/myapp/doc/root
ProxyPreserveHost On
ProxyPass /socoapi http://127.0.0.1:3535
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
ProxyPassReverse /socoapi http://127.0.0.1:3535
@morganney
morganney / performance-entry.js
Created September 27, 2014 17:43
Resource Timing API Performance Entry
{
connectEnd: 318.862000000081
connectStart: 318.862000000081
domainLookupEnd: 318.862000000081
domainLookupStart: 318.862000000081
duration: 53.30899999989924
entryType: "resource"
fetchStart: 318.862000000081
initiatorType: "link"
name: "http://www.foobar.com/blog/wp-content/themes/foobar/style.css"
@morganney
morganney / resource-type-hierarchy.js
Last active August 29, 2015 14:06
A Nested JSON Hierarchy by Type from Resource Performance Entries
function getJSONResourceHierachy() {
var images = {png: 1, jpg: 1, jpeg: 1, gif: 1, tif: 1, tiff: 1, bmp: 1, ico: 1, svg: 1}
, entries = window.performance.getEntriesByType('resource')
, length = entries.length
, archy = {}
, entry = undefined
, name = undefined
, mt = undefined
;