Skip to content

Instantly share code, notes, and snippets.

View n3bulous's full-sized avatar

Kevin McFadden n3bulous

View GitHub Profile
@pcreux
pcreux / turboframe_missing_handler.js
Created July 21, 2025 07:42
A developer friendly turboframe error handler
// Display a developer-friendly error message when Turbo Frame fails to load.
if (process.env.NODE_ENV === 'development') {
document.addEventListener('turbo:frame-missing', async function (event) {
event.preventDefault();
const frame = event.target;
const response = event.detail.response;
const frameId = frame.id;
const url = response?.url || frame.src;
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 {
---
description:
globs: spec/**/*
alwaysApply: false
---
# RSpec Testing Guidelines
## Core Principles
- Use RSpec for all tests
- Use FactoryBot for test data

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

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.

@lloydwatkin
lloydwatkin / action_mailer_job.rb
Created November 7, 2024 11:45
ActionMailer using pure Sidekiq
# i.e. Sidekiq job
class ApplicationMailerJob
include Sideiq::Worker
sidekiq_options queue: "low_priority"
def perform(mailer, action, arguments)
mailer.constantize.send(action, arguments).deliver_now
end
@DmitryTsepelev
DmitryTsepelev / 0_README.md
Last active July 23, 2025 13:58
Terminal–based game tutorial

Sources for my blog post about terminal–based game

@wndxlori
wndxlori / send_to_kindle.rb
Last active April 15, 2024 20:00
When you have a whole LOT of ebooks to send to your Kindle
#!/Usr/bin/env ruby
require 'mail'
require 'fileutils'
# Check if a command line argument is provided
if ARGV.length < 1
puts "Usage: ruby send_to-kindle.rb <directory containing epub files>"
exit 1
@AliOsm
AliOsm / .env
Last active August 18, 2025 12:55
Deploy Rails, GoodJob, PostgreSQL, Redis, Memcached, Meilisearch, and ChromaDB on the same server using Kamal.
KAMAL_REGISTRY_PASSWORD=dckr_pat_xXXxx_x0xXxXx-xX-XXX0xX0x-x
RAILS_MASTER_KEY=00x00xxx000xxx000000xx0x000x0x00
POSTGRES_PASSWORD=xXxxx0xXXx0
MEILI_MASTER_KEY=xXxxx0xXXx0
BLAZER_DATABASE_URL=postgres://service:{POSTGRES_PASSWORD}@service-name-postgres:5432/service_production