Skip to content

Instantly share code, notes, and snippets.

View almostwhitehat's full-sized avatar
💭
Matt Metzger is typing

Matt Metzger almostwhitehat

💭
Matt Metzger is typing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am almostwhitehat on github.
  • I am almostwhitehat (https://keybase.io/almostwhitehat) on keybase.
  • I have a public key whose fingerprint is 82E7 6B8D 4751 19C0 C1E1 942F 85FA A1AF BC14 E33D

To claim this, I am signing this object:

@almostwhitehat
almostwhitehat / view_finder.rb
Created January 27, 2017 05:57
Add HTML comments to rendered templates and views to discover where content is coming from
# Drop this in as a rails initializer and resstart rails
# View the source of pages - you'll see which template and views are used when rendering pages
module ActionView
class TemplateRenderer
alias_method :original_render, :render
def render(context, options)
rendered_content = original_render(context, options)
# Random string makes it easier to jump between matching start / stop when viewing source of the page
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
require 'benchmark/ips'
ARRAY = [*1..100]
def slow
ARRAY.select { |x| x.eql?(50) }.last
end
def fast
ARRAY.reverse.detect { |x| x.eql?(50) }
require 'benchmark/ips'
ARRAY = [*1..100]
def slow
ARRAY.select { |x| x.eql?(80) }.last
end
def fast
ARRAY.reverse.detect { |x| x.eql?(80) }
Before do |scenario|
tagged_as_a_bug = scenario.source_tag_names.any? { |tag| tag.start_with? '@Bug-' }
if tagged_as_a_bug
STDOUT.puts 'Skipped - Bug'
scenario.skip_invoke!
end
end
Pry.editor = proc { |file, line| "rubymine #{file} --line #{line} #{file}" }
Pry::Commands.create_command "rm" do
description "Launches rubymine at the current point"
def process
run 'edit --current'
end
end