Skip to content

Instantly share code, notes, and snippets.

@psstoev
psstoev / sample_spec2.1.rb
Created October 26, 2011 17:05
Ruby homework2 additional tests
describe Collection do
let(:additional_tags) do
{
'John Coltrane' => %w[saxophone],
'Bach' => %w[piano polyphony],
}
end
let(:input) do
<<-END
@psstoev
psstoev / sample_spec.rb
Created December 16, 2011 03:03
Sample spec for task 6
# encoding: utf-8
describe GameOfLife::Board do
describe 'initialization' do
it 'accepts multiple coords in the constructor' do
board = new_board [0, 0], [1, 1], [2, 2]
end
end
describe 'corner cases' do
@psstoev
psstoev / Robert_Heinlein
Created January 9, 2012 17:42
Robert Heinlein
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
-- Robert Heinlein
@psstoev
psstoev / count-change.txt
Created March 21, 2012 22:44
Count-change
T(0, n) = 1
⎧ 0, m < 0 или n = 0
T(m, n) = ⎨
⎩ T(m, n - 1) + T(m - Cₙ, n), Cₙ - номиналът на n-тата монета, някаква константа
@psstoev
psstoev / emacs-scheme-after-save-hook.el
Created April 2, 2012 22:51
Custom mode-hook for Emacs, to run Scheme "unit tests".
;; Add this to your .emacs, the function supposes, that you have a
;; subdirectory "tests", where there is a file with the same name as
;; the file you are editing. Not very interesting, but convinient.
(add-hook 'scheme-mode-hook
(lambda ()
(add-hook 'after-save-hook
(lambda ()
(let ((file-name (file-name-nondirectory buffer-file-name)))
(if (file-exists-p (concat "tests/" file-name))
@psstoev
psstoev / gist:7531555
Created November 18, 2013 17:14
Memoize solutions
# Solution 1:
class Memoizer < BasicObject
def initialize(instance)
@instance = instance
@cache = {}
end
def cache(method, *args)
@cache["#{method}, #{args}"] = @instance.public_send method, *args