This is a very trivial example of using mirage with Ember Twiddle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { computed } = Ember; | |
const { readOnly } = computed; | |
export default Ember.Component.extend({ | |
cost: readOnly('delayedCalculation.cost'), | |
tax: readOnly('delayedCalculation.tax'), | |
total: computed('cost', 'tax', function() { | |
return this.get('cost') + this.get('tax'); | |
}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.profileEditorController = Em.ObjectController.extend({ | |
addressBinding: 'content.address' | |
}); | |
App.Router = Em.Router.extend({ | |
root: Em.Route.extend({ | |
profile: Em.Route.extend({ | |
route: 'profile', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(($)-> | |
$.fn.logoPopup = -> | |
this.mousedown -> | |
$(document).bind("contextmenu", (event)-> | |
true | |
) | |
if event.which == 3 | |
$('<div id="logo-lightbox-container">').hide().appendTo('body').load('/u/logo', -> | |
$.easybox("#logo-lightbox-container") | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.ProjectSelectView = Ember.CollectionView.extend({ | |
selected: null, | |
itemViewClass: Ember.View.extend({ | |
attributeBindings:['selected'], | |
valueBinding: 'content.selected' | |
}), | |
valueChanged: function(){ | |
this.$().val( this.get('selected') ); | |
}.observes('selected'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object @posts | |
attributes :id, :title, :created_at | |
child :user do | |
extends "users/show" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
x = 10_000 | |
first_id = Sport.first.id | |
key = "Sport:#{first_id}" | |
Sport.set key, Sport.find(first_id) # prime cache | |
Benchmark.bm(20) do |b| | |
b.report "Sport.get" do |