This file contains 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
" Don't allow using the arrow keys in normal mode | |
map <Left> :echo "no!"<CR> | |
map <Right> :echo "no!"<CR> | |
map <Up> :echo "no!"<CR> | |
map <Down> :echo "no!"<CR> |
This file contains 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
" Based on | |
runtime colors/ir_black.vim | |
let g:colors_name = "grb256" | |
hi pythonSpaceError ctermbg=red guibg=red | |
hi Comment ctermfg=darkgrey | |
hi TabLineFill ctermbg=15 ctermfg=234 |
This file contains 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" RUNNING TESTS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
noremap <leader>l :call RunTestFile()<cr> | |
noremap <leader>; :call RunNearestTest()<cr> | |
noremap <leader>o :call RunTests('')<cr> | |
function! RunTestFile(...) | |
if a:0 | |
let command_suffix = a:1 |
This file contains 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
# Raises a condition. If a handler is set up, it can restart the condition | |
# and return to this place. | |
# | |
# name - The Symbol name of the condition. | |
# | |
# Returns nothing if the condition was restarted, and doesn't return at all | |
# otherwise. | |
def condition(name) | |
callcc do |cont| | |
throw name, cont |
This file contains 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
require 'pattern' | |
# Returns the n'th number in the Fibonacci sequence. | |
def fib(n) | |
Pattern.match(n) do | |
on(0) { 0 } | |
on(1) { 1 } | |
on(Integer) { fib(n - 2) + fib(n - 1) } | |
end | |
end |
This file contains 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
def calculate_score(term) | |
if score can be calculated | |
Score.new(value) | |
else | |
NoScore | |
end | |
end | |
def save_score(term, score) | |
if score.available? |
This file contains 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
class Score | |
attr_reader :value | |
def initialize(value) | |
@value = value | |
end | |
def available? | |
true | |
end |
This file contains 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
class RockScore | |
def initialize(value) | |
@value = value | |
end | |
def available? | |
!@value.nil? | |
end | |
def value |
This file contains 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
# Incidentally, I wrote this as "RickScore" first. Perhaps an interesting | |
# concept? ;-) | |
score = RockScore.for_term("apple") | |
if score.available? | |
"Score: #{score.value}" | |
else | |
"Could not calculate score" | |
end |
This file contains 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
class Blog | |
attr_writer :post_maker | |
def new_post(options = {}) | |
post_maker.new(options).tap do |p| | |
p.blog = self | |
end | |
end | |
private |