Skip to content

Instantly share code, notes, and snippets.

View ultimatemonty's full-sized avatar

Chris McCuller ultimatemonty

View GitHub Profile
@ultimatemonty
ultimatemonty / ember-crud-pattern.js
Created September 23, 2014 14:31
Ember CRUD pattern
App.PostsController = Em.ArrayController.extend({
actions: {
create: function () {
// some validation logic here
return this.send('createPost');
},
save: function (model) {
// some validation logic here
@ultimatemonty
ultimatemonty / dreamfactory-response.json
Last active August 29, 2015 14:07
Dreamfactory response with all "related data"
{
"record": [
{
"id": 2,
"name": "3M Aerospace",
"website": "http://solutions.3m.com/wps/portal/3M/en_US/Aerospace/Aircraft/",
"isActive": true,
"isQAActive": true,
"createdBy": "32",
"createdDate": "2014-10-01T15:19:35",
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
var string = DS.attr('string'),
bool = DS.attr('boolean'),
number = DS.attr('number'),
date = DS.attr('date'),
isoDate = DS.attr('isodate');
App.Location = DS.Model.extend({
name: string,
iata: string,
icao: string,
@ultimatemonty
ultimatemonty / application-route.js
Created November 2, 2014 16:43
This gist was an attempt to work around https://github.com/emberjs/ember.js/issues/5264 that failed. wanted to save it for later reference if needed.
App.ApplicationRoute = Ember.Route.extend({
actions: {
back: function (path, model) {
console.log('APPLICATION.BACK');
var transitionObject = App.Transition.create({ 'path': path, 'objectId': model.get('id') });
this.transitionTo('transition', transitionObject);
}
}
});
@ultimatemonty
ultimatemonty / payment-terms-schema.json
Last active August 29, 2015 14:10
Schema for PaymentTerms table
// This schema throws the 102 error with related=*
{
"name": "Currencies",
"label": "Currencies",
"plural": "Currency",
"primary_key": "id",
"name_field": null,
"field": [
{
"name": "id",
@ultimatemonty
ultimatemonty / nl2br.js
Created December 4, 2014 21:41
Ember nl2br helper
Ember.Handlebars.registerBoundHelper('nl2br', function (text) {
var breakTag = '<br />';
return new Handlebars.SafeString((text + '')
.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'));
});
@ultimatemonty
ultimatemonty / gist:84a90e2ec35e05ada5ad
Created December 22, 2014 20:32
ArrayComputed error
Error Message:
Index out of range
Stack Trace:
Error: Index out of range
at new Error (native)
at Error.EmberError (http://localhost:1337/js/libs.js:14284:23)
at Array.__exports__.default.Mixin.create.removeAt (http://localhost:1337/js/libs.js:32218:19)
at arrayComputed.removedItem (http://localhost:1337/js/libs.js:28713:17)
at Object.DependentArraysObserver.flushChanges (http://localhost:1337/js/libs.js:27386:40)
@ultimatemonty
ultimatemonty / app-session.js
Last active August 29, 2015 14:15
currentUser into routes and controllers via Session
App.AppSession = SimpleAuth.Session.extend({
currentUser: Ember.computed('userId', function () {
var userId = this.get('userId');
if (!Ember.isEmpty(userId)) {
return this.container.lookup('store:main').find('user', userId);
}
})
});
@ultimatemonty
ultimatemonty / environment.js
Last active January 19, 2017 09:19
PubNub with Ember CLI
// config/environment.js
module.exports = function(environment) {
var ENV = {
modulePrefix: 'ember-cli-pubnub',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {