Skip to content

Instantly share code, notes, and snippets.

View scottmessinger's full-sized avatar

Scott Ames-Messinger scottmessinger

View GitHub Profile
@scottmessinger
scottmessinger / old_node.rb
Last active August 29, 2015 14:06
How I imagine the migration stuff happening
class OldNode
def lesson
@lesson ||= Lesson.find(id)
end
def verify_migration
self.verify_field_names
self.verify_sections
end
App.PlanbookDate = Ember.Model.extend({
/**
* Computed Property
* This property returns a routine. If the routine is pristine,
* it creates a routine then adds parts from the routine template to it.
*
* If the routine is not pristine, it just returns the routine.
*
*/
<!--
template: planbook.hbs
-->
{{render 'dates'}}
<!--
template: dates.hbs
controller: see DatesController below

type == "routine"

error

@scottmessinger
scottmessinger / gist:11184957
Created April 22, 2014 16:07
Questions about Ember

Ember does a bunch of useful, powerful, magical things that makes life easy. However, I find myself often a loss to understand how the magic works or how to hook into it. I think I struggle most to understand how & when things are instantiated, how they magically know of each other (e.g. the app knows all it's models & controllers), and how to instantiate things manually and give them access to all the other classes. Here are some examples:

  • If I create an instance of a controller, how do I make sure it has access to the app containers?
  • In Ember-CLI, how does Ember know about all the models/controllers/etc I create? When I write export default PostController, how does Ember register that as a controller and add it to the container?
  • In Ember-CLI, filenames & folder names make a difference. If files are named something unexpected, the documentation writes that they need to be imported automiatcally. Where would such an import statement go? What is the code path that the abnormally named class has to ski
import SortableListMixin from '../mixins/sortable-list';
import Part from '../models/part';
import Section from '../models/section';
var PartsController = Ember.ArrayController.extend(SortableListMixin, {
init: function(){
this._super()
// ISSUE #1 - probably unrelated the es6 change.
// Shouldn't the content be set automatically to an array?
if (Ember.isNone(this.get('content'))){
@scottmessinger
scottmessinger / html
Last active December 25, 2015 02:28
Uservoice
var uvOptions = {};
// Include the UserVoice JavaScript SDK (only needed once on a page)
(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/API_KEY.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})()
UserVoice=window.UserVoice||[];
function showClassicWidget() {
UserVoice.push(['showLightbox', 'classic_widget', {
primary_color: '#cc6d00',
link_color: '#007dbf',
forum_id: 140171
}]);
var smoke = TS.HomeSmokeView.create({signal: "Magically Generating Your Schedule. Hold on.<br>Magic can't be rushed."}).append()
Ember.run.schedule('afterRender', this, function(){
this.get('queue').forEach(function(course) {
course.schedule()
})
this.get('queue').clear()
smoke.destroy()
})

Core Concepts

[ snip ]

Concepts

The router drives an Ember app. The router translates the URL into a model that is rendered with a template. Optionally, you can use controllers and views for more control. Controllers hold application state that isn't expressed in the URL. Views back templates and can handle events.

Templates

[ snip ]

Models

<div class="selected-standards">
<ul>
{{#each selected in view.context.standards}}
<li class="box selected-triad">
<span {{ action toggleStandard selected view target="view.context"}}> {{selected.shortCode}} </span>
</li>
{{/each}}
</ul>
</div>