Skip to content

Instantly share code, notes, and snippets.

Avatar

Brent Ertz brentertz

  • Broadcom, Inc.
  • Boulder, CO
View GitHub Profile
View sample-cla
This is a sample contributor's license agreemenet
@brentertz
brentertz / pr-template-bookmarklet.js
Last active Aug 29, 2015
PR Template Bookmarklet
View pr-template-bookmarklet.js
javascript:(function() {
var e = document.getElementById('pull_request_body');
if (e) {
if (e.value) {
e.value += '\n\n';
}
e.value += '
#### What does this PR do?\n\n
#### Any background context you want to provide?\n\n
#### Where should the reviewer start?\n\n
@brentertz
brentertz / spec_helper.rb
Created Jan 6, 2013
database_cleaner alternative
View spec_helper.rb
config.around do |example|
ActiveRecord::Base.transaction do
example.run
raise ActiveRecord::Rollback
end
end
@brentertz
brentertz / say_formatter.rb
Last active Dec 10, 2015
Custom RSpec formatter that speaks aloud using the say command, if available.
View say_formatter.rb
require 'rspec/core/formatters/progress_formatter'
# Custom RSpec formatter that speaks aloud using the say command, if available.
# Not to be taken too seriously, but fun for annoying your coworkers.
# Usage: bundle exec rspec -r ./say_formatter.rb -f SayFormatter spec
class SayFormatter < RSpec::Core::Formatters::ProgressFormatter
VOICES = %w[Agnes Albert Alex Bad\ News Bahh Bells Boing Bruce Bubbles Cellos
Deranged Fred Good\ News Hysterical Junior Kathy Pipe\ Organ
Princess Ralph Trinoids Vicki Victoria Whisper Zarvox]
@brentertz
brentertz / application.rb
Last active Oct 13, 2015
Disallow site indexing in non-production environments
View application.rb
# Disallow site indexing in non-production environments
config.middleware.insert_before(::Rack::Lock, '::Rack::Robots')
@brentertz
brentertz / cream_and_sugar.rb
Created Nov 9, 2012 — forked from joshuaclayton/cream_and_sugar.rb
Ruby Decorators using BasicObject
View cream_and_sugar.rb
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@brentertz
brentertz / emitter.js
Created Oct 20, 2012
Node.js: Extend a class to be an EventEmitter
View emitter.js
var util = require('util'),
EventEmitter = require('events').EventEmitter;
var Server = function() {
var self = this;
this.on('custom_event', function() {
self.logSomething('custom_event');
});
@brentertz
brentertz / engines
Created Aug 10, 2012
Getting started with Node and Express
View engines
{
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
@brentertz
brentertz / gist:3176445
Created Jul 25, 2012
Ruby regex capture named matches as local variables.
View gist:3176445
# You can name your captured matches and ruby will create local variables for you automatically.
# The regex is on Rubular at http://rubular.com/r/HJbhamKAib
$ irb
1.9.3p0 :001 > s = "Foo Bar Bas <foo@bar.com>"
"Foo Bar Bas <foo@bar.com>"
1.9.3p0 :002 > /(?<label>.*) <(?<email>[^>]*)/ =~ s
0
@brentertz
brentertz / rails
Created Jul 11, 2012
Rack middleware to help avoid SEO duplicate content issues. Removes www and trailing slash and performs a permanent redirect.
View rails
config.middleware.insert_before(0, 'Rack::SeoRedirect')