Skip to content

Instantly share code, notes, and snippets.

View jweaver's full-sized avatar

Jack Weaver jweaver

  • ~/
View GitHub Profile
@jweaver
jweaver / proxy-example
Created August 10, 2013 23:54
How to use a Proxy (example). Useful for debugging, as logging can be done as the object under proxy is changed for any value(s).
var engineer = { name: 'Joe Sixpack', salary: 50 };
var interceptor = {
set: function (receiver, property, value) {
console.log(property, 'is changed to', value);
receiver[property] = value;
}
};
engineer = Proxy(engineer, interceptor);
@jweaver
jweaver / app.js
Created August 25, 2012 21:43
Wrapping Repojs as an Angularjs Directive
var myApp = angular.module('myApp', []);
myApp.directive('repository', function() {
return {
restrict: 'C',
scope: {
owner: '@repoOwner',
name: '@repoName'
},
link: function(scope, element, attrs, controller) {
//attach to 'repoOwner' due to ordering of attributes in element. TODO: Is there a better way?