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 'date' | |
class Sorter | |
def initialize(*instructions) | |
@defaults = { | |
direction: :ascending, | |
nils: :small, | |
accessor: :itself, | |
case_sensitive: true, | |
normalized: false, |
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
# frozen_string_literal: true | |
module Router | |
class << self | |
include Rails.application.routes.url_helpers | |
def default_url_options | |
Rails.application.config.action_controller.default_url_options || {} | |
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 'sqlite3' | |
require 'minitest/autorun' | |
puts "info: gem version: #{SQLite3::VERSION}" | |
puts "info: sqlite version: #{SQLite3::SQLITE_VERSION}/#{SQLite3::SQLITE_LOADED_VERSION}" | |
puts "info: sqlcipher?: #{SQLite3.sqlcipher?}" | |
puts "info: threadsafe?: #{SQLite3.threadsafe?}" | |
class TestCase < Minitest::Test | |
def setup |
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 'benchmark' | |
require 'active_record' | |
require 'pg' | |
# ----------------------------------------------------------------------------- | |
INPUT_COLUMNS = { | |
name: "Name of benchmark", | |
iters: "Number of iterations the block is run", | |
usr_time: "Amount of user CPU time", |
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 ArrayColumns | |
extend ActiveSupport::Concern | |
class_methods do | |
def array_columns_sanitize_list(values = []) | |
return [] if values.nil? | |
values.select(&:present?).map(&:to_s).uniq.sort | |
end | |
def array_columns(*column_names) |
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 :db do | |
namespace :snap do | |
task setup: :environment do | |
@snapshot_dir = Rails.root.join('storage/snapshots') | |
@db_path = ActiveRecord::Base.connection_db_config.database | |
@db_name = @db_path.rpartition('/').last.remove('.sqlite3') | |
end | |
task setup_snaps: :setup do | |
@snaps = Pathname(@snapshot_dir) |
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 "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "sqlite3" | |
gem "enumerable-statistics" | |
end | |
require "benchmark" |
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/concerns/has_many_attached.rb | |
module HasManyAttached | |
extend ActiveSupport::Concern | |
class_methods do | |
def has_many_attached(name, dependent: :purge_later, service: nil, strict_loading: false, **options) | |
super(name, dependent: :purge_later, service: nil, strict_loading: false) | |
if options[:file_types].any? | |
validate "validate_#{name}_file_types".to_sym |
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
<form action="#"> | |
<section data-controller="passphrase"> | |
<label for="passphrase-for-registration">Passphrase</label> | |
<input type="text" | |
id="passphrase-for-registration" | |
data-passphrase-registration-target="input" | |
data-action="passphrase#validate" | |
autocomplete="new-password" | |
required | |
minlength="12" |
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 RailsExt | |
module SQLite3Adapter | |
# Perform any necessary initialization upon the newly-established | |
# @raw_connection -- this is the place to modify the adapter's | |
# connection settings, run queries to configure any application-global | |
# "session" variables, etc. | |
# | |
# Implementations may assume this method will only be called while | |
# holding @lock (or from #initialize). | |
# |
NewerOlder