Skip to content

Instantly share code, notes, and snippets.

View n3bulous's full-sized avatar

Kevin McFadden n3bulous

View GitHub Profile
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 April 19, 2025 06:19
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 May 22, 2025 06:45
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
@jjb
jjb / file.md
Last active July 1, 2025 18:47
Using Jemalloc 5 with Ruby.md

For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.

Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.

Ubuntu/Debian

FROM ruby:3.1.2-bullseye
RUN apt-get update ; \