Skip to content

Instantly share code, notes, and snippets.

View ashanbrown's full-sized avatar
🔌
plugged in

Andrew Shannon Brown ashanbrown

🔌
plugged in
View GitHub Profile
from __future__ import print_function
import contextlib
import pytest
# Introduce a Loud integer class that has some annoying properties that force us into a bunch of
# set up in our tests (in this case, to prevent unnecessary output to stdout during test)
class LoudInt(int):
@ashanbrown
ashanbrown / gist:c336923ee94609528095
Created January 24, 2015 18:37
accepts_nested_attributes_for breaks automatic inverse_of
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@ashanbrown
ashanbrown / new_relic.rb
Created December 5, 2014 21:11
initializer monkey patch to get new_relic explains to show up when using octopus
if defined?(NewRelic::Agent::Instrumentation::ActiveRecordSubscriber)
module NewRelic
module Agent
module Instrumentation
class ActiveRecordSubscriber
def active_record_config_for_event_with_octopus(event)
return unless event.payload[:connection_id]
config = active_record_config_for_event_without_octopus(event)
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'sqlite3'
GEMFILE
@ashanbrown
ashanbrown / jquery.ajax.queue.coffee
Last active August 29, 2015 14:02 — forked from maccman/jquery.ajax.queue.coffee
queued ajax requests with a queueMaxConcurrency option that can be set on each request
$ = jQuery
queues = {}
queue = (name) ->
name = 'default' if name is true
queues[name] or= {entries: [], running: 0}
next = (name, done) ->
list = queue(name)
@ashanbrown
ashanbrown / polymorphic_inverse_test.rb
Last active August 29, 2015 14:01
test case for polymorphic inverse_of
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end