Skip to content

Instantly share code, notes, and snippets.

View dschnare's full-sized avatar

Darren Schnare dschnare

View GitHub Profile
@dschnare
dschnare / index.correct.jade
Last active December 18, 2015 12:49
Sharing Variables with Jade Templates: Examples of how and how not to share variables across a template and layout.
extends layout
prepend page
- title = "Home"
block body
p This is the \#{title} page
@dschnare
dschnare / interpolation.js
Last active May 26, 2016 18:01
Ruby-style string interpolation for JavaScript.
// Author: Darren Schnare
// Keywords: javascript,interpolation,string,ruby
// License: MIT ( http://www.opensource.org/licenses/mit-license.php )
// Repo: https://gist.github.com/gists/3886395
String.prototype.interpolate = function (o) {
return this.replace(/#\{(.+?)\}/g, function ($0, $1) {
with (o) {
return eval($1);
}
});
@dschnare
dschnare / equals.js
Created September 29, 2011 15:31
EqualsJS - Deep equality testing for JavaScript.
// Author: Darren Schnare
// Keywords: javascript,equality,testing,equals,object
// License: MIT ( http://www.opensource.org/licenses/mit-license.php )
// Repo: https://gist.github.com/1251001
// Creates an equals function within the specified scope.
(function(scope) {
// Determines if two objects have the same values. This is a
// recursive test that tests all objects through out the object
// tree.
@dschnare
dschnare / aop.js
Last active February 28, 2023 01:58
AopJS - A lightweight aspect oriented programming (AOP) API for JavaScript.
// Author: Darren Schnare
// Keywords: aop,aspect,oriented,programming,javascript,pointcut
// License: MIT ( http://www.opensource.org/licenses/mit-license.php )
// Repo: https://gist.github.com/1235559
// Inspiration: http://karlagius.com/2008/04/25/aspect-oriented-programming-in-javascript/
// Reference: http://docs.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/advices.html
// Reference: http://static.springsource.org/spring/docs/2.0.x/reference/aop.html
// Appends the aop namespace to the specified scope (defaults to global).