Skip to content

Instantly share code, notes, and snippets.

Matthew Mueller matthewmueller

Block or report user

Report or block matthewmueller

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 gist:2641307
#!/usr/bin/env node
var nom = require('nom'),
join = require('path').join,
args = process.argv.slice(2);
if(!args[0]) {
console.log('Usage: read <url>');
process.exit(0);
}
@matthewmueller
matthewmueller / express-layout.js
Created Jun 14, 2012
Basic, synchronous way of supporting layouts in express 3.x
View express-layout.js
app.engine('mu', function(path, options, fn) {
var views = app.get('views'),
view = path;
if(options.layout) {
view = join(views, '..', options.layout);
options.body = fs.readFileSync(path, 'utf8');
}
cons.hogan(view, options, function(err, str) {
@matthewmueller
matthewmueller / express-layout.js
Created Jun 14, 2012
Basic, synchronous way of supporting layouts in express 3.x
View express-layout.js
app.engine('mu', function(path, options, fn) {
var views = app.get('views'),
view = path;
if(options.layout) {
// Assumes layouts and views are at same level
view = join(views, '..', options.layout);
options.body = fs.readFileSync(path, 'utf8');
}
@matthewmueller
matthewmueller / index.js
Created Jun 24, 2012
Javascript: express 3 boilerplate
View index.js
var express = require('express'),
cons = require('consolidate'),
port = process.argv[2] || 8080,
app = express();
app.engine('html', cons.hogan);
app.set('view engine', 'html');
app.set('views', __dirname);
app.configure(function() {
@matthewmueller
matthewmueller / toggle.js
Created Aug 12, 2012
Toggle between two or more functions
View toggle.js
/**
* toggle between n functions
*
* Example:
*
* var a = function(p) { console.log("a:", p); };
* var b = function(p) { console.log("b:", p); };
*
* var func = toggle(a, b);
* func('hi') // => "a: hi"
@matthewmueller
matthewmueller / lazy-load-redux-action.js
Last active Oct 9, 2015
Non-working lazy-load redux action. The reason it doesn't work is because webpack cannot resolve dynamic paths (without assistance). Makes sense to create a loader like `react-proxy-loader` that will generate this. Then you can stick this in middleware and be done.
View lazy-load-redux-action.js
/**
* Module Dependencies
*/
var relative = require('path').relative
/**
* Action
*/
View clean.js
/**
* Written by Jonathan Bolster
* Blog Post: http://bolsterweb.com/2011/10/how-clean-is-your-window-object/
*/
(function(window){
var keys = {},
cleanWindow,
iframe = document.createElement("iframe");
iframe.style.display ="none";
@matthewmueller
matthewmueller / bind.js
Created Aug 25, 2012
super basic bind function
View bind.js
function __bind(fn, context) {
return function() {
return fn.apply(context, arguments);
};
}
@matthewmueller
matthewmueller / index.js
Created Sep 5, 2012
vhost on separate paths
View index.js
var express = require('express'),
app = module.exports = express();
app.use('/a', express.vhost('*', require('./a')));
app.use('/b', express.vhost('*', require('./b')));
app.listen(8080);
View index.js
var Debug = require('redux-debug')
var debug = require('debug')
var assign = require('object-assign')
var thunk = require('redux-thunk')
var Redux = require('redux')
function store_enhancer (options) {
return function (next) {
return function (reducer, initial_state) {
You can’t perform that action at this time.