Skip to content

Instantly share code, notes, and snippets.

View alexspeller's full-sized avatar
🏁

Alex Speller alexspeller

🏁
View GitHub Profile
<VirtualHost *:80>
ServerName "me.dev"
DocumentRoot "/var/www/awc/me/public/"
RewriteEngine On
RewriteCond %{HTTP:Accept} text/html [NC]
RewriteRule ^(.*)$ /
RewriteRule ^/api/(.*)$ http://localhost:2403/$1 [P]
</VirtualHost>
App.ApplicationRoute = Em.Route.extend
model: ->
Em.RSVP.hash
users: store.find('user')
setupController: (controller, context) ->
@controllerFor('users').set('model', context.users)
App.UsersController = Em.ArrayController.extend()
App.ApplicationRoute = Em.Route.extend
model: ->
store.find('user')
setupController: (controller, users) ->
@controllerFor('users').set('model', users)
App.UsersController = Em.ArrayController.extend()
App.FooController = Em.Controller.extend
require 'bundler/setup'
Bundler.require
# Gem versions:
# celluloid (0.15.1)
# celluloid-io (0.15.0)
# nio4r (0.5.0)
# timers (1.1.0)
# Routes
App.Router.map ->
@resource 'post', path: "/posts/:post_id"
App.PostRoute = Em.Route.extend
model: (params) ->
@store.find('post', params.post_id)
App.PostIndexRoute = Em.Route.extend
model: (params) ->
// embedded
{
post: {
title: "whatever",
comments: [
{
id: 1,
comment: "something"
}
]
@alexspeller
alexspeller / foo.js
Last active December 23, 2015 11:38
App.Bands = Ember.ObjectProxy.extend();
App.Bands.reopenClass({
all: function() {
return $.getJSON("http://domain.com/api/v1/bands?format=jsonp&callback=?").then(function (response) {
return response.map(function (band) {
return App.Bands.create({content: band})
});
});
}
});
Admin.RefreshableModel = Em.Object.extend({
/**
* Keeps reloading a given model from the server. To stop this process, just
* kill the `timer` variable.
*/
reload: function(model) {
if(this.timer) { this.stop(); }
this.model = model;
this.timer = Em.run.later(this, '_reload', 15000);
@alexspeller
alexspeller / gist:6698048
Last active December 23, 2015 21:39 — forked from abuiles/gist:6698011
model.get('foos').then (foos) ->
foos.get('firstObject')
App.PushClient = Em.Object.extend
init: ->
@connection = connectToSocketIOSomehow()
subscribe: (channel, callback) ->
@connection.subscribe channel, callback
App.register 'pushClient:main', App.PushClient
App.inject 'router', 'pushClient', 'pushClient:main' # inject pushClient into router