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
URI.open(url) do |uri| | |
base_uri = uri.base_uri | |
listable_type = case base_uri.to_s | |
when /soundcloud.com\/(?<artist>.+)\/tracks/ | |
raise UnparsableTrackUrlError | |
when /soundcloud.com\/(?<artist>.+)\/sets\/(?<title>.+)/ | |
SoundCloudPlaylist | |
when /soundcloud.com\/(?<artist>.+)\/(?<title>.+)/ | |
SoundCloudTrack |
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 { LitElement, html, css } from "lit"; | |
import { property, customElement } from "lit/decorators.js"; | |
@customElement("content-element-input") | |
class ContentElementInput extends LitElement { | |
@property({ type: Boolean }) | |
contentEditable = true; | |
@property({ type: String }) | |
placeholder = ""; |
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 YieldsMembers | |
module ClassMethods | |
mattr_accessor :method_names | |
def yields_members_for(*method_names) | |
self.method_names = method_names | |
end | |
end | |
def initialize(...) | |
super(...) |
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 YieldsMembers | |
module ClassMethods | |
def yields_members_for(*method_names) | |
module_eval do | |
# method_names.each do |method_name| | |
binding.pry | |
define_method :add do |*members, &proc| | |
puts "IN PREPENDED MODULE" | |
binding.pry | |
super members |
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
// useHotkeys.js | |
import hotkeys from "hotkeys-js"; | |
export const bindHotkeys = (controller) => { | |
hotkeys.filter = () => true; | |
for (const [hotkey, handler] of Object.entries( | |
controller.constructor.hotkeys | |
)) { | |
hotkeys(hotkey, (e) => controller[handler](e)); |
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 ApplicationCable | |
class Connection < ActionCable::Connection::Base | |
identified_by :current_user | |
identified_by :session_id | |
def connect | |
self.current_user = env["warden"].user | |
self.session_id = request.session.id | |
reject_unauthorized_connection unless self.current_user || self.session_id | |
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
module Submittable | |
extend ActiveSupport::Concern | |
include StimulusReflex::ConcernEnhancer | |
included do | |
prepend_before_reflex do | |
instance_variable_set("@#{resource_name.underscore}", resource_class.new(submit_params)) | |
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 { navigator } from "@hotwired/turbo"; | |
import { Controller } from "stimulus"; | |
import { useMutation } from "stimulus-use"; | |
export default class extends Controller { | |
connect() { | |
useMutation(this, { attributes: true, childList: true, subtree: true }); | |
} | |
mutate(entries) { |
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
# app/models/application_record.rb | |
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
cattr_accessor :skip_callbacks | |
end | |
# app/models/concerns/user_notifiable.rb | |
module UserNotifiable | |
included do |
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
# app/helpers/application_helper.rb | |
module ApplicationHelper | |
def onboarding_step_path(workflow) | |
board = workflow.user.boards&.first | |
case workflow.next_step | |
when :create_board | |
new_board_path | |
when :create_embed | |
board_path(board) | |
when :create_comment |