Skip to content

Instantly share code, notes, and snippets.

View sandalsoft's full-sized avatar
🏖️
Working from the beach

Eric Nelson sandalsoft

🏖️
Working from the beach
View GitHub Profile
Getting an error when I return json from my TickerSerializer serializer.
Error: Assertion Failed: You must include an `id` in a hash passed to `push`
This is becuase ember-data is looking for data.id from a serializer
(https://github.com/emberjs/data/blob/d9c47f10e3ee016f0bc0f0d5f4de1ebb294051c8/packages/ember-data/lib/system/store.js#L1205)
Is my JSON wrong?
TickerSerializer extends DS.JSONSerializer, and returns this JSON
/** from the ember-data b7 source for push():
Push some data for a given type into the store.
This method expects normalized data:
* The ID is a key named `id` (an ID is mandatory)
* The names of attributes are the ones you used in
your model's `DS.attr`s.
@sandalsoft
sandalsoft / app.js
Created May 28, 2014 21:58 — forked from wycats/app.js
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
var Ticker = DS.Model.extend({
symbol: DS.attr('string'),
options: DS.hasMany('option', {embedded: 'always'}),
Ask: DS.attr('string'),
AverageDailyVolume: DS.attr('string'),
Bid: DS.attr('string'),
AskRealtime: DS.attr('string'),
BidRealtime: DS.attr('string'),
BookValue: DS.attr('string'),
Change_PercentChange: DS.attr('string'),
var row = {"put":{"strikePrice":12.5,"lastPrice":0,"vol":0,"bid":5.6,"expiry":"2014-09-20","openInt":0,"ask":6.5,"net":0,"type":"PUT","ticker":"I"},"call":{"strikePrice":12.5,"lastPrice":0,"vol":0,"bid":5.6,"expiry":"2014-09-20","openInt":0,"ask":6.5,"net":0,"type":"CALL","ticker":"I"}};
getCellContent: function(row) {
window.console.log('row: ' + JSON.stringify(row));
window.console.log('1: ' + row['put'].openInt);
window.console.log('2: ' + row.put.openInt);
window.console.log('3: ' + row['put']['openInt']);
return row['put']['openInt'];
}
DEBUG: ------------------------------- vendor.js:16672
DEBUG: Ember : 1.5.1 vendor.js:16672
DEBUG: Ember Data : 1.0.0-beta.8.2a68c63a vendor.js:16672
DEBUG: Handlebars : 1.3.0 vendor.js:16672
DEBUG: jQuery : 1.11.1 vendor.js:16672
DEBUG: ------------------------------- vendor.js:16672
Attempting URL transition to / vendor.js:16672
generated -> route:application Object {fullName: "route:application"} vendor.js:16672
generated -> route:index Object {fullName: "route:index"} vendor.js:16672
Transition #0: application: calling beforeModel hook vendor.js:16672
define("options-ember/controllers/ticker",
["ember","exports"],
function(__dependency1__, __exports__) {
"use strict";
var Ember = __dependency1__.Ember;
var TickerController = Ember.ObjectController.extend({
needs: "application",
ticker_symbol: Ember.computed.alias('controllers.application.ticker_id'),
import Ember from 'ember';
var TickerController = Ember.ObjectController.extend({
needs: "application",
ticker_symbol: Ember.computed.alias('controllers.application.ticker_id'),
expirys: Ember.computed.mapBy('model.options', 'expiry'),
expiryList: Ember.computed.uniq('expirys'),
actions: {
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
name: require('./package.json').name,
// for some large projects, you may want to uncomment this (for now)
es3Safe: true,
@sandalsoft
sandalsoft / appify.sh
Last active July 8, 2016 20:03 — forked from advorak/appify.sh
appify — create the simplest possible Mac app from a shell script (adds an application icon)
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
appify v3.0.0 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh