Skip to content

Instantly share code, notes, and snippets.

View barelyknown's full-sized avatar

Sean Devine barelyknown

View GitHub Profile
@barelyknown
barelyknown / authenticate-in-ember-using-a-url-parameter-4.js
Created December 1, 2015 20:17
authenticate-in-ember-using-a-url-parameter-4.js
import ApplicationController from './application';
ApplicationController.reopen({
unsetToken: Ember.observer('token', function() {
if (this.get('token')) {
Ember.run.next(this, function() {
this.set('token', null);
});
}
})
@barelyknown
barelyknown / authenticate-in-ember-using-a-url-parameter-3.js
Created December 1, 2015 20:16
authenticate-in-ember-using-a-url-parameter-3.js
// 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) {
@barelyknown
barelyknown / authenticate-in-ember-using-a-url-parameter-2.js
Created December 1, 2015 20:15
authenticate-in-ember-using-a-url-parameter-2.js
// app/controllers/application.js
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['token'],
token: null
});
@barelyknown
barelyknown / authenticate-in-ember-using-a-url-parameter-1.js
Created December 1, 2015 20:15
authenticate-in-ember-using-a-url-parameter-1
// 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'
});
});
@barelyknown
barelyknown / state-matches.js
Created November 20, 2015 22:36
/app/controllers/state-matches.js
import Ember from 'ember';
export default Ember.Controller.extend({
matchingStates: [],
states: Ember.inject.service('states'),
actions: {
updateMatches(query) {
if (Ember.isPresent(query)) {
@barelyknown
barelyknown / states.js
Created November 20, 2015 22:32
app/services/states.js
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: {
@barelyknown
barelyknown / authenticated.js
Created November 20, 2015 22:28
/app/routes/authenticated.js
import Ember from 'ember';
export default Ember.Route.extend({
states: Ember.inject.service('states'),
beforeModel() {
this.get('states');
},
});
@barelyknown
barelyknown / stats.rake
Created August 28, 2015 13:30
Setup for `bundle exec rake stats`
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
@barelyknown
barelyknown / blackjack-rails-api-spec-documentation-after-TableRuleSet-model-implemented.txt
Last active August 29, 2015 14:26
blackjack-rails-api spec documentation after TableRuleSet model implemented
Seans-MacBook-Pro:blackjack-rails-api seandevine$ bundle exec rspec --format documentation
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 31252
V1::CardResource
has no updatable fields
has no creatable fields
@barelyknown
barelyknown / gist:ed18b2b7b4f258b691e3
Created July 11, 2015 15:29
login with valid credentials by pressing enter from password input
// login.hbs
// {{input value=identification name='identification'}}
// {{input value=password name='password' enter='authenticate'}}
// <button name='login' {{action 'authenticate'}}>Login</button>
// this test passes
test('login with valid credentials', function(assert) {
visit('/login');
andThen(function() {