Skip to content

Instantly share code, notes, and snippets.

@superlou
superlou / service-selector.hbs
Created August 24, 2014 01:20
Uncooperative {{#if}}
<div class='service-selector'>
{{input value=service focus-out="lostFocus"}}
{{#if showMatches}}
<ul class='matches'>
{{#each matchedServices}}
<li>{{name}}</li>
{{/each}}
</ul>
{{/if}}
</div>
@superlou
superlou / used-service-box.hbs
Created September 1, 2014 17:25
Weird corner case
<div class="panel">
<div class='panel-summary' {{action 'toggleExpanded'}}>
<div class='row'>
<div class='span-10'>
{{usedService.service.name}}
<div class='subtle'>
{{usedService.service.desc}}
| <a href='#' {{bind-attr href="service.siteLink"}}>Visit</a>
</div>
</div>
@superlou
superlou / Brocfile.js
Last active August 29, 2015 14:07
CKEditor file picking
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var pickFiles = require('broccoli-static-compiler');
var app = new EmberApp();
// Use `app.import` to add additional libraries to the generated
// output files.
//
@superlou
superlou / Controller new-character.js
Created November 10, 2014 01:38
Duplicate records
import Ember from 'ember';
export default Ember.ObjectController.extend({
actions: {
save: function() {
var _this = this;
var record = this.store.createRecord('character', this.get('model'));
record.save();
@superlou
superlou / lodging.js
Created January 12, 2015 01:48
Access to dev.api.ean.com
import Ember from 'ember';
export default Ember.Controller.extend({
customerSessionId: 23, // todo Should be unique for each user session
possible: function(location) {
$.get('http://dev.api.ean.com/ean-services/rs/hotel/v3/list', {
apiKey: 'mc7re8wzh2vnnw67uz4je6qq',
cid: 55505,
_type: 'json',
import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
findAll: function(store, type, sinceToken) {
return new Promise(function(resolve, reject) {
$.post('http://localhost/wsibd/tasks.php', {
file: '/home/lsimons/workspace/wsibd/test_files/test.mpp',
resourceName: 'LCS'
}, function(result) {
import Ember from 'ember';
var gDrive = Ember.Object.extend({
clientId: '937974467154-23re9rr70mnlkmuddvpp325abth5u51k.apps.googleusercontent.com',
scopes: ['https://www.googleapis.com/auth/drive', 'email'],
authed: false,
ready: false,
init: function() {
window.handleClientLoad = this.handleClientLoad.bind(this);
@superlou
superlou / online-store.js
Created April 8, 2015 23:53
Dropbox Store
var DropboxOnlineAdapter = DS.Adapter.extend({
find: function(store, type, id, snapshot) {
var dropbox = this.container.lookup('service:dropbox');
var path = this.filename(type, id);
return dropbox.files(path).then((result) => {
var data = {
id: id,
text: result
@superlou
superlou / schedule.js
Created April 27, 2015 23:34
Odd time conversions
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
start: DS.attr('date'),
finish: DS.attr('date'),
places: DS.hasMany('places'),
events: DS.hasMany('event')
});
@superlou
superlou / gist:935790
Created April 22, 2011 00:44
Modeling polymorphic has_many :through
A user creates Spaces (rooms), Items (things), and Profiles (people).
Reservations are used to schedule times when these three models are in use and cannot be used elsewhere.
Since the modeling of a thing that can only be in use in one place/activity is common to Spaces, Items, and Profiles, this common functionality makes up the polymorphic model Resource.
Reservation
belongs_to :manager, :class_name => "Profile"
has_many :reservation_lines, :before_add => :set_nest, :dependent => :destroy
has_many :profiles, :through => :reservation_lines, :source => :reservable, :source_type => 'Profile'
has_many :spaces, :through => :reservation_lines, :source => :reservable, :source_type => 'Space'