View gist:de3dfe15f3f0f30b86c1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.samurai.created = function () { | |
console.log(this); | |
} | |
Template.samurai.rendered = function () { | |
console.log(this); | |
} | |
Template.samurai.events({ | |
'click .sword': function (event, template) { |
View gist:18b539c5858876e6476e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Rectangle(h,w) { | |
var width=w; // Both the 'width' and 'w' is private | |
var heigth=h; // Both the 'height' and 'h' is private | |
this.setWidth= function(w){ width=w;} | |
this.setHeight= function(h){ heigth=h;} | |
this.getWidth= function(){ return width;} | |
this.getHeight= function(){ return heigth;} | |
this.constructor.prototype.getDiagonal=function() { | |
return Math.sqrt(heigth*heigth+width*width); | |
}; |
View gist:0b5b9e2adfe4c53067eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DOUBLE | |
console.log(99 == "99"); // true | |
console.log(0 == false); // true | |
//TRIPLE | |
console.log(99 === "99"); // false | |
console.log(0 === false); // false | |
console.log(' \n\n\n' === 0); // false |
View gist:1018c36505c869694561
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by abhiaiyer on 4/10/15. | |
*/ | |
Wootric = {}; | |
Meteor.startup(function () { | |
var key = Meteor.settings.public && Meteor.settings.public.wootric && Meteor.settings.public.wootric.key; | |
if (!key) { | |
return; | |
} |
View Bad UI Code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'click .submit': function (event, template) { | |
var post = template.data.post; | |
// Lets do more presentational stuff // | |
$(template.find(‘button[type=submit]’)).addClass(‘loading’); | |
$(template.find(‘input,textarea’)).not(“:disabled”).addClass(“disabled”).prop(“disabled”, true); | |
// Lets also check if you're logged in here | |
if (!Meteor.userId()) { | |
return ShowToast('Some Message', 'error') | |
} | |
// lets run some callbacks |
View Blaze AC Step 1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lets say we have some view called CommentSubmitComponent | |
// This view will make many things happen. Its job is to send off | |
// actions from the view and process something. | |
// Lets make an Action Creator | |
let CommentSubmitActions = new ZenAction(); | |
// So yeah yeah this is just a plain object at this point. But even so, you have a | |
// logical place to attach functionality | |
_.extend(CommentSubmitActions, { |
View BlazeACStep2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// register this group of functions with the ActionMixins | |
ZenMixins.registerMixin('CommentActions', { | |
fetchData(collection, query, options) { | |
// Do something here | |
}, | |
submitComment(options, cb) { | |
return Meteor.call('submitComment', options, cb); | |
}, | |
manipulateDOM(template) { |
View keyCodeMixin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DEFAULT_SUBMISSION_KEYS = [13, 188]; | |
/** | |
* Register a mixin for key events | |
*/ | |
ZenMixins.registerMixin('keyEvents', { | |
/** | |
* Decides whether the given event is a keyup for the 'Enter' key. | |
* | |
* @param event | |
* @returns {boolean} - True if the event is keyup on enter key |
View mixintest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('A Unit test for a test function', function () { | |
it('should do something when i say so :)', function () { | |
var actionCreator = new ZenAction(['testMixin']); | |
expect(actionCreator.getTest()).toEqual(undefined); | |
}); | |
}); |
View fakefunc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var psuedoReusableFunction = function (param1, param2, param3, param4) { | |
// do something with params 1 and 2 | |
DoSomething(param1); | |
DoSomething(param2); | |
// params 3 and 4 were added when your app changed but you didn't | |
// want to rewrite anything | |
if (param3) { | |
DoSomethingElse(param3); | |
} | |
// ya da ya da ... |