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 addVariables(engine) { | |
// for each player | |
for (var row = 1; row <= PLAYERS.getNumRows(); row++) { | |
var player = PLAYERS.getCell( | |
row, | |
PLAYERS_PLAYER_COLUMN | |
).getValue(); | |
var projectedPoints = PLAYERS.getCell( | |
row, PLAYERS_PROJECTED_POINTS_COLUMN | |
).getValue(); |
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 optimizeRoster() { | |
// this sets engine to an instance of Google's LP/MIP solver | |
var engine = LinearOptimizationService.createEngine(); | |
// clear previous selections from the Players worksheet | |
clearPreviousSelections(); | |
// add the variables (players and their salaries) | |
// to the optimization problem | |
addVariables(engine); |
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
import ApplicationController from './application'; | |
ApplicationController.reopen({ | |
unsetToken: Ember.observer('token', function() { | |
if (this.get('token')) { | |
Ember.run.next(this, function() { | |
this.set('token', null); | |
}); | |
} | |
}) |
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
// app/routes/application.js | |
import Ember from 'ember'; | |
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; | |
export default Ember.Route.extend(ApplicationRouteMixin, { | |
session: Ember.inject.service('session'), | |
isTokenAuthenticating: null, | |
model(params) { |
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
// app/controllers/application.js | |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
queryParams: ['token'], | |
token: null | |
}); |
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
// app/authenticators/token.js | |
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant'; | |
export default OAuth2PasswordGrant.extend({ | |
authenticate(token) { | |
return new Promise((resolve, reject) => { | |
resolve({ | |
access_token: token, | |
token_type: 'bearer' | |
}); | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
matchingStates: [], | |
states: Ember.inject.service('states'), | |
actions: { | |
updateMatches(query) { | |
if (Ember.isPresent(query)) { |
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
import Ember from 'ember'; | |
export default Ember.Service.extend(Ember.PromiseProxyMixin, { | |
store: Ember.inject.service(), | |
query(limit, offset) { | |
return this.get('store').query('state', { | |
include: 'country,region', | |
page: { |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
states: Ember.inject.service('states'), | |
beforeModel() { | |
this.get('states'); | |
}, | |
}); |
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
task :stats => "app:stats_setup" | |
# insert additional types into the statistics table and sort the list | |
namespace :app do | |
task :stats_setup do | |
require 'rails/code_statistics' | |
app_entries, spec_entries = [], [] | |
until ::STATS_DIRECTORIES.empty? | |
entry = STATS_DIRECTORIES.shift |