Skip to content

Instantly share code, notes, and snippets.

View bensheldon's full-sized avatar
🏊‍♂️
Swimming through code.

Ben Sheldon bensheldon

🏊‍♂️
Swimming through code.
View GitHub Profile
# 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
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
end
<% require_relative File.expand_path("git_worktree", __dir__) %>
default: &default
adapter: postgresql
encoding: unicode
pool: 20
connect_timeout: 5
checkout_timeout: 5
development:
const origDefine = customElements.define;
customElements.define = function(name, ctor, options) {
if (name !== 'turbo-cable-stream-source') return origDefine.call(this, name, ctor, options);
const proto = ctor.prototype;
const origDisconnectedCallback = proto.disconnectedCallback;
const origConnectedCallback = proto.connectedCallback;
proto.connectedCallback = async function() {
if (this.disconnecting) {
# frozen_string_literal: true
module TurboPermanentCableHelper
def turbo_permanent_stream_from(*streamables, **attributes)
raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
raise ArgumentError, "an id is required" if attributes[:id].blank?
attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
attributes[:'signed-stream-name'] = Turbo::StreamsChannel.signed_stream_name(streamables)
attributes[:data] ||= {}
attributes[:data][:turbo_permanent] = true
# frozen_string_literal: true
# config/initializers/view_component.rb
#
# Instantiate a ViewComponents that is (optionally) serializable by Active Job
# but otherwise behaves like a normal ViewComponent. This allows it to be passed
# as a renderable into `broadcast_action_later_to`.
#
# To use, include the `ViewComponent::Serializable` concern:
#
# class ApplicationComponent < ViewComponent::Base
class BaseController < ApplicationController
include Flowable
self.form_flow = [
"AppliesController",
# Initial "can we help you" questions
"Apply::LocationsController",
"Apply::RecentlyAppliedsController",
"Apply::LanguagesController",
<% require_relative File.expand_path("git_worktree", __dir__) %>
default: &default
adapter: postgresql
encoding: unicode
pool: 20
connect_timeout: 5
checkout_timeout: 5
development:
# 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
@bensheldon
bensheldon / i18n-tasks-normalize.rb
Last active July 28, 2025 22:56
Normalize the YAML output of i18n-tasks so that strings are always doublequoted, or strings with newlines use YAML Literations (e.g. `key: |` style)
# 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