Skip to content

Instantly share code, notes, and snippets.

View anthonycrumley's full-sized avatar

Anthony Crumley anthonycrumley

View GitHub Profile
execute pathogen#infect()
syntax on
filetype plugin indent on
augroup vimrc
set hlsearch
set tabstop=2
set shiftwidth=2
set expandtab
set ruler
// We are doing something like this in several places
$("#student_id").bind("keypress", function(e){
if (e.keyCode == 13){
jQuery("#student_submit").parent().parent('form')[0].submit();
return false;
}
});
// The following are a couple of approaches to encapsulate this.
function parse_git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
}
function parse_git_modified {
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
}
function parse_git_dirty {
execute pathogen#infect()
syntax on
filetype plugin indent on
augroup vimrc
set hlsearch
set tabstop=2
set shiftwidth=2
set expandtab
developers = %w{ arongray tmiller acsellers pho3nixf1re jzw benolee }
pairs = developers.sort.combination(2).to_a
sprint_assignments_without_double_duty = pairs.
combination(developers.length / 2).
to_a.
select{|assignments| assignments.flatten.uniq.length == developers.length}
sprint_assignments_with_unique_pairs =
require 'haml'
def line_counter(node)
script_filters = %w{ javascript erb plain }
if node.type == :filter && script_filters.include?(node.value[:name])
lines_from_this_node = node.value[:text].split("\n").length
else
lines_from_this_node = 0
end
require 'haml'
def line_counter(node)
decendants = node.children.map{|n| line_counter(n)}
if node.type == :filter && %w{ javascript erb plain }.include?(node.value[:name])
me = node.value[:text].split("\n").length
else
me = 0
end
sum(decendants) + me
require File.dirname(__FILE__) + '/../test_helper'
class RangeTest < ActiveSupport::TestCase
test "Range#coinsides_with?" do
range_1 = Time.zone.now..Time.zone.now
range_2 = range_1
assert (range_1).coinsides_with?(range_2), <<-MESSAGE
Ranges should coincide but don't!
1 |
2 |
require File.dirname(__FILE__) + '/../test_helper'
class RangeTest < Test::Unit::TestCase
test <<-TEST do
Range#coinsides_with?
|
|
TEST
range = Time.zone.now..Time.zone.now
@anthonycrumley
anthonycrumley / have_sent_email.rb
Created July 18, 2013 14:27
Issues with Shoulda and domain model unit tests.
require 'test_helper'
class GF::Appointments::FooTest < ActiveSupport::TestCase
# In non-ActiveRecord classes that use Shoulda a subject must be
# defined to use the should dsl method. Otherwise it will try to
# instantiate a class based on the class name of the test, in this
# case it tries to instantiate GF::Appointments::Foo. This instantiation
# fails if the initializer has required parameters and may have other
# undesirable side effects.
subject { Object.new }