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
<div x-data @remove='console.log($el, "removed")'></div> |
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
# adds `acts_as_list` and a `ordered` scope with given scope | |
# usage: | |
# include Listable | |
# include Listable[scope: :user] | |
module Listable | |
extend ActiveSupport::Concern | |
included do | |
include ListableModule.new | |
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
class HashSchema | |
def initialize(schema) | |
@schema = schema.map { |key, type| | |
[key, HashSchema.lookup(type)] | |
}.to_h | |
end | |
def cast(params) | |
params.map { |key, value| | |
[key, @schema[key] ? @schema[key].cast(value) : value] |
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
<div data-controller="smart-scroll" | |
data-action="smart-scroll:added->smart-scroll#handleAdded | |
resize->smart-scroll#handleAdded | |
scroll->smart-scroll#handleScroll"> | |
<div data-controller="smart-scroll-item"> | |
aya: an an | |
</div> | |
<div data-controller="smart-scroll-item"> | |
hatate: ni hao | |
</div> |
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
default: &default | |
adapter: mysql2 | |
encoding: utf8mb4 | |
charset: utf8mb4 | |
collation: utf8mb4_unicode_ci |
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
# 不考慮重複 key 和無 value 的情況 | |
parseQS = (qs = location.search) -> | |
object = {} | |
pairs = qs.substring(1) # 去除前置 ? 字元 | |
.split('&') # 變成一堆 oo=xx 字串 | |
for pair in pairs | |
[key, value] = pair.split('=') | |
object[key] = value |
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
Rails.application.config.assets.precompile += %w( ratchicons.eot | |
ratchicons.woff | |
ratchicons.ttf | |
ratchicons.svg ) |
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
namespace :deploy do | |
namespace :assets do | |
Rake::Task['deploy:assets:precompile'].clear_actions | |
desc "Precompile assets on local machine and upload them to the server." | |
task :precompile do | |
run_locally do | |
execute 'RAILS_ENV=production bundle exec rake assets:precompile' | |
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
require 'rack/rewrite' | |
Rails.application.config.middleware.insert(0, Rack::Rewrite) do | |
rewrite %r{^/(?!assets|auth|admin)}, '/' | |
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
class CustomSlimEngine < Slim::Template | |
def evaluate(scope, locals, &block) | |
scope.class_eval do | |
include Rails.application.routes.url_helpers | |
include Rails.application.routes.mounted_helpers | |
include ActionView::Helpers | |
end | |
super | |
end |
NewerOlder