Rails 7.2 defaults:
Highscore.connection
# => #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x000000000080e8 env_name="development" role=:writing>
With config.active_record.permanent_connection_checkout = :disallowed
:
# frozen_string_literal: true | |
class ApplicationService | |
def self.call(...) | |
new(...).call | |
end | |
def initialize(...) | |
end | |
end |
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "json_pure" | |
gem "benchmark-ips" | |
end |
source "https://rubygems.org" | |
gemspec |
These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.
/** | |
* GlobalsDebugger | |
* | |
* Inspect the stack when a global variable is being set on the window object. | |
* Given a global variable name, it proxies the variable name in the window | |
* object adding some custom code that will be invoked whenever the variable | |
* is set. The custom code will log the current stack trace and halt the code | |
* execution to allow inspecting the stack and context in your browser DevTools. | |
* You can use the "globalsToInspect" query-parameter to set a comma-separated | |
* list of names of the variables you want to inspect. |
require 'benchmark' | |
require 'etc' | |
Ractor.new { :warmup } if defined?(Ractor) | |
def fibonacci(n) | |
return n if (0..1).include? n | |
fibonacci(n - 1) + fibonacci(n - 2) | |
end |
# Add color coding based on Rails environment for safety | |
if defined? Rails | |
banner = if Rails.env.production? | |
"\e[41;97;1m #{Rails.env} \e[0m " | |
else | |
"\e[42;97;1m #{Rails.env} \e[0m " | |
end | |
# Build a custom prompt |
If we terminate a loop early, for-of
invokes method .return()
of the iterator. Generators return generator objects (that implement both the Iterable interface and the Iterator interface). If we invoke .return()
on such an object, the generator is terminated. We can prevent that by overriding .return()
.
More information: https://exploringjs.com/es6/ch_iteration.html#sec_iteration-protocol-in-depth
Demonstration:
function logIter(iter) {