Skip to content

Instantly share code, notes, and snippets.

View dasch's full-sized avatar
💭
LOOKING INTENTLY INTO THE VOID

Daniel Schierbeck dasch

💭
LOOKING INTENTLY INTO THE VOID
View GitHub Profile
def calculate_score(term)
if score can be calculated
Score.new(value)
else
NoScore
end
end
def save_score(term, score)
if score.available?
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
# 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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
" 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
@dasch
dasch / no.vim
Created September 26, 2012 12:19
" 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>
@dasch
dasch / curly_doc.rb
Last active December 18, 2015 00:08
Formatting Curly methods.
module CurlyDoc
def self.documentation_for_method(method)
pretty_name = CurlyInfo.curly_name(method)
description = I18n.translate(method.name, namespace: "curly.methods")
"%s - %s" % [pretty_name, description]
end
end

Keybase proof

I hereby claim:

  • I am dasch on github.
  • I am dasch (https://keybase.io/dasch) on keybase.
  • I have a public key whose fingerprint is EF11 DF25 B02F 0136 DF44 6EA9 CED4 AD42 717D 5ECC

To claim this, I am signing this object:

@dasch
dasch / git-pr
Created December 18, 2014 10:27
Open the GitHub compare page for a branch
#!/bin/bash
local_branch=$(git for-each-ref --format="%(refname:short)" $(git symbolic-ref HEAD))
remote_name=$(git config branch.$local_branch.remote)
remote_refspec=$(git config branch.$local_branch.merge)
remote_branch=${remote_refspec#refs/heads/}
remote_git_url=$(git config remote.origin.url)
remote_http_url=${remote_git_url#[email protected]:}
remote_http_url=${remote_http_url%.git}
github_url="https://github.com/$remote_http_url"
clicks : Signal (Int, Int)