Skip to content

Instantly share code, notes, and snippets.


Eric Ferraiuolo ericf

View GitHub Profile
ericf / timeago.js
Created Nov 11, 2015
<TimeAgo> with React Intl v2
View timeago.js
import React from 'react';
import {
} from 'react-intl';
const TimeAgo = ({date, intl}) => {
let year = intl.formatDate(date, {year: 'numeric'});
let month = intl.formatDate(date, {month: '2-digit'});
let day = intl.formatDate(date, {day: '2-digit'});
View messages.js
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
import {Component, Children, PropTypes} from 'react';
import {intlShape} from '../types';
import {invariantIntlContext} from '../utils';
ericf / CSP + SPDY
Last active Aug 29, 2015

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][].


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.

View gist:9255584
<!DOCTYPE html>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="stylesheet" href="">
<div class="pure-g">
View gist:8445982
'use strict';
var serialize = require('./serialize');
module.exports = Exposed;
function Exposed() {
Object.defineProperties(this, {
// Brand with constructor.
'@exposed': {value: Exposed},
View gist:8445732
Exposed.prototype._getApplicableNamespaces = function () {
var namespaces = this.__namespaces__.concat(),
proto = Object.getPrototypeOf(this);
function isApplicable(namespace) {
return !namespaces.some(function (ns) {
var nsRegex = new RegExp('^' + ns + '(?:$|\\..+)');
return nsRegex.test(namespace);
View gist:8444769
app.expose('foo', '');
console.log(res.locals.state); // => = "foo";
app.expose('bar', '');
console.log(res.locals.state); // => = "foo";
View gist:8443907
✓ should have a .local property
✓ should be the string "state"
✓ should have a .namespace property
✓ should be null
✓ should have a .extend property
✓ should respond to .extend()
View utils.js
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
var utils = require('../utils');
module.exports = function fileSizes(pureDir, callback) {
View gist:8026041
'use strict';
var fs = require('fs'),
path = require('path'),
parseCSS = require('css-parse'),
Promise = require('es6-promise').Promise;
module.exports = function gridUnits(pureDir, callback) {
readUnits(path.join(pureDir, 'grids-units.css'))