Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

andriy-baran

🎯
Focusing
View GitHub Profile
@zinovyev
zinovyev / webpacker_helper.rb
Created Mar 28, 2019
Rails helper for loading controller specific assets managed by Webpacker
View webpacker_helper.rb
module WebpackerHelper
def page_pack_tags
join_paths(application_pack_tags,
controller_pack_tags)
end
def application_pack_tags
join_paths(attempt_to_find(:stylesheet, 'application'),
attempt_to_find(:javascript, 'application'))
end
@davidcornu
davidcornu / EventedClass.coffee
Created Jan 19, 2012
Allows CoffeeScript classes to trigger their own events and allow binding to them.
View EventedClass.coffee
class EventedClass
bind: (event, callback) ->
@eventHandlers ||= {}
@eventHandlers[event] = [] unless @eventHandlers[event]?
@eventHandlers[event].push(callback)
return true
unbind: (event, callback) ->
@eventHandlers ||= {}