Skip to content

Instantly share code, notes, and snippets.

View brentertz's full-sized avatar

Brent Ertz brentertz

View GitHub Profile
@brentertz
brentertz / sample-cla
Created June 9, 2017 14:25
sample-cla
This is a sample contributor's license agreemenet
@brentertz
brentertz / pr-template-bookmarklet.js
Last active August 29, 2015 14:18
PR Template Bookmarklet
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 January 6, 2013 04:00
database_cleaner alternative
config.around do |example|
ActiveRecord::Base.transaction do
example.run
raise ActiveRecord::Rollback
end
end
@brentertz
brentertz / say_formatter.rb
Last active December 10, 2015 00:19
Custom RSpec formatter that speaks aloud using the say command, if available.
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 October 13, 2015 06:58
Disallow site indexing in non-production environments
# Disallow site indexing in non-production environments
config.middleware.insert_before(::Rack::Lock, '::Rack::Robots')
@brentertz
brentertz / cream_and_sugar.rb
Created November 9, 2012 14:46 — forked from joshuaclayton/cream_and_sugar.rb
Ruby Decorators using BasicObject
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@brentertz
brentertz / emitter.js
Created October 20, 2012 16:30
Node.js: Extend a class to be an EventEmitter
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 August 10, 2012 14:44
Getting started with Node and Express
{
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
@brentertz
brentertz / gist:3176445
Created July 25, 2012 14:24
Ruby regex capture named matches as local variables.
# 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 July 11, 2012 22:45
Rack middleware to help avoid SEO duplicate content issues. Removes www and trailing slash and performs a permanent redirect.
config.middleware.insert_before(0, 'Rack::SeoRedirect')