Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Light elight

  • Heroku
  • Washington, DC
View GitHub Profile
View gist:731944
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 5
THRESHOLD = 300 # In ms
def sql(event)
return unless event.duration > THRESHOLD
callers = Rails.
backtrace_cleaner.
@tenderlove
tenderlove / person_test.rb
Created Feb 10, 2011
Use minitest/spec with Rails 3
View person_test.rb
require 'test_helper'
require 'minitest/autorun'
module Tenderlove
class Spec < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
View gist.rb
## conduce - be conducive to; "The use of computers in the classroom lead to better writing"
#
# a model+view component for rails that combines the conductor and presenter
# pattern via a model capable of generating view-centric methods
#
module Conducer
# base class
#
@coreyhaines
coreyhaines / .rspec
Last active Apr 17, 2021
Active Record Spec Helper - Loading just active record
View .rspec
--colour
-I app
@ryanb
ryanb / tasks_controller_refactoring.rb
Created Nov 9, 2012
Variation of RubyTapas episode "021 Domain Model Events" without using callbacks
View tasks_controller_refactoring.rb
class TasksController < ApplicationController
def update
tracker = TaskTracker.new(@task)
if @task.update_attributes(params[:task])
TaskPusher.new(tracker, socket_id).push_changes
TaskMailSender.new(tracker, current_user).deliver_email
# success response
else
# failure respond
end
@jbgo
jbgo / debug_system_stack_error.md
Created Jan 9, 2013
debug SystemStackError in ruby 1.9
View debug_system_stack_error.md

This is how I debug SystemStackError when there is no stack trace.

My first attempt was:

begin
  a_method_that_causes_infinite_recursion_in_a_not_obvious_way
rescue SystemStackError
  puts caller
end