Skip to content

Instantly share code, notes, and snippets.

@alvinsng
alvinsng / no-use-effect.md
Created March 17, 2026 20:00
Skill generated by Factory Droid
name description
no-use-effect
Enforce the no-useEffect rule when writing or reviewing React code. ACTIVATE when writing React components, refactoring existing useEffect calls, reviewing PRs with useEffect, or when an agent adds useEffect "just in case." Provides the five replacement patterns and the useMountEffect escape hatch.

No useEffect

# in config/environment.rb
if ENV['SPRING_ENV'] == 'test' && ENV['RAILS_ENV'] == 'test'
require File.expand_path('../../spec/spec_helper', __FILE__)
end
# in spec_helper.rb
# runs in Spring parent
unless MySpecHelper.factory_sequences
DatabaseCleaner.clean_with(:truncation)
RESEED_DB.call
MySpecHelper.factory_sequences = FactoryGirl.sequences
# In spec/factories/account.rb
FactoryBot.define do
sequence(:email) { |n| "test_email_#{n}@example.com" }
end
# In Spring parent
def seed_db
100.times { create(:account) }
end
seed_db # creates 100 accounts with sequences 1 to 100
MySpecHelper.factory_sequences = FactoryGirl.sequences
# In spec/factories/account.rb
FactoryBot.define do
sequence(:email) { |n| "test_email_#{n}@example.com" }
end
# In Spring parent
def seed_db
100.times { create(:account) }
end
seed_db # creates 100 accounts with sequences 1 to 100
# In Spring fork's spec run
@alvinsng
alvinsng / opendoor_rspec_database_cleaner.rb
Created May 2, 2018 23:10
opendoor_rspec_database_cleaner.rb
# in spec_helper.rb
RSpec.configure do |config|
# other spec configs here
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
end
# in config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
# If in Spring & test env, load spec_helper.rb
if ENV['SPRING_ENV'] == 'test' && ENV['RAILS_ENV'] == 'test'
require File.expand_path('../../spec/spec_helper', __FILE__)
end
RESEED_DB = -> do
DbSeedsHelper.create_default_customer_data_types
DbSeedsHelper.create_markets
DbSeedsHelper.create_organizations
DbSeedsHelper.create_owner_entities
DbSeedsHelper.create_system_human
DbSeedsHelper.create_seller_flows
DbSeedsHelper.create_title_orgs
end
@alvinsng
alvinsng / gist:c63043ee8393b510fee3
Created March 21, 2015 23:27
AltManagerContainer.js
var React = require('react');
module.exports = React.createClass({
displayName: 'AltManagerContainer',
propTypes: {
Action: React.PropTypes.function.isRequired,
Store: React.PropTypes.function.isRequired,
alt: React.PropTypes.object.isRequired,