Skip to content

Instantly share code, notes, and snippets.

View mattbrictson's full-sized avatar

Matt Brictson mattbrictson

View GitHub Profile
@mattbrictson
mattbrictson / Gemfile
Last active April 17, 2024 04:23
Ruby and JS dependencies that power mattbrictson.com
source "https://rubygems.org"
ruby file: ".ruby-version"
gem "bootsnap", require: false
gem "faraday"
gem "faulty"
gem "puma", "~> 6.0"
gem "rack-canonical-host"
gem "rails", "~> 7.1.0"
@mattbrictson
mattbrictson / application.html.erb
Last active August 16, 2023 15:33
Simpler nested layouts in Rails using the parent_layout helper
<%= render("shared/navbar") %>
<div class="container">
<%= render("shared/alerts") %>
<%= render("shared/page_header") %>
<%= yield %>
<%= render("shared/footer") %>
@mattbrictson
mattbrictson / Gemfile
Created September 11, 2015 15:55
Using vcr with Minitest + Rails (test unit style)
group :test do
gem "minitest"
gem "vcr"
gem "webmock", "~> 1.15.0"
end
@mattbrictson
mattbrictson / 01-headers
Created October 29, 2011 00:08
How to Defeat the Browser Back Button Cache
Cache-Control: no-cache, max-age=0, must-revalidate, no-store
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@mattbrictson
mattbrictson / 01-first_cut.html
Last active June 17, 2018 23:04
How to Implement Radio Buttons in Wicket
<input type="radio" name="ticker" value="AAPL"/>Apple<br/>
<input type="radio" name="ticker" value="GOOG"/>Google<br/>
<input type="radio" name="ticker" value="MSFT"/>Microsoft<br/>
@mattbrictson
mattbrictson / Gemfile
Created August 21, 2011 17:53
Configuring rails 3.1 and dragonfly to use Herkou and Amazon CloudFront
gem 'dragonfly', '~>0.9.4'
group :production do
gem 'fog' # for Amazon S3
end
~$ which ruby
/Users/mbrictson/.rbenv/shims/ruby
~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
- INSTALLATION DIRECTORY: /Users/mbrictson/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /Users/mbrictson/.rbenv/versions/2.0.0-p247/bin/ruby
- EXECUTABLE DIRECTORY: /Users/mbrictson/.rbenv/versions/2.0.0-p247/bin
- RUBYGEMS PLATFORMS:
@mattbrictson
mattbrictson / .bashrc
Last active October 26, 2015 07:28
"r" shortcut in bash for "rails" and "rake"
# Shortcut for `bundle exec rails` and `bundle exec rake`.
# If bin/rails and bin/rake are available, use them instead as they are much
# faster to execute than `bundle exec`.
function r() {
if [[ "g|generate|c|console|s|server|db|dbconsole|r|runner|new" =~ $1 ]]; then
if [ -x bin/rails ]; then
bin/rails "$@"
elif [ -x script/rails ]; then
script/rails "$@"
else
@mattbrictson
mattbrictson / Gemfile
Created May 18, 2012 23:06
Faster Capybara Specs
gem 'database_cleaner', group: :test