Skip to content

Instantly share code, notes, and snippets.

👌
Enjoying life, including work.

Balint Erdi balinterdi

👌
Enjoying life, including work.
Block or report user

Report or block balinterdi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View components.my-component-1.js
import Ember from 'ember';
export default Ember.Component.extend({
myFirstAction: '',
actions: {
myComponentAction() {
this.sendAction('myFirstAction');
}
}
});
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
myColor: 'red',
});
View controllers.application.js
import Ember from 'ember';
function loadAndSave(loadingProperty, operation) {
this.set(loadingProperty, true);
return operation.finally(() => {
this.set(loadingProperty, false);
});
}
export default Ember.Controller.extend({
@balinterdi
balinterdi / songs_controller.rb
Created Sep 23, 2016
Some non-working ways to use jsonapi_resources primitives to craft a response
View songs_controller.rb
class SongsController < ApplicationController
def index
# params[:bandId], params[:q]
serializer = JSONAPI::ResourceSerializer.new(SongResource)
resource = SongResource.new(song, context)
render json: serializer.serialize_to_hash(resource)
end
def index
@balinterdi
balinterdi / destructuring.js
Last active Sep 6, 2016
Fooling around with ES2015 destructurings
View destructuring.js
var pearlJam = {
members: [
{ firstName: 'Eddie', lastName: 'Vedder' },
{ firstName: 'Mike', lastName: 'McCready' },
{ firstName: 'Jeff', lastName: 'Ament' },
]
}
let { members: [ eddieVedder ] } = pearlJam;
let { firstName: eddie } = eddieVedder;
@balinterdi
balinterdi / person.js
Created Jun 20, 2016
Composing `friendships` from the constituent parts - doesn't work
View person.js
export default Model.extend({
name: DS.attr(),
frienderFriendships: DS.hasMany('friendship', { inverse: 'friender' }),
friendedFriendships: DS.hasMany('friendship', { inverse: 'friended' }),
friendships: Ember.computed('frienderFriendships', 'friendedFriendships', function() {
let friendedFriendshipsRel = this.hasMany('friendedFriendships');
let frienderFriendshipsRel = this.hasMany('frienderFriendships');
let frienderFriendships;
@balinterdi
balinterdi / route.js
Created Jun 20, 2016
Eager-fetch belongsTo relationships – does not work
View route.js
model(params) {
return this.store.findRecord('person', params.person_id)
.then((person) => {
return {
friendships: person.get('friendships', { include: 'friender,friended' }),
person
}});
},
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@balinterdi
balinterdi / ga-events.js
Created Mar 4, 2016
Prevent GA to report too high of a bounce rate for your "one page at one visit" site (a landing page or a blog)
View ga-events.js
$.domReady(function(){
// Fire an event so that GA doesn't count it as a "bounce"
// http://blog.popcornmetrics.com/why-your-google-analytics-bounce-rate-is-wrong-and-how-to-fix-it/
function readPage() {
ga('send', {
'hitType': 'event',
'eventCategory': 'engagement',
'eventAction': 'read'
});
}
@balinterdi
balinterdi / app.css
Last active Feb 3, 2016
Binding style attributes warning in Ember
View app.css
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.bordered {
border: 1px solid blue;
height: 100px;
}
You can’t perform that action at this time.