Skip to content

Instantly share code, notes, and snippets.

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

Ben Sheldon [he/him] bensheldon

🏊‍♂️
Swimming through code.
View GitHub Profile
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__))
@bensheldon
bensheldon / phone_number.rb
Created May 23, 2025 23:10
A Phone Number tiny type
# 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)

Project Guidelines

Project Overview

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
require "bundler/inline"
# Inline Gemfile for dependencies
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
# spec/support/capybara_check_choose.rb
# frozen_string_literal: true
module System
module CapybaraCheckChoose
# Speed up `allow_label_click`, which is the default, so that it
# does the label click immediately rather than waiting for the
# default strategy to fail
def _check_with_label(selector, checked, locator,
allow_label_click: session_options.automatic_label_click, **options)
class Household < ApplicationRecord
has_many :members
has_many :expenses
end
class Member < ApplicationRecord
belongs_to :household
end
class Expense < ApplicationController

My theory is that folks are hallucinating complex structure for these docs. If you read the Cursor forums, people are asking the Cursor LLM how to format them 🙃 Those shared above are the results of writing in the UI and what gets puts into version control.

My approach is that when I am annoyed by something I have to manually fix up, I go update the file.

Some of it is just impossible, like using the new Strong Params expects syntax given the training cutoffs. I’m not going to completely document the interface (cursor/rules can’t link to docs and can only link to a single file) . So I hint it, and it simply hallucinates the interface mostly correctly most of the time. Principle of Least Surprise in practice!

My .cursorrules were pretty inconsistent project to project, and I don’t believe that putting very generic things like “Use exceptions for exceptional cases, not for control flow” or “Use Active Record effectively” improves things.

# frozen_string_literal: true
# == Schema Information
#
# Table name: ai_prompt_responses
#
# id :bigint not null, primary key
# ai_model :text
# completed_at :datetime
# error_message :text