Skip to content

Instantly share code, notes, and snippets.

Amiel Martin amiel

View GitHub Profile
View adapters.shop-language.js
import Adapter from 'ember-data/adapters/json-api';
import UrlTemplates from "ember-data-url-templates";
export default Adapter.extend(UrlTemplates, {
urlTemplate: '/shops{/shopId}/languages{/id}',
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
this.set('myArray', []);
},
getNewItem() {
@amiel
amiel / adapters.user.js
Last active Dec 23, 2016 — forked from samselikoff/mirage.config.js
Mirage dev boilerplate
View adapters.user.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
buildURL(type, id) {
return `/users/${id}.json`;
},
});
@amiel
amiel / controllers.application.js
Last active Sep 9, 2016
Example PromiseProxyMixin issue
View controllers.application.js
import Ember from 'ember';
const { inject } = Ember;
export default Ember.Controller.extend({
myService: inject.service(),
appName: 'Ember Twiddle',
});
@amiel
amiel / delete.js
Created Jun 16, 2016
Usage of delete in javascript
View delete.js
object = { foo: 'bar', foobar: undefined };
$.param(object); // => "foo=bar&foobar="
delete object.foobar;
$.param(object); // => "foo=bar"
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View adapter-context.js
import Ember from 'ember';
export default Ember.Service.extend({
// this is intentionaly empty
});
@amiel
amiel / 1_promises.js
Last active Aug 29, 2015
Safe calls before a javascript library is loaded; 2 ideas
View 1_promises.js
// Pattern 1, all access through a promise
function trackEvent() {
var args = arguments;
trackEvent.promise.then(function(library) {
library.trackEvent.apply(null, args);
});
}
@amiel
amiel / worker.js
Last active Aug 29, 2015
Loading sailsjs environment in a grunt task
View worker.js
module.exports = function (grunt) {
grunt.registerTask('queue:work', 'Run queue worker', function (command) {
var Sails = require('sails').Sails;
var callback = this.async();
var sails = new Sails();
var sailsConfig = { port: -1 };
sails.load(sailsConfig, function (err) {
sails.initialize(function(){
You can’t perform that action at this time.