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
#!/usr/bin/env ruby | |
# https://twitter.com/smlpth/status/1693574834179961234 | |
# "I have an array of amounts on one hand and a target amount on the other. I need to find a combination of amounts in the array that sums to the target. If multiple combinations work, take the one containing the most recent amounts." | |
require 'logger' | |
logger = Logger.new(STDOUT) | |
logger.level = :debug # set it to info to only see matches | |
# logger.level = :info |
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
# Initialize the application passing the given group. By default, the | |
# group is :default | |
def initialize!(group = :default) #:nodoc: | |
raise "Application has been already initialized." if @initialized | |
run_initializers(group, self) | |
@initialized = true | |
self | |
end | |
def run_initializers(group = :default, *args) | |
return if instance_variable_defined?(:@ran) |
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
# Load the Rails application. | |
require_relative 'application' | |
# Initialize the Rails application. | |
Rails.application.initialize! |
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
# This file is used by Rack-based servers to start the application. | |
require_relative 'config/environment' | |
run Rails.application |
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_option :config, aliases: "-c", type: :string, default: "config.ru", | |
desc: "Uses a custom rackup configuration.", banner: :file | |
# [...] | |
def server_options | |
{ | |
user_supplied_options: user_supplied_options, | |
server: using, | |
log_stdout: log_to_stdout?, |
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 Iluvrails | |
class Application < Rails::Application | |
# Initialize configuration defaults for originally generated Rails version. | |
config.load_defaults 6.0 | |
# Settings in config/environments/* take precedence over those specified here. | |
# Application configuration can go into files in config/initializers | |
# -- all .rb files in that directory are automatically loaded after loading | |
# the framework and any gems in your application. | |
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
# frozen_string_literal: true | |
# rubocop:disable Style/RedundantBegin | |
require "rails" | |
%w( | |
active_record/railtie | |
active_storage/engine | |
action_controller/railtie | |
action_view/railtie | |
action_mailer/railtie | |
active_job/railtie |
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_relative 'boot' | |
require 'rails/all' | |
# Require the gems listed in Gemfile, including any gems | |
# you've limited to :test, :development, or :production. | |
Bundler.require(*Rails.groups) | |
module Iluvrails | |
class Application < Rails::Application | |
# Initialize configuration defaults for originally generated Rails version. |
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
def perform | |
extract_environment_option_from_argument | |
set_application_directory! | |
prepare_restart | |
Rails::Server.new(server_options).tap do |server| | |
# Require application after server sets environment to propagate | |
# the --environment option. | |
require APP_PATH | |
Dir.chdir(Rails.application.root) | |
if server.serveable? |
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 | |
require "rails/command" | |
aliases = { | |
"g" => "generate", | |
"d" => "destroy", | |
"c" => "console", | |
"s" => "server", | |
"db" => "dbconsole", | |
"r" => "runner", | |
"t" => "test" |
NewerOlder