Skip to content

Instantly share code, notes, and snippets.

View elwayman02's full-sized avatar

Jordan Hawker elwayman02

View GitHub Profile
onWaitListUpdate: function() {
// If autojoin is not enabled, don't try to disable
if (!Settings.autojoin) return;
// If user is DJing, don't try to disable
var dj = API.getDJ();
if (dj !== null && dj.id === API.getUser().id) return;
// If user is in waitlist, don't try to disable
if (API.getWaitListPosition() > -1) return;
// If waitlist is full, don't try to disable
if (API.getWaitList().length == 50) return;
/**
* @license Copyright © 2012-2015 The plug³ Team and other contributors
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@elwayman02
elwayman02 / plugCubed
Created February 21, 2015 03:17
plugCubed-2
/**
* @license Copyright © 2012-2015 The plug³ Team and other contributors
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ npm install
> [email protected] postinstall c:\Projects\GitHub\jordan-hawker
> bower install
npm WARN unmet dependency c:\Projects\GitHub\jordan-hawker\node_modules\ember-cl
i\node_modules\broccoli-sane-watcher requires sane@'1.0.0-rc1' but will load
npm WARN unmet dependency c:\Projects\GitHub\jordan-hawker\node_modules\ember-cl
i\node_modules\sane,
npm WARN unmet dependency which is version 0.8.0
function getWinPosition(joins, winner) {
var spots = joins.length;
var winningSpot;
var lockDistance = Math.floor(spots / 4);
if (lockDistance < 1) { lockDistance = 1;}
for (winningSpot = 0; winningSpot < lockDistance; winningSpot++) {
if (!joins[winningSpot]) {
break;
}

This section explains the basic styles and patterns used in our JavaScript code. It borrows heavily from established resources at other companies that have extensive experience with JS, such as Yahoo, Google, and Mozilla. This guide is written with ES6 syntax in mind.

Some interesting JavaScript tips and gotchas can be found here

Comments

Use JS Doc-style comments whenever possible. Google's style guide has a great summary of JSDoc guidelines.

Strings

export default Ember.Component.extend({
classNames: ['tharp-component'],
firstName: 'Daniel',
lastName: 'Tharp'
});
@elwayman02
elwayman02 / gist:1ac2cabeb1dd722a2ffa
Created July 14, 2015 20:10
Class definition separation
// foo-component.js
export default Ember.Component.extend({
classNames: ['foo'],
barClasses: Ember.computed('bar', function () {
return this.get('bar') ? 'foo bar' : 'foo';
}),
bazClasses: Ember.computed('baz', function () {
return this.get('baz') ? 'baz' : '';
@elwayman02
elwayman02 / Converting libraries to Ember CLI addons.md
Last active August 29, 2015 14:27 — forked from kristianmandrup/Converting libraries to Ember CLI addons.md
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.

I hereby claim:

  • I am elwayman02 on github.
  • I am jordanhawker (https://keybase.io/jordanhawker) on keybase.
  • I have a public key whose fingerprint is C0F5 0250 2F28 2134 760F 65E0 F6E1 84C8 C881 65AC

To claim this, I am signing this object:

{