Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
HeroicEric / sort_by_example.rb
Created August 14, 2014 13:53
Example of Enumerable#sort_by
# http://ruby-doc.org/core-2.1.2/Enumerable.html#method-i-sort_by
people = [
{ first_name: 'Eric', last_name: 'Kelly' },
{ first_name: 'John', last_name: 'Smith'},
{ first_name: 'Adam', last_name: 'Sheehan' },
{ first_name: 'Richard', last_name: 'Davis' },
]
sorted_people = people.sort_by do |person|
@HeroicEric
HeroicEric / enumerable_example_p1.md
Last active August 29, 2015 14:05
Enumerable Examples - Part 1

Enumerable Examples

[Enumerable][enumerable] is a mixin that is used to add additional functionality to collection classes like Array and Hash. This means that you can use the methods defined in Enumerable on both arrays and hashes.

#map

[Enumberable#map][map] is useful when you want to create a new array by iterating over some collection of values, and calculate a new value based on

general:
build_dir: rails
dependencies:
post:
- cd ../ember && npm install
- cd ../ember && bower install
cache_directories:
- "../ember/node_modules"
- "../ember/bower_components"
test:
** (FunctionClauseError) no function clause matching in Ecto.Adapters.Postgres.DateTime.encode_date/1
stacktrace:
(ecto) lib/ecto/adapters/postgres/datetime.ex:36: Ecto.Adapters.Postgres.DateTime.encode_date({{2010, 4, 17}, {14, 0, 0, 0}})
lib/postgrex/protocol.ex:280: anonymous fn/2 in Postgrex.Protocol.encode_params/1
(elixir) lib/enum.ex:977: anonymous fn/3 in Enum.map/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:977: Enum.map/2
lib/postgrex/protocol.ex:275: Postgrex.Protocol.encode_params/1
lib/postgrex/protocol.ex:245: Postgrex.Protocol.send_params/2
lib/postgrex/protocol.ex:126: Postgrex.Protocol.message/3
@HeroicEric
HeroicEric / application.route.js
Created July 24, 2015 02:59 — forked from lmcardle/application.route.js
Ember.computed.oneWay issue
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return {name: 'sam'};
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
const {
computed,
get,
isPresent
} = Ember;
export default Ember.Controller.extend({
appName:'Ember Twiddle',
@HeroicEric
HeroicEric / components.foo-bar.js
Last active August 29, 2015 14:27
Closure Actions vs Bubbled Actions
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
closureAction() {
this.attrs.closureAction();
},
bubbledAction() {
this.sendAction('bubbledAction');
import Ember from 'ember';
const {
computed,
get
} = Ember;
const { alias } = computed;
export default Ember.Controller.extend({
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});