Skip to content

Instantly share code, notes, and snippets.

View spickermann's full-sized avatar
💻
18 years of experience with Ruby on Rails

Martin Spickermann spickermann

💻
18 years of experience with Ruby on Rails
View GitHub Profile
@skatkov
skatkov / forever.sh
Created November 28, 2023 10:48
run tests forever (until they fail)
while bundle exec rake test; do :; done
@fatkodima
fatkodima / inspect_queries.rb
Created January 17, 2024 00:35
Inspect db queries
# Make sure to have prepared statements enabled.
# config/database.yml
# test:
# database: ...
# prepared_statements: true
# Add this to the top scope of test/test_helper.rb or spec/rails_helper.rb and
# run tests as usual.
queries = Hash.new(0)
# Here's the problem statement we worked on:
# 1. Spam post detection: Run a forum post through a series of configurable checks to give it a spam score,
# and flag the post when it crosses the threshold, with details on what led to the score.
# We had a Gemfile with `gem "rails"` and `gem "sqlite3"` in it, but that was it.
require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")