Skip to content

Instantly share code, notes, and snippets.

View olegkovalenko's full-sized avatar

Oleg Kovalenko olegkovalenko

  • Evolution Gaming
View GitHub Profile
@olegkovalenko
olegkovalenko / delegate_matcher.rb
Created August 8, 2011 14:16 — forked from txus/delegate_matcher.rb
RSpec matcher for delegations for mocka
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end
@olegkovalenko
olegkovalenko / Evolution of a Ruby Programmer.rb
Created November 30, 2011 11:34 — forked from hemanth/Evolution of a Ruby Programmer.rb
Evolution of a Ruby Programmer.rb
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@olegkovalenko
olegkovalenko / Gemfile
Created April 17, 2012 13:35
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
# Ruby has #source_location method that returns code location where a method was declared.
# What Ruby lacks is alike functionality that could show where an object was created.
# Below is a very rough solution that may help with tracing object allocations
# by storing the first entry in the caller list during object initialization phase.
# It doesn't work for built-in classes like Fixnum and for classes that don't invoke #initialize()
# like the ones derived from ActiveRecord::Base, but can be potentially tailored to address
# at least the latter case by overriding ActiveRecord::Base.new in addition to overriding #initialize()
class BasicObject
attr_reader :allocated_at

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x