Skip to content

Instantly share code, notes, and snippets.

View jordpo's full-sized avatar

Jordan Morano jordpo

  • Burlington, VT
View GitHub Profile
@jordpo
jordpo / polling-alt.js
Last active August 29, 2015 14:26
Ember Polling Mixin for Routes
// an alternative approach to my gist below
import Ember from 'ember';
const get = Ember.get;
const set = Ember.set;
const later = Ember.run.later;
const cancel = Ember.run.cancel;
@jordpo
jordpo / ajax.js
Last active February 22, 2017 00:01
IcarusWorks - Single Sign On with Ember.js
// addon/services/ajax.js
// ensure custom ajax requests have the appropriate authorization headers when signed in
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
const {
computed,
inject,
get
} = Ember;
@jordpo
jordpo / Contract Killer 3.md
Created March 17, 2016 14:14
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@jordpo
jordpo / ember-data-imports.js
Created October 19, 2016 16:13
New imports for ember data
// DS.Model
import Model from 'ember-data/model';
// DS.RESTSerializer
import RESTSerializer from 'ember-data/serializers/rest';
// DS.JSONSerializer
import JSONSerializer from 'ember-data/serializers/json';
// DS.JSONAPISerializer
headers: computed('session.isAuthenticated', {
get() {
const headers = {};
const session = get(this, 'session');
if (get(session, 'isAuthenticated')) {
session.authorize('authorizer:oauth', (headerName, headerValue) => {
headers[headerName] = headerValue;
});
}
@jordpo
jordpo / query.rb
Created August 25, 2017 15:33
company bidder query
class Companies::CompanyUsersQuery
def initialize()
@scope = CompanyUser
end
def add_includes
scope = scope.include([:credentials, :company])
self
end
@jordpo
jordpo / action-dropdown.hbs
Last active August 29, 2017 20:55
Filtering
{{#basic-dropdown as |dropdown|}}
{{#dropdown.trigger
class='c-button'
}}
Filters
{{/dropdown.trigger}}
{{#dropdown.content}}
<div>
<h2>
Bidders
@jordpo
jordpo / route-action.js
Last active February 1, 2019 05:42
A route-action helper to expose current route handling
import Helper from '@ember/component/helper';
import { inject as service } from '@ember-decorators/service';
import { bind } from '@ember/runloop';
import { getOwner } from '@ember/application';
function findHandler(owner, currentRouteInfo, action) {
const route = owner.lookup(`route:${currentRouteInfo.name}`);
const handler = route.actions ? route.actions[action] : route[action];
if (!handler && currentRouteInfo.parent) {
return findHandler(owner, currentRouteInfo.parent, action);
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
@jordpo
jordpo / controllers.application\.js
Last active July 13, 2020 20:19
Changeset Boolean Bug
import Controller from '@ember/controller';
import { EmberChangeset, Changeset } from 'ember-changeset';
class MyChangeset extends EmberChangeset {
// NOTE using the default safeSet for only type boolean fixes the issue
safeSet(obj, key, value) {
if (typeof value.value === 'boolean') (obj[key] = value);
return super.safeSet(obj, key, value);
}