z, ? | toggle help (this) |
space, → | next slide |
shift-space, ← | previous slide |
d | toggle debug mode |
## <ret> | go to slide # |
c, t | table of contents (vi) |
f | toggle footer |
g | toggle follow |
r | reload slides |
n | toggle notes |
p | run preshow |
P | toggle pause |
s | choose style |
Date date = new java.util.Date(2014, 3, 16);
Date date = new java.util.Date(2014, 3, 16);
// April 16th
Date date = new java.util.Date(2014, 3, 16);
// April 16th, 3914
Date date = new java.util.Date(2014, 3, 16);
// April 16th, 3914
// days start from 1
// months start from 0
// years start from 1,900
wroclove = Date.new 2014, 3, 16
wroclove = Date.new 2014, 3, 16
#=> March 16th, 2014
# days start from 1
# months start from 1
# years start from 1
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
eurucamp - wroclove
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
eurucamp - wroclove
#=> 138 days
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
eurucamp - wroclove
#=> 138 days
wroclove..eurucamp
#=> Range of Dates
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
case Date.today
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
case Date.today
when Date.new...wroclove then :before
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
case Date.today
when Date.new...wroclove then :before
when wroclove...eurucamp then :between
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
case Date.today
when Date.new...wroclove then :before
when wroclove...eurucamp then :between
when eurucamp..Date::Infinity then :after
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
case Date.today
when Date.new...wroclove then :before
when wroclove...eurucamp then :between
when eurucamp..Date::Infinity then :after
end
#=> :between
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).all?(&:friday?)
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).all?(&:friday?)
#=> false :(
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).count(&:friday?)
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).count(&:friday?)
#=> 20 \o/
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).select(&:friday?)
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).select(&:friday?)
#=> March 21st, March 28th, April 4th…
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).each_cons(2) do |lower, upper|
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).each_cons(2) do |lower, upper|
puts "#{lower} - #{upper}"
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).each_cons(2) do |lower, upper|
puts "#{lower} - #{upper}"
end
# 2014-03-16 - 2014-03-17
# 2014-03-17 - 2014-03-18
# 2014-03-18 - 2014-03-19
# …
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).partition do |date|
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).partition do |date|
date.saturday? or date.sunday?
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
weekend, weekday = (wroclove..eurucamp).partition do |date|
date.saturday? or date.sunday?
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
weekend, weekday = (wroclove..eurucamp).partition do |date|
date.saturday? or date.sunday?
end
weekend
#=> March 16th, March 22nd, March 23rd…
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
weekend, weekday = (wroclove..eurucamp).partition do |date|
date.saturday? or date.sunday?
end
weekend
#=> March 16th, March 22nd, March 23rd…
weekday
#=> the rest :(
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).slice_before(&:monday?)
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).slice_before(&:monday?).each do |week|
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).slice_before(&:monday?).each do |week|
puts "#{week.first} – #{week.last}"
end
wroclove = Date.new 2014, 3, 16
eurucamp = Date.new 2014, 8, 1
(wroclove..eurucamp).slice_before(&:monday?).each do |week|
puts "#{week.first} – #{week.last}"
end
# 2014-03-16 – 2014-03-16 ← last day of this week
# 2014-03-17 – 2014-03-23
# 2014-03-24 – 2014-03-30
# …
class Date
def free?
saturday? or sunday?
end
end
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
(wroclove..eurucamp).chunk(&:free?).each do |free, dates|
end
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
(wroclove..eurucamp).chunk(&:free?).each do |free, dates|
puts dates.map { plans.(free) }.join ' '
end
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
(wroclove..eurucamp).chunk(&:free?).each do |free, dates|
puts dates.map { plans.(free) }.join ' '
end
# ⚛
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
(wroclove..eurucamp).chunk(&:free?).each do |free, dates|
puts dates.map { plans.(free) }.join ' '
end
# ⚛
# ⚒ ⚒ ⚒ ⚒ ⚒
fun = %w(⚓ ⚛ ♥ ♫ ⚘ ✍ ✂ ⚔)
plans = -> free { free ? fun.sample : '⚒' }
(wroclove..eurucamp).chunk(&:free?).each do |free, dates|
puts dates.map { plans.(free) }.join ' '
end
# ⚛
# ⚒ ⚒ ⚒ ⚒ ⚒
# ⚘ ⚔
# ⚒ ⚒ ⚒ ⚒ ⚒
# ♫ ⚓
# ⚒ ⚒ ⚒ ⚒ ⚒
# ✂ ♥
# …
Two easy steps to quickly get
better
at programming Ruby:
1) read about enumerable.rb
2) read it again.
— Florian Gilcher