This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Put this in your .vimrc and whenever you `git commit` you'll see the diff of your commit next to your commit message. | |
" For the most accurate diffs, use `git config --global commit.verbose true` | |
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that. | |
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff() | |
function OpenCommitMessageDiff() | |
" Save the contents of the z register | |
let old_z = getreg("z") | |
let old_z_type = getregtype("z") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You’re given two integer ranges (x1, x2) and (y1, y2). For example, the ranges (1, 10) and (5, 20). Sum the | |
# numbers that exist in both ranges. In our example, we would add up 5, 6, 7, 8, 9 and 10 (for a total of 45) since | |
# 5, 6, 7, 8, 9 and 10 exist in both ranges. | |
#The function should look like this (in Ruby): | |
def sum_of_intersection(x1, x2, y1, y2) | |
intersection = (x1..x2).to_a & (y1..y2).to_a | |
intersection.inject { |sum, i| sum + i } | |
end |