Skip to content

Instantly share code, notes, and snippets.

@jgwhite
jgwhite / app.js
Last active August 29, 2015 13:56
App = Ember.Application.create();
App.Router.map(function () {
this.resource('user', function () {
this.route('links');
});
});
App.IndexRoute = Em.Route.extend({
beforeModel: function () {
App = Ember.Application.create();
App.Router.map(function () {
this.resource('slow', function () {
this.resource('really-slow');
});
});
App.SlowRoute = Ember.Route.extend({
model: function () {
@jgwhite
jgwhite / quine.js
Last active August 29, 2015 13:59
Quines
var p = 'var p = x, q = ', q = 'console.log(p.replace("x", String.fromCharCode(39) + p + String.fromCharCode(39)) + String.fromCharCode(39) + q + String.fromCharCode(39) + String.fromCharCode(10) + q)'
console.log(p.replace("x", String.fromCharCode(39) + p + String.fromCharCode(39)) + String.fromCharCode(39) + q + String.fromCharCode(39) + String.fromCharCode(10) + q)
@jgwhite
jgwhite / adding_a_session.feature
Created May 3, 2014 10:15
Decent example of a cucumber spec
Feature: Adding a session
Scenario:
Given I am in London
Given it is 28 April 2014 at 12:00
And I am signed in to Google as "someone@example.com"
When I visit "/admin"
And I fill in "Add a session" with "Wednesday at 2pm"
And I click "Add"
Then I see "Wednesday 2:00–2:30pm"
@jgwhite
jgwhite / ds-many-array-ext.js
Last active August 29, 2015 14:01
Initializer for reopening an Ember built-in class
// app/initializers/ds-many-array-ext.js
export default {
name: 'ds-many-array-ext',
initialize: function(container, app) {
DS.ManyArray.reopen({
// ...
});
}
};
/* global require */
var Application = require('my-app/app')['default'];
var Router = require('my-app/router')['default'];
export default function startApp(attrs) {
var App;
var attributes = Ember.merge({
// useful Test defaults
@jgwhite
jgwhite / Brocfile.js
Created May 27, 2014 15:08
Example brocfile
/* global require, module */
// NOTE: npm install broccoli-static-compiler broccoli-merge-trees --save-dev
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
name: require('./package.json').name,
@jgwhite
jgwhite / Brocfile.js
Last active August 29, 2015 14:01
Using Ember Canary with ember-cli (cribbed from https://github.com/abuiles/facturas)
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var fileMover = require('broccoli-file-mover');
var vendorTree = fileMover('vendor', {
files: {
'ember/index.js': 'ember/ember.js',
'ember-prod/index.js': 'ember/ember.prod.js'
}
module.exports = function(app) {
app.get('<%= path %>', function(req, res) {
res.send('hello');
});
};
@jgwhite
jgwhite / 1-request
Created June 12, 2014 11:12
discuss.emberjs.com CDN
GET /cdn_asset/discuss_emberjs_com/vendor-6328298c3c407b36ae3fadbbb8814df9.js?origin=http%3A%2F%2Fdiscuss.emberjs.com HTTP/1.1
Host: scdn-discourse.r.worldssl.net
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache
Accept: */*
Origin: http://discuss.emberjs.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36
Referer: http://discuss.emberjs.com/
Accept-Encoding: gzip,deflate,sdch