Skip to content

Instantly share code, notes, and snippets.

View abhiaiyer91's full-sized avatar

Abhi Aiyer abhiaiyer91

  • Netlify
  • Los Angeles
View GitHub Profile
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);
};
//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
/**
* 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;
}
// 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) {
// 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, {
@abhiaiyer91
abhiaiyer91 / Bad UI Code.js
Last active December 12, 2015 21:58
Ui Example
'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
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
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);
});
});
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 ...
const ProfileAvatarComponent = ({profilePhoto, role}) => {
return (
<div className="img-circle">
<div className="grey-outline">
<img src={profilePhoto} className="img-responsive"/>
</div>
</div>
)
}