Skip to content

Instantly share code, notes, and snippets.

class Numeric # converts numbers into letters
Alph = ("A".."Z").to_a
def alph
s, q = "", self
(q, r = (q - 1).divmod(26)) && s.prepend(Alph[r]) until q.zero?
s
end
end
grid = Hash[("A".."Z").to_a.zip(1..27).to_a] # creates a hash where keys are letters, values are numbers.
def to_numbers
map {|i| grid.fetch(i)} #converts array of letters to numbers, using grid hash.
end
def to_letters
sum.map {|i| grid.key(i)} #convers array of numbers into letters, using grid hash.
end
@alekst
alekst / heroku
Last active August 29, 2015 13:56
$ heroku -v
dyld: lazy symbol binding failed: Symbol not found: _ruby_run
Referenced from: /usr/local/bin/ruby
Expected in: /usr/lib/libruby.dylib
dyld: Symbol not found: _ruby_run
Referenced from: /usr/local/bin/ruby
Expected in: /usr/lib/libruby.dylib
Trace/BPT trap: 5
@alekst
alekst / gist:11255016
Last active August 29, 2015 14:00
test verbose's truthiness
# vim:fileencoding=utf-8
require_relative 'test_helper'
context 'Resque::Scheduler::Configuration' do
test 'verbose should be false' do
assert_kind_of(FalseClass, Resque::Scheduler.verbose)
end
end