Skip to content

Instantly share code, notes, and snippets.

┬─┬◡ノ(° -°ノ)
(╯°□°)╯︵ ┻━┻
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init(){
var model = Ember.Object.create({
title:"My Cool Model",
items:[
{name:"item1",isSelected:true},
{name:"item2",isSelected:false}
]
@jeradg
jeradg / ember-data-model-mock.js
Created March 3, 2016 19:46
Mock ember-data object factory - Use mirage fixtures (or any other plain old JS object) to mock Ember Data models in component integration tests. See also ember-cli-mirage-object-factory.js - https://gist.github.com/jeradg/6043ba31d831633ce4e3
// tests/helpers/model-mock.js
export function modelMock(attrs) {
const emberDataRecordAttrs = {
isValid: true,
isNew: false
};
return Ember.Object.extend(emberDataRecordAttrs)
.create(attrs);
}
@jeradg
jeradg / ember-cli-mirage-object-factory.js
Last active March 3, 2016 19:47
ember-cli-mirage Ember.Object factory - Use mirage factories to mock Ember Data models in component integration tests. See also ember-data-model-mock.js: https://gist.github.com/jeradg/6f8bfbbf0722d34eea09
/*
* Decorator on a Mirage plain-ol'-JavaScript-object factory
* to allow you to create Ember objects.
*
* The objects act just enough like an Ember Data model that
* you can use them as a drop-in replacement for DS.Model instances
* in many component integration tests.
*
* Returns an object with one method, `create`, that returns
* subclasses of Ember.Object that are created with the Mirage
@jeradg
jeradg / application.controller.js
Last active January 21, 2016 06:59
Computed Properties with @each (broken - Ember 2.2.0)
import Ember from 'ember';
let lastId = 0;
export default Ember.Controller.extend({
rootItems: Ember.computed.filter('owner.items', function(item) {
return item.get('parent.content') === null;
}).property('[email protected]'),
owner: Ember.computed(function() {
@jeradg
jeradg / application.controller.js
Last active January 11, 2016 16:48 — forked from denzo/application.controller.js
Computed Properties with @each (working - Ember 2.0.2)
import Ember from 'ember';
let lastId = 0;
export default Ember.Controller.extend({
rootItems: Ember.computed.filter('owner.items', function(item) {
return item.get('parent.content') === null;
}).property('[email protected]'),
owner: Ember.computed(function() {
@jeradg
jeradg / ro-coffee.md
Last active August 11, 2016 18:44
RewardOps coffee orders
  • Abid: Medium double iced americano (summer), OR medium double americano (otherwise)
  • Alex: Medium double americano, black, no sugar
  • Azim: Medium drip, 1 milk
  • Drew: Doesn't drink coffee!
  • Jerad: Medium drip, black
  • Manny: Lactose-free cap
  • Michael: Double decaf americ. in a small cup (Jimmy's), OR decaf long black (HDB)
  • Michelle: Single cortado
  • Roland: Double americano, medium cup, double milk + a splash of cream, 2 sugars
  • Yathi: Medium ice latte (summer) OR medium medium (otherwise)
@jeradg
jeradg / JavaScript flatten
Created March 25, 2013 23:23
JavaScript function for flattening an array.
var flatten = function( array ) {
var flattenedArray = [ ];
var flattenLoop = function( i ) { i.forEach( function( j ) {
if ( Object.prototype.toString.call( j ) === '[object Array]' ) {
flattenLoop( j );
} else {
flattenedArray.push( j );
}
});
};