Skip to content

Instantly share code, notes, and snippets.

Eric Ferraiuolo ericf

Block or report user

Report or block ericf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sanitizeUrl.js
/**
* Sanitize URL — Validate it looks like a URL, then make it less dirty.
*
* Oddnut Software
* Copyright (c) 2010 Eric Ferraiuolo - http://eric.ferraiuolo.name
* MIT License - http://www.opensource.org/licenses/mit-license.php
*
* Examples:
*
* 'Http://WWW.example.com/' » 'http://www.example.com/'
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: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', 'window.foo');
console.log(res.locals.state); // => window.foo = "foo";
app.expose('bar', 'window.bar');
console.log(res.locals.state); // => window.foo = "foo";
View gist:8443907
exports
.local
✓ should have a .local property
✓ should be the string "state"
.namespace
✓ should have a .namespace property
✓ should be null
.extend
✓ should have a .extend property
✓ should respond to .extend()
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'))
.then(parseCSS)
View gist:8025839
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
module.exports = function fileSizes(pureDir, callback) {
getModules(pureDir)
.then(getFileSizes.bind(null, pureDir))
View gist:8016919
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
module.exports = filesizes;
// -----------------------------------------------------------------------------
View gist:7760305
> var exposed = Exposed.create();
undefined
> var obj = {};
undefined
> Object.defineProperty(obj, 'foo', {
..... enumerable: true,
..... get: function () { return 'FOO'; }
..... });
{ foo: [Getter] }
> exposed.add('foo', obj);
You can’t perform that action at this time.