Skip to content

Instantly share code, notes, and snippets.

@chrismealy
chrismealy / request_debug_helpers.rb
Created July 18, 2012 23:05 — forked from henrik/request_debug_helpers.rb
show_page debug helper for RSpec request specs that opens or reloads page in Chrome.
module RequestDebugHelpers
DEBUG_URL = "http://example.dev/debug.html"
def show_page
filename = File.join(Rails.root, 'public', 'debug.html')
File.open(filename, 'w') do |f|
f.puts page.body.gsub("</title>", " (#{ current_path })\\0")
end
system "osascript", "-e", <<-OSASCRIPT
@chrismealy
chrismealy / Gemfile
Created September 13, 2012 19:54
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@chrismealy
chrismealy / gist:29540dfc1dfd62cc7e08846b836e1aad
Created January 17, 2017 06:13 — forked from jordan-brough/gist:1926410
ruby count_by using group_by
# See http://jordan.broughs.net/archives/2012/07/enumerablecount_by-for-ruby
# Ruby >= 1.8.7 (incl 1.9.x)
module Enumerable
def count_by(&block)
Hash[group_by(&block).map { |key,vals| [key, vals.size] }]
end
end
@chrismealy
chrismealy / how-to-squash-commits-in-git.md
Created November 3, 2017 18:09 — forked from patik/how-to-squash-commits-in-git.md
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date: