Rails 6.1で新しく入る機能について
@willnet
最近のRailsリリース日
- 6.0.0 (2019/08/06)
- 5.2.0 (2018/04/09)
- 5.1.0 (2017/04/27)
- 5.0.0 (2016/06/30)
require 'set' | |
class InspectAssociations | |
def self.call(model) | |
new.call(model) | |
end | |
def call(model) | |
return if set.include?(model) | |
set.add(model) |
require 'ferrum' | |
require 'base64' | |
browser = Ferrum::Browser.new(logger: File.open('/tmp/hoge.log', 'w')) | |
Dir.mktmpdir do |dir| | |
browser.on('Page.screencastFrame') do |params, index, total| | |
File.open("#{dir}/#{Time.now.strftime('%Y%m%d%H%M%S%L.jpeg')}", 'w') do |f| | |
f.write(Base64.decode64(params['data'])) | |
end |
ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |model| | |
string_or_text_columns = model.columns.select { |column| column.type == :string || column.type == :text } | |
columns_with_maximum_length_validation = model.validators.select {|v| v.is_a? ActiveRecord::Validations::LengthValidator }.select {|v| v.options[:maximum] || v.options[:within] }.map(&:attributes).flatten.uniq | |
string_or_text_columns.each do |column| | |
if columns_with_maximum_length_validation.include?(column.name.to_sym) | |
puts "#{model.name}##{column.name} is OK" | |
else | |
puts "#{model.name}##{column.name} is NG" | |
end | |
end |
// chromeを利用して、ユーザ一覧を表示しつつconsoleで↓を実行すると、現在の参加者からランダムで一人表示することができます | |
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word)=> !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin_outline/)) | |
const names_set = new Set(names_array) | |
const names_uniq_array = Array.from(names_set) | |
names_uniq_array[Math.floor(Math.random() * names_uniq_array.length)] |
source 'https://rubygems.org' | |
platforms :jruby do | |
gem 'railties' | |
end | |
group :test do | |
gem 'railties' | |
end |
class ApplicationRecord < ActiveRecord::Base | |
@ar_initialize_counter = Hash.new(0) | |
@ar_find_counter = Hash.new(0) | |
after_initialize :count_initialize | |
def count_initialize | |
return unless ApplicationRecord.enable_counter? | |
gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } | |
caller_in_app = caller.find { |file_and_lineno| file_and_lineno !~ gems_paths} |
{ | |
"mode": "development", | |
"output": { | |
"filename": "js/[name]-[contenthash].js", | |
"chunkFilename": "js/[name]-[contenthash].chunk.js", | |
"hotUpdateChunkFilename": "js/[id]-[hash].hot-update.js", | |
"path": "/Users/willnet/tmp/webpacker5/public/packs", | |
"publicPath": "/packs/" | |
}, | |
"resolve": { |
@willnet
Calculating ------------------------------------- | |
erubi v1.9.0 20.994k i/100ms | |
slim v4.0.1 20.212k i/100ms | |
haml v5.1.2 11.562k i/100ms | |
faml v0.8.1 18.360k i/100ms | |
hamlit v2.10.0 21.497k i/100ms | |
------------------------------------------------- | |
erubi v1.9.0 245.242k (± 1.6%) i/s - 1.239M | |
slim v4.0.1 233.443k (± 2.2%) i/s - 1.172M |
class WrapperForKaminari | |
attr_reader :total_count, :per, :page | |
delegate_missing_to :@models | |
def initialize(models:, total_count:, per:, page:) | |
@models = models | |
@total_count = total_count | |
@per = per | |
@page = page | |
end |