This is a Ruby on Rails application that helps users with benefits applications. The application uses:
- Ruby on Rails 8
- PostgreSQL database
- Bootstrap 5.3 for UI styling
- Hotwire (Turbo and Stimulus) for frontend interactivity
- RSpec for testing
# frozen_string_literal: true | |
# https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding | |
class SmsCounter | |
MAX_SEGMENTS = 10 | |
GSM7_SINGLE_SEGMENT_LENGTH = 160 | |
GSM7_MULTI_SEGMENT_LENGTH = 153 | |
USC2_SINGLE_SEGMENT_LENGTH = 70 | |
USC2_MULTI_SEGMENT_LENGTH = 67 |
# frozen_string_literal: true | |
module I18nTaskYamlExt | |
UNMASKED_EMOJI = / | |
(?: | |
(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F) # base emoji | |
(?:\u200D(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F))* # + ZWJ parts | |
) | |
/ux |
# Benchmark performance differences between "require" and "Autoload" | |
# | |
# $ for run in {1..3}; do ZEITWERK=0 AUTOLOAD=0 ruby scripts/autoload.rb && ZEITWERK=0 AUTOLOAD=1 ruby scripts/autoload.rb; done | |
# REQUIRE 0.208000 0.360310 0.568310 ( 0.568952) | |
# AUTOLOAD 0.242265 0.374332 0.616597 ( 0.617540) | |
# REQUIRE 0.214861 0.360820 0.575681 ( 0.576603) | |
# AUTOLOAD 0.225601 0.364912 0.590513 ( 0.590673) | |
# REQUIRE 0.214296 0.359103 0.573399 ( 0.574008) | |
# AUTOLOAD 0.224972 0.359481 0.584453 ( 0.584926) | |
# $ for run in {1..3}; do ZEITWERK=1 AUTOLOAD=0 ruby scripts/autoload.rb && ZEITWERK=1 AUTOLOAD=1 ruby scripts/autoload.rb; done |
❯ OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES bin/test test/application/loading_test.rb:560 | |
Run options: --seed 3148 | |
# Running: | |
/Users/bensheldon/Repositories/rails/rails/railties/test/application/loading_test.rb:571: warning: constant Gem::Specification::NOT_FOUND is deprecated | |
/Users/bensheldon/Repositories/rails/rails/railties/test/application/loading_test.rb:571: warning: constant Gem::RubyGemsVersion is deprecated | |
/Users/bensheldon/Repositories/rails/rails/railties/test/application/loading_test.rb:571: warning: constant Gem::ConfigMap is deprecated | |
/Users/bensheldon/Repositories/rails/rails/railties/test/application/loading_test.rb:571: warning: constant Gem::List is deprecated | |
/Users/bensheldon/Repositories/rails/rails/railties/test/application/loading_test.rb:571: warning: constant Gem::SpecificGemNotFoundException is deprecated |
import { Controller } from "@hotwired/stimulus" | |
import { debounce } from "lib/utils" | |
export default class extends Controller { | |
static values = { | |
resizeDebounceDelay: { | |
type: Number, | |
default: 100, | |
} | |
} |
import {Controller} from "@hotwired/stimulus" | |
// Warns if form fields have unsaved changes before leaving the page. | |
// Changes are stored in Session Storage to restore un-warnable events | |
// like using the back button | |
// | |
// To use: | |
// <form data-controller="unsaved-changes"> | |
// <input type="text" name="name" data-unsaved-changes-target="field"> | |
export default class extends Controller { |
# frozen_string_literal: true | |
# Reduce the amount of quote churn in the YAML files that results from | |
# i18n-tasks attempting to normalize the quotes itself. | |
# Always attempt to preserve the pre-existing quote style. | |
require 'psych' | |
class I18nTasksWrapper | |
def self.i18n_files | |
locales_path = File.expand_path('./locales', File.dirname(__FILE__)) |
# frozen_string_literal: true | |
class PhoneNumber | |
EXACT_DIGITS = 10 | |
MAX_NON_DIGITS = 5 | |
delegate :present?, :blank?, :encoding, to: :@value | |
delegate :hash, to: :strict | |
def initialize(value) |
# frozen_string_literal: true | |
require "bundler/inline" | |
# Inline Gemfile for dependencies | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "benchmark-ips" | |
end |