Skip to content

Instantly share code, notes, and snippets.

View villander's full-sized avatar

Michael Villander villander

View GitHub Profile
@villander
villander / components.display-qp.js
Last active July 20, 2017 23:01 — forked from tamebadger/components.display-qp.js
Query Param Component
import Ember from 'ember';
const { computed: { alias }, observer } = Ember
export default Ember.Component.extend({
routing: Ember.inject.service('-routing'),
params: alias('routing.router.currentState.routerJsState.fullQueryParams')
})
@villander
villander / didreceiveattrs.js
Created January 18, 2017 20:05 — forked from adamjmcgrath/didreceiveattrs.js
Ember: Observer vs didReceiveAttrs
didRecieveAttrs(attrs) {
if (attrs.newAttrs.dimensions.value !== attrs.oldAttrs.dimensions.value) {
chart.redraw();
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Nested Routes - Loading'
});
@villander
villander / android_instructions.md
Created December 25, 2016 22:18 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@villander
villander / routes.application.js
Created December 9, 2016 16:24 — forked from mike-north/routes.application.js
async/await in Ember Routes
import Ember from 'ember';
const DATA_URL = 'https://api.github.com/orgs/emberjs/repo';
export default Ember.Route.extend({
// Values returned from async function are Promises
model: async function() {
// Get the data, AND WAIT FOR IT TO RETURN (type: Object)
var data = await $.getJSON(DATA_URL);
import Ember from 'ember';
import moment from 'moment';
export default Ember.Component.extend({
init(){
this._super(...arguments);
console.log(`${this.get('day')}`);
isActive: true;
},
@villander
villander / controllers.application.js
Created August 7, 2016 19:41 — forked from sukima/controllers.application.js
PromiseProxyMixin UI feedback
import Ember from 'ember';
import { makeTestPromise } from '../utils/test-foo';
const TestFoo = Ember.Object.extend(Ember.PromiseProxyMixin, {
init() {
// By default a PromiseProxy will rethrow a
// rejected promise causing it to be left
// unhandled. Since by the nature of this use
// pattern it is handled (see template) we add
// a no-op to the end of the chain and the
@villander
villander / app.js
Created July 28, 2016 21:00 — forked from jmdobry/app.js
js-data + js-data-firebase + js-data-localstorage
var fb = new DSFirebaseAdapter({
basePath: 'https://my-app.firebase.io'
});
var ls = new DSLocalStorageAdapter();
var store = new JSData.DS({
// try firebase first, otherwise try offline data
fallbackAdapters: ['fb', 'ls'],
// After creating an item, sync it to localStorage
@villander
villander / 1-proposal.md
Created July 26, 2016 04:03 — forked from JedWatson/1-proposal.md
Proposal: adding reverse-relationship population to Mongoose (as implemented in KeystoneJS)

I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).

I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.

I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.

The problem

The built-in population feature is really useful; not just for