Skip to content

Instantly share code, notes, and snippets.

@trabus
trabus / embed.js
Created January 5, 2014 06:40
Discourse embed code
/* global discourseUrl */
/* global discourseEmbedUrl */
(function() {
var comments = document.getElementById('discourse-comments'),
iframe = document.createElement('iframe');
iframe.src = discourseUrl + "embed/comments?embed_url=" + encodeURIComponent(discourseEmbedUrl);
iframe.id = 'discourse-embed-frame';
iframe.width = "100%";
iframe.frameBorder = "0";
@trabus
trabus / conflicting-addons.md
Last active August 24, 2018 15:30
Handling addons with conflicting module names

Say that you have some-addon and other-addon, and both have a foo service, and both export app/services/foo.js.

What you would observe is that other-addon would win over some-addon providing the foo service in your consuming app, because modules are resolved alphabetically.

To get around this, you can essentially proxy the services in your app folder, like so:

// app/services/foo-a.js
export { default } from 'some-addon/services/foo';
@trabus
trabus / gist:6c2ecfbd8e5145e7b328
Last active April 16, 2018 11:01
Pods in ember-cli

Overview

Pods are a type of file organization structure in ember-cli. They allow you to gather related modules and assets together in your file structure. Currently pod structured modules can live side by side with your basic modules because the resolver that ships with ember-cli will look up your path in pod structure, and then fall back to basic structure if no paths are resolved.

Soon there will be a point where some blueprints will only generate in pod structure, and others will only generate in basic structure. This will allow us to collect a list of types that support each lookup structure and only need to lookup modules once. This will also cause less ambiguity around what a project structure looks like.

TLDR

My opinion on pods is that they should not live in the same namespace as type based modules. We should re-appropriate 'components',' models', and 'routes' (or 'resources') as pod prefixes to house the concerns of global ui, data, and route specific ui, respectively. Everything else stays th

@trabus
trabus / install_multiple_blueprints.js
Created September 30, 2015 22:05
Installing multiple blueprints from another blueprint
var RSVP = require('rsvp');
var assign = require('lodash/object/assign');
module.exports = {
description: '',
// creates an array of blueprints to install, for instance scaffolding
install: function(options){
var blueprints = [
{ blueprint: this.lookupBlueprint('account'),
options: options
},
@trabus
trabus / gist:8001480
Created December 17, 2013 07:49
Using Isotope.js with Ember.js
// Controller
App.SomeController = Ember.ArrayController.extend({
items: []
});
// View
App.SomeView = Ember.View.extend({
// this will be run once the didInsertElement event occurs, and any time an item is added
initIsotope: function(){
// use the run loop to execute after rendering is complete
@trabus
trabus / controllers.application.js
Created May 9, 2016 18:31
multiple dynamic properties
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@trabus
trabus / application.controller.js
Created April 22, 2016 20:18
component blur demo
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@trabus
trabus / components.foo-bar.js
Last active April 8, 2016 19:35
Funky Computed Property
import Ember from 'ember';
const {Component, computed} = Ember;
export default Component.extend({
mything: null,
// thing value is also passed into the component
// thing watches no keys, and is not consumed
thing: computed({
// the getter is ignored entirely
set(k, v) {
// do any amount of work here
@trabus
trabus / account.service.js
Last active January 30, 2016 10:34
query-param-service
import Ember from 'ember';
const {computed} = Ember;
export default Ember.Service.extend({
_account: null,
account: computed('_account', {
get(key) {
return this.get('_account');
},
set(key, val) {