Skip to content

Instantly share code, notes, and snippets.

View chadhietala's full-sized avatar
🎯
Focusing

Chad Hietala chadhietala

🎯
Focusing
View GitHub Profile
@chadhietala
chadhietala / gist:3739958
Created September 17, 2012 21:39
Contributor Model
App.Contributor = Ember.Object.extend()
App.Contributor.reopenClass
allContributors: []
find: ->
$.ajax
url: 'https://api.github.com/repos/emberjs/ember.js/contributors'
dataType: 'jsonp'
success: (resp) =>
resp.data.forEach ((contributor) =>
@allContributors.addObject App.Contributor.create(contributor)
@chadhietala
chadhietala / Dataminer.coffee
Last active October 14, 2015 00:38
Code Examples From Want
class Dataminer
mine: (type) ->
if this[type]
this[type]()
else
new Error 'Non-valid data type to mine. Acceptable types are image, url, and title'
image: ->
ogImage = queryOpenGraphParam "meta[property='og:image']"
@chadhietala
chadhietala / app.rb
Created December 15, 2012 18:14
Wordpress Layouts Code Examples
require 'shotgun'
require 'sinatra'
require 'mongo'
require 'json/pure'
uri = URI.parse(ENV['MONGOLAB_URI'])
conn = Mongo::Connection.from_uri(ENV['MONGOLAB_URI'])
db = conn.db(uri.path.gsub(/^\//, ''))
PAGE_SIZE = 20
@chadhietala
chadhietala / store.js
Created March 13, 2013 14:37
Handle MongoDBs and CouchDBs _ID in Ember 1.0.0-RC-1 and Ember Data Rev 11
App.Adapter = DS.RESTAdapter.extend({
serializer: DS.RESTSerializer.extend({
primaryKey: function(type){
return '_id';
}
})
});
App.Store = DS.Store.extend({
var desktop = new EmberApp({
trees: {
app: 'app/desktop',
templates: 'app/desktop/templates',
styles: 'app/desktop/styles'
}
});
@chadhietala
chadhietala / gist:692b4829c014487f5ec9
Last active August 29, 2015 14:07
Models in Ember

URLS And APIs

In Ember everything developed around the URL. In an Ember application you define your routes in a DSL that looks like the following.

Ember.Router.map(function () {
   this.resource('profile', { path: '/:profile_id' });
});

So when a user goes to profile/123 what happens that URL maps to ProfileRoute where the url is serialized and passed to the model hook so you can ask the data store to preform a GET on /api/profile/123.

743 passing (5m)
4 pending
3 failing
1) Acceptance: addon-smoke-test "after each" hook:
AssertionError: tmp/ should be empty after `ember` tasks. Contained: caching-writer-dest-dir_PwSDFK.tmp/
caching-writer-dest-dir_PwSDFK.tmp/environments/
caching-writer-dest-dir_PwSDFK.tmp/environments/development.json
caching-writer-dest-dir_PwSDFK.tmp/environments/test.json
@chadhietala
chadhietala / master
Created February 25, 2015 05:13
io.js (reopen-method branch)
core-object/create (0) x 56,417,825 ops/sec ±1.21% (91 runs sampled)
core-object/create (1) x 26,906,821 ops/sec ±1.11% (90 runs sampled)
core-object/create (5) x 11,057,028 ops/sec ±0.94% (86 runs sampled)
core-object/create (default init) (0) x 56,052,254 ops/sec ±0.94% (89 runs sampled)
core-object/create (default init) (1) x 26,311,756 ops/sec ±0.95% (91 runs sampled)
core-object/create (default init) (5) x 10,421,557 ops/sec ±1.20% (88 runs sampled)
uberproto/create (0) x 4,621,752 ops/sec ±1.16% (89 runs sampled)
uberproto/create (1) x 4,658,817 ops/sec ±1.07% (91 runs sampled)
uberproto/create (5) x 4,637,146 ops/sec ±0.97% (87 runs sampled)
raw/create (0) x 40,304,048 ops/sec ±1.04% (88 runs sampled)
@chadhietala
chadhietala / gist:9c1620fe1c2a494f695d
Created March 5, 2015 17:45
Async Tests In QUnit 2.0
var QUnit = require('qunitjs');
QUnit.module('foo', {
afterEach:function(assert) {
var done = assert.async();
setTimeout(function() {
done();
}, 1000);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
data: Ember.computed(function() {
let arr = [];
let i = 0;
while (i < 100) {
arr.push(i);
i++;