Skip to content

Instantly share code, notes, and snippets.

import { test, moduleFor } from 'ember-qunit';
moduleFor('route:application', 'ApplicationRoute', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function() {
var route = this.subject();
ok(route);
{{! because the template yields the actions can go
on the route/controller}}
{{#todo-list todos=todos as |todo|}}
{{#todo-item todo=todo as |todo|}}
{{input value=todo.name}}
<a href="#" {{action "save" todo}}>Save</a>
<h4>Javascript</h4>
<textarea cols="60" rows="12"><%= html_escape(render("forms/v1/cp/javascript")) %></textarea>
this does not escape the output of the partial. this gets really messy
because our partial has a </textarea>
forms/v1/cp/javascript:
<div id="strike-form-6150cd9ecfcddc83eefe04bd09d356ae"></div>
<script type="text/javascript">
strike_form_init = function() {
strike_form = new StrikeForm();
strike_form.start();
};
</script>
<script src="http://www.strikeform.com/forms/show/v1/6150cd9ecfcddc83eefe04bd09d356ae.js"></script>
<?php
/**
* Finds all of the X(table) within (radius) of (object).
*
* Uses Haversine formula
*
* @author ryan
*/
class Gps_Radius {
root@ryan-desktop:/usr/local/src/bdsm-0.8.8# sm sets install ruby
[✘] bdsm-ruby!
Unknown SCM type (not found) for url 'wayneeseguin/bdsm-ruby'.
A command has returned error code '(1)' without being handled.
+# source file # function()
========================================================================================================================================
less +866 /sm/core/cli/modules/shell/sets/dsl # sets_install()
less +506 /sm/core/sm/modules/shell/logging/dsl # action_call()
@ryanto
ryanto / gist:4140696
Created November 24, 2012 17:56
Enumerable

I'd like to see more enumerable functions, min/max and groupBy are just a few I've recently used, but there are many more (Ruby's Enumerable is what I am thinking of). While these functions are easy to implement, it would be nice to see them in Ember. I know that Ember.Enumerable wants to stay as close as possible to the JS API, so it sounds like that is not a good place for these.

There are a lot of 3rd party libs that build out these functions for you. However, because of Ember's use of proxies (like DS.ManyArray) you have to remember to call toArray on the relationship. This creates ugly code: groupBy(person.get('posts').toArray(), 'category'). What's worse is these 3rd party libs don't know about Ember's binding system, so the above turns into groupBy(person.get('posts').toArray(), function(post) { return post.get('category') });. I think it's a lot easier to think of the above as person.get('posts').groupBy('category').

Is there interest for these functions? If so, how should

@ryanto
ryanto / gist:a3ae9cc8119ca0f2f235
Last active October 29, 2015 12:04
Declarative CPs
import Ember from 'ember';
export default Ember.Component.extend({
channelTalk: null,
classNames: 'Channel-table-row',
channel: Ember.computed.readOnly('channelTalk.channel'),
talk: Ember.computed.readOnly('channelTalk.talk'),

Ember.JS Testing

From Sam...

Unit

No collaborators loaded. Only use if you’re testing single object.

Integration

@ryanto
ryanto / gist:5428622
Created April 21, 2013 05:45
EmberJS attribute bindings as promises.

I send the controller an event that will result in some long processing/work. Once this work is complete, I want the controller to update a binding. Ideally, I do not want th controller to know anything about this work, I simply want it to ask for the result.

In this example thingApi is an injected object that knows how to create new strings for things (done async). newString() is a function that returns a promise that eventually resolves to a string.

What I have to do:

    this.get('thingApi').newString().then(function(string) {
      this.set('thing', string);
 });