Skip to content

Instantly share code, notes, and snippets.

View andriy-baran's full-sized avatar
🎯
Focusing

andriy-baran

🎯
Focusing
View GitHub Profile
@equivalent
equivalent / README.md
Last active April 8, 2024 03:00
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

@bantic
bantic / rails_route_recognizer.rb
Last active September 9, 2022 12:22
Programmatically list all routes (/paths) from within a rails app.
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize
@davidcornu
davidcornu / EventedClass.coffee
Created January 19, 2012 17:08
Allows CoffeeScript classes to trigger their own events and allow binding to them.
class EventedClass
bind: (event, callback) ->
@eventHandlers ||= {}
@eventHandlers[event] = [] unless @eventHandlers[event]?
@eventHandlers[event].push(callback)
return true
unbind: (event, callback) ->
@eventHandlers ||= {}
@zinovyev
zinovyev / webpacker_helper.rb
Created March 28, 2019 21:34
Rails helper for loading controller specific assets managed by Webpacker
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