View for.clj
This file contains 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
; xs = '{a {p 1, q 2} b {m 3, n 4}} | |
(for [[x y] xs] | |
(for [[a b] y] | |
[[a x] b])) | |
; this produces | |
; (({[a p] 1} {[a q] 2}) ({[b m] 3} {[b n] 4})) | |
; | |
; I require |
View group.js
This file contains 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.computed.groupable = function(dependentKey, groupBy){ | |
var options = { | |
initialValue: [] , | |
initialize: function(array, changeMeta, instanceMeta){ | |
}, | |
addedItem: function(array, item, changeMeta, instanceMeta){ | |
var key = groupBy(item); | |
var group = array.findBy('key', key); | |
View grouped2.js
This file contains 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
groupedDeals: Ember.arrayComputed('contacts', 'deals.@each.status', { | |
initialValue: [], | |
initialize: function(array, changeMeta, instanceMeta) { | |
array.pushObject(Ember.Object.create({key: 'open',name: 'Open Deals',count: 0,value: 0,deals: Ember.A()})); | |
array.pushObject(Ember.Object.create({key: 'closed',name: 'Closed Deals',count: 0,value: 0,deals: Ember.A()})); | |
array.pushObject(Ember.Object.create({key: 'lost',name: 'Lost Deals',count: 0,value: 0,deals: Ember.A()})); | |
}, | |
addedItem: function(array, deal, changeMeta, instanceMeta) { | |
var contact = deal.get('contact'); | |
View serializer.rb
This file contains 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
class UserSerializer < ActiveModel::Serializer | |
embed :ids | |
attributes :id | |
attributes :activity_ids | |
def activity_ids | |
{url: "/users/#{object.id}/activities"} | |
end | |
end |
View .vimrc
This file contains 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
augroup myvimrc | |
au! | |
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif | |
augroup END |
View reduce.js
This file contains 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.CompanyItemController = Ember.ObjectController.extend({ | |
total: Ember.reduceComputed("deals.@each.{status,value}", { | |
initialValue: 0, | |
addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
if (item.get('state') === 'lost') { | |
return accumulatedValue; | |
} | |
return accumulatedValue + item.get('value'); | |
}, | |
removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { |
View reduce-redux.js
This file contains 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.CompanyItemController = Ember.ObjectController.extend({ | |
openDeals: Ember.computed.filter('deals.@each.{status,value}', function(item){ | |
return item.get('state') !== 'lost'; | |
}), | |
opendDealsValues: Ember.computed.mapBy('openDeals', 'value'), | |
total: Ember.computed.sum("opendDealsValues"), | |
dealTotals: App.computed.groupable('deals',function(deal){ | |
return deal.get('state'); | |
}) | |
}); |
View brace.js
This file contains 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.CompanyItemController = Ember.ObjectController.extend({ | |
openDeals: Ember.computed.filter('deals.@each.{status,value}', function(item){ | |
return item.get('state') !== 'lost'; | |
}), | |
total: Ember.computed.sum("opendDealsValues"), | |
dealTotals: App.computed.groupable('deals',function(deal){ | |
return deal.get('state'); | |
}) | |
}); |
View sp.js
This file contains 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.CompanyItemController = Ember.ObjectController.extend({ | |
openDeals: Ember.computed.filter('deals.@each.{status,value}', function(item){ | |
return item.get('state') !== 'lost'; | |
}), | |
total: Ember.computed.sum("opendDealsValues"), | |
dealTotals: App.computed.groupable('deals',function(deal){ | |
return deal.get('state'); | |
}) | |
}); |
View aggregate.js
This file contains 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
// USAGE | |
// App.SomeModel = DS.Model.extend ({ | |
// users: DS.hasMany('users'), | |
// contacts: DS.hasMany('contacts') | |
// // Aggregate users and contacts into one array | |
// people: App.computed.aggregate('users', 'contacts') | |
// }) | |
// | |
App.computed.aggregate = function() { |
OlderNewer