Skip to content

Instantly share code, notes, and snippets.

View jeremysmithco's full-sized avatar

Jeremy Smith jeremysmithco

View GitHub Profile
@jeremysmithco
jeremysmithco / scripts.sh
Created February 1, 2026 01:55
Conductor Setup for Rails App 2026-01-31
#======================
# Setup
#======================
docker compose -f $CONDUCTOR_ROOT_PATH/docker-compose.yml up -d
sed -e "s/^DATABASE_PREFIX=$/DATABASE_PREFIX=${CONDUCTOR_WORKSPACE_NAME}-/" \
"$CONDUCTOR_ROOT_PATH/.env.development" > .env.development
sed -e "s/^DATABASE_PREFIX=$/DATABASE_PREFIX=${CONDUCTOR_WORKSPACE_NAME}-/" \
"$CONDUCTOR_ROOT_PATH/.env.test" > .env.test
@jeremysmithco
jeremysmithco / cfp.html.erb
Last active January 31, 2026 23:50
Blue Ridge Ruby CFP Stimulus Countdown Timer
<div data-controller="simple-countdown" data-simple-countdown-deadline-value="2026-02-03T00:00:00Z" class="leading-relaxed text-center text-[#2672B5] mb-12">
<div class="flex justify-center items-start gap-1 sm:gap-2 font-mono font-bold">
<div class="flex flex-col items-center">
<span class="text-[#2672B5] text-sm sm:text-base mb-2 uppercase tracking-wider">Days</span>
<div class="flex gap-1">
<span data-simple-countdown-target="days" class="bg-[#1a1a1a] text-white text-3xl sm:text-5xl rounded px-2 sm:px-3 py-2 sm:py-4 tracking-wider">00</span>
</div>
</div>
<span class="text-[#1a1a1a] text-3xl sm:text-5xl mt-8 sm:mt-10">:</span>
<div class="flex flex-col items-center">
module SolidFlow
class WorkflowJob < ActiveJob::Base
delegate :run, :in_parallel, to: :workflow
queue_as :default
def perform(*args)
build(*args)
StepExecutor.new(workflow.serialized, 0, batch).execute
@jeremysmithco
jeremysmithco / highlightable_controller.js
Created February 18, 2025 20:06
Stimulus.js RangeError Issue
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static values = { highlighted: Boolean };
static classes = ["highlighted"];
toggle() {
this.highlightedValue = !this.highlightedValue;
}
@jeremysmithco
jeremysmithco / stimulus_data.rb
Last active November 28, 2024 07:30
stimulus_data helper
# Example Usage
# data: stimulus_data(
# autosubmit: { controller: true },
# toggle: { controller: true, classes: { checked: "highlighted", unchecked: "unhighlighted" } },
# sortable: { target: "sortBy", actions: { click: "sort" },
# ).merge(other: "stuff")
class StimulusData
def initialize(**controllers)
@controllers = controllers
@jeremysmithco
jeremysmithco / payments_controller.rb
Created November 6, 2024 21:49
Stripe Checkout PaymentsController
class PaymentsController < ApplicationController
CHECKOUT_SESSION_ID_KEY = :checkout_session_id
before_action :authenticate_user!
def new
stripe_customer = find_or_create_stripe_customer
checkout_session = create_checkout_session(stripe_customer)
redirect_to checkout_session.url, allow_other_host: true
@jeremysmithco
jeremysmithco / _form.html.erb
Created October 24, 2024 13:44
Stimulus autosuggest with @github/combobox-nav
<%= tag.div data: { controller: "autosuggest", action: "autosuggest:click:outside->autosuggest#hide" }, class: "relative" do %>
<%= f.text_field :subject, autocomplete: "off", data: { autosuggest_target: "input", action: "input->autosuggest#search focus->autosuggest#search keydown.up->autosuggest#arrowSearch keydown.down->autosuggest#arrowSearch keydown.esc->autosuggest#hide" } %>
<%= tag.ul role: "listbox", hidden: true, data: { autosuggest_target: "list", action: "combobox-commit->autosuggest#commit" }, class: "z-40 absolute w-full max-h-60 overflow-auto mt-1 rounded border border-gray-300 shadow-lg p-1 bg-white" do %>
<% @subjects.each do |subject| %>
<%= tag.li subject.name, role: "option", id: dom_id(subject, :listbox), data: { autosuggest_target: "item" }, class: "w-full text-left cursor-pointer p-2 hover:bg-gray-100 aria-selected:bg-gray-100 aria-selected:font-semibold" %>
<% end %>
<% end %>
<% end %>
@jeremysmithco
jeremysmithco / _form.html.erb
Created October 16, 2024 17:28
Stimulus @github/session-resume
<%= form_with(model: topic_form, url: spaced_topics_path) do |form| %>
<div class="mb-4">
<%= form.label :title %>
<%= form.text_field :title, data: { session_resume_target: "resumeable" } %>
<%= form.error :title %>
</div>
<div class="mb-2">
<%= form.label :body, class: "sr-only" %>
<%= form.markdown_text_area :body, data: { session_resume_target: "resumeable" } %>
@jeremysmithco
jeremysmithco / riff1.rb
Created September 9, 2024 18:33
Riffing on Topic Subscriptions
class User
has_many :subscriptions
has_many :followings
end
class Channel
has_many :topics
has_many :subscriptions
end
@jeremysmithco
jeremysmithco / active_storage.rb
Last active August 8, 2024 21:01
Rough sketch of Active Storage calculated variants
Rails.application.config.to_prepare do
ActiveStorage::Attachment.class_eval do
private
def transform_variants_later
if record.respond_to?(:calculated_variants)
record.calculated_variants[name.to_sym]&.values.each do |transformations|
blob.preprocessed(transformations)
end
end