Skip to content

Instantly share code, notes, and snippets.

View ericf's full-sized avatar

Eric Ferraiuolo ericf

View GitHub Profile
@ericf
ericf / CSP + SPDY Push.md
Last active August 29, 2015 14:05
CSP + SPDY Push

SPDY Push for Externalizing Dynamic Inline Scripts for CSP

This is a rough outline of some thoughts on how to leverage [SPDY Push][SPDY] externalize inline <script>s that contain dynamic, page/user-specific configuration and state data to align with [CSP][].

Problem

We are building web apps where the initial rendering (HTML) is built server-side, and in order for the client-side JavaScript app to take over, the app's configuration and initial state are written to an inline <script> element.

"use strict";
var _ = SM.import('lodash');
var DOM = SM.import('sm-dom');
var Uri = SM.import('sm-uri');
// WebKit (as of version 538.35.8) fires a useless popstate event after every
// page load, even when the page wasn't popped off the HTML5 history stack. We
// only want to handle popstate events that result from a page actually being
// popped off the HTML5 history stack, so we need a way to differentiate between
const INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT';
function reducer(state, action) {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
}
}
<!doctype html>
<html>
<head>
<title>Test Page</title>
</head><body>
<input type="hidden" id="task1" value="Node loaded from YQL">
<ul id="tasks"></ul>
var supportedMimeTypes = ['video/mp4', 'video/x-ms-wmv'];
var supportedVideoExtensions = ['.mp4', '.wmv', '.mp4v', '.m4v'];
var getSupportedMediaSource = function(videoElement)
{
// If the video element source is supported, then we replace the tag.
if (videoElement.src
&& isWMPSupported(videoElement))
{
@cowboy
cowboy / jquery-widget-bootstrap.js
Created February 8, 2011 16:56
Experimenting with loading widgets that are dependent on jQuery...
/*!
* jQuery Widget Bootstrap - v0.3 - 02/11/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(jq_ver, jq_min, fn) {
diff --git a/src/jsonp/js/jsonp.js b/src/jsonp/js/jsonp.js
index f6f6b44..91d2634 100644
--- a/src/jsonp/js/jsonp.js
+++ b/src/jsonp/js/jsonp.js
@@ -122,6 +122,9 @@ JSONPRequest.prototype = {
// In case additional requests are issued before the current reques
// returns, don't remove the proxy.
self._requests++;
+ if (!('_timeouts' in self)) {
+ self._timeouts = 0;
@lsmith
lsmith / iOS_details_arrow.css
Created March 6, 2011 07:56
The CSS to create an iOS details call-to-action arrow
/* assumes .details is position: relative */
.details::after {
content: '';
position: absolute;
border-top: 3px solid #7f7f7f;
border-right: 3px solid #7f7f7f;
height: 6px;
width: 6px;
top: 50%;
right: 12px;
@lsmith
lsmith / gist:895834
Created March 31, 2011 04:49
Thoughts on adding HTML_PARSER support to Plugin.addHostAttr sugar for Plugins.
Y.Plugin.addHostAttr = function (name, host, plugin) {
host.ATTRS[name] = {
setter: function (val) {
var config = isObject(val) ? val : {},
method = (val) ? 'plug' : 'unplug',
widgetProto = Widget.prototype;
this[method](plugin, config);
if (val && (host.prototype === widgetProto || widgetProto.isPrototypeOf(host.prototype))) {
@ericf
ericf / gist:961730
Created May 8, 2011 22:12
A simple, small, and powerful CSS Grid System (based on YUI 3 CSS Grids)
/* Based on YUI 3 CSS Grids: http://developer.yahoo.com/yui/3/cssgrids/ */
.layout {
letter-spacing: -0.31em; /* webkit: collapse white-space between units */
*letter-spacing: normal; /* reset IE < 8 */
word-spacing: -0.43em; /* IE < 8 && gecko: collapse white-space between units */
}
.layout > *,
.layout .unit {
display: inline-block;
zoom: 1; *display: inline; /* IE < 8: fake inline-block */