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); | |
}; |
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 |
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; | |
} |
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) { |
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, { |
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 |
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 |
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); | |
}); | |
}); |
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 ... |
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
const ProfileAvatarComponent = ({profilePhoto, role}) => { | |
return ( | |
<div className="img-circle"> | |
<div className="grey-outline"> | |
<img src={profilePhoto} className="img-responsive"/> | |
</div> | |
</div> | |
) | |
} |