Skip to content

Instantly share code, notes, and snippets.

View olegkovalenko's full-sized avatar

Oleg Kovalenko olegkovalenko

  • Evolution Gaming
View GitHub Profile

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
@olegkovalenko
olegkovalenko / .tmux.conf
Created December 8, 2015 10:48
short tmux conf
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind < resize-pane -L 1
bind > resize-pane -R 1
@olegkovalenko
olegkovalenko / parser.rb
Last active September 5, 2015 14:30
Monadic parsing in Ruby
# Based on FUNCTIONAL PEARLS: Monadic Parsing in Haskell
# by Graham Hutton
# University of Nottingham
# Erik Meijer
# University of Utrecht
#
require 'superators' # gem install superators
# parser = ->(x) { [a, l]}
def item
->(cs) {
@olegkovalenko
olegkovalenko / crontab.Doq5oJsuSd
Created May 26, 2015 14:31
contab fintess lifehack
*/30 9-17 * * 1-5 say "Stand up and walk around"
# 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
@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
@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 / 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