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
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
_observer1: Ember.observer('foobar', function() { | |
//something here | |
}).on('init'), | |
_observer2: Ember.on('init', Ember.observer('foobar', function() { | |
//something here | |
})) | |
}); |
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 Api::V1::UserSerializer < Api::V1::BaseSerializer | |
type :users | |
attributes :id, :name | |
has_many :microposts, serializers: Api::V1::MicropostSerializer do | |
link :self, '/api/v1/microposts' | |
end | |
end |
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
import Ember from 'ember'; | |
import Notify from 'ember-notify'; | |
export default Ember.Route.extend(ApplicationRouteMixin, { | |
actions: { | |
error: function (errorObject) { | |
if (errorObject) { | |
if (errorObject.status === 401) { | |
return this.transitionTo('login'); |
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
{ | |
"extends": "airbnb", | |
"env": { | |
"browser": true | |
}, | |
"rules": { | |
"no-underscore-dangle": 0, | |
"class-methods-use-this": 0, | |
"arrow-body-style": 0, | |
"no-console": 0, |
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
pi@raspberrypi:~ $ crystal | |
/opt/crystal/embedded/bin/crystal: /lib/arm-linux-gnueabihf/libtinfo.so.5: no version information available (required by /opt/crystal/embedded/bin/crystal) | |
/opt/crystal/embedded/bin/crystal: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /opt/crystal/embedded/bin/crystal) |
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
module ActionDispatch | |
class Flash | |
class FlashHash | |
# Returns a hash that includes everything but the given keys. | |
# hash = { a: true, b: false, c: nil} | |
# hash.except(:c) # => { a: true, b: false} | |
# hash # => { a: true, b: false, c: nil} | |
# | |
# This is useful for limiting a set of parameters to everything but a few known toggles: | |
# @person.update(params[:person].except(:admin)) |
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 Foobar | |
def run! | |
self.foobar = 'test' #doesn't fail? | |
hey = self.foobar #bang! fails | |
end | |
private | |
attr_accessor :foobar | |
end | |
Foobar.new.run! |
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
module NestedControllers | |
CALLBACKS_OPTS = [:filter, :if, :unless, :kind].freeze | |
#adds the relative paths to controller so you can do `render 'subcontroller/something'` | |
#instead of `render 'parent_controller/subcontroller/something'` | |
#(solves 2) | |
def self.extended(base) | |
base.prepend_view_path("app/views/#{base.controller_path}/") | |
end |
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
#ENV: Ruby 2.4.1, a i7-6700HQ CPU, 16GB RAM | |
require 'benchmark' | |
require 'delegate' | |
require 'forwardable' | |
class Person | |
def initialize(name) | |
@name = name | |
end |