Skip to content

Instantly share code, notes, and snippets.

Alex Lawrence alexlawrence

Block or report user

Report or block alexlawrence

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:dbac7feae0917cecc484
makeFunctionWithMiddleware = (originalFunction) ->
_allFunctions = [originalFunction]
middleWearableFunction = ->
_allFunctions[0].apply null, arguments
middleWearableFunction.use = ([criteria]..., middleware) ->
nextFunction = _allFunctions[0]
decoratedMiddleWare = (args...) ->
if criteria and not criteria.apply(null, args)
nextFunction.apply null, args
else
View gist:e41c4c5f15f5992785c5
makeFunctionWithMiddleware = (originalFunction) ->
_allFunctions = [originalFunction]
decoratedFunction = ->
_allFunctions[0].apply null, arguments
decoratedFunction.use = (middleware) ->
nextFunction = _allFunctions[_allFunctions.length - 1]
_allFunctions.unshift (args...) -> middleware.apply null, args.concat nextFunction
decoratedFunction
someFunction = (a, b) ->
@alexlawrence
alexlawrence / overloaded.js
Last active Jan 1, 2016
Function overloading.
View overloaded.js
var overloaded = function() {
var functions = Array.prototype.slice.call(arguments, 0);
return function() {
try {
var functionToInvoke = functions.filter(function(x) {
return x.length == arguments.length;
})[0];
functionToInvoke.apply(this, arguments);
}
@alexlawrence
alexlawrence / String.format.js
Last active Dec 15, 2015
String.format like in C#
View String.format.js
String.format = function(f) {
return Array.prototype.slice.call(arguments,1).reduce(function(o,v,i){return o.replace('{'+i+'}',v);},f);
}
View README.md

Node.js for Raspberry Pi

This is a very old gist - it may not work nor be correct anymore. Use everything at your own risk. See http://n8.io/cross-compiling-nodejs-v0.8/ for something slightly more up-to-date.

OpenSSL has been problematic in the past, use --without-ssl first to determine if it's a problem with node or OpenSSL.

Pre-built binaries

You can’t perform that action at this time.