Skip to content

Instantly share code, notes, and snippets.

View Jacke's full-sized avatar
👀
Mastermind

Stan Sobolev Jacke

👀
Mastermind
View GitHub Profile
@Jacke
Jacke / dsl.rb
Last active December 19, 2015 09:09
DSL Yield(self)
class Admin
def admin(&block)
@admin ||= Admin.new(&block)
end
class << self
attr_accessor :name, :environment # class attributes
def new
unless @instance # Singleton-pattern only one instance
yield(self) # Yielding self, so self is Admin
end
@Jacke
Jacke / proc_to_block.rb
Created July 7, 2013 22:39
Proc to block convertation
def m1 &block
m2 &block
end
def m2
yield
end
m1 {puts "hello"} # hello
@Jacke
Jacke / closure.rb
Created July 7, 2013 22:45
Block as closure
def method_with_block_as_closure(&block)
another_method block
end
def another_method(variable)
m2 &variable
end
def m2
x=25
yield x
@Jacke
Jacke / how.rb
Last active December 19, 2015 11:09
Magic with &:symbol and &block
class Translator
def speak &language # Proc.new { |obj| obj.send(:method) }
language.call(self) # self make obj so it convert to self.send(:method)
# Proc.new { |obj| obj.send(method) } .call(self)
end
protected
def french
'bon jour'
module Excel
module Formulas
def pmt(rate, nper, pv, fv=0, type=0)
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper)))
end
def ipmt(rate, per, nper, pv, fv=0, type=0)
p = pmt(rate, nper, pv, fv, 0);
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1))
(type == 0) ? ip : ip / (1 + rate)
# Clone rbenv into ~/.rbenv
git clone git@github.com:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL
Список изученного:
Ruby
1. "Язык программирования Ruby" Дэвид Флэнаган, Юкихиро Мацумото
2. "Изучаем Ruby" Майкл Фитцджеральд
3. "Учись программировать" Крис Пайн
4. Ruby в Викиучебнике (сейчас вроде как удалили)
5. Скринкасты ruby.hasbrains.ru (Роман Снитко)
6. Курсы Codeschool (Try Ruby, Ruby Bits, Ruby Bits Part 2)
7. Другие он-лайн курсы (RubyMonk, RubyKoans)

Structure

  • Have a breakable toy side Rails project. It anchors your learning. Apply new skills/techniques here.
  • Put the code in Github. Give mentors access to the project. They'll review your code.
  • Understand the code review process and other style guidelines.
  • Deploy your breakable toy to Heroku.
  • Set learning goals weekly (e.g. X chapters of the Pickaxe, X Railscasts/week).
  • Keep a text document (using vim) to record interesting commands/concepts/things you've learned.
  • Review the text document daily for comprehension.

Hello Class!

This is a Gist, a pastable area on the web that I'll be using to save code snippets off, so you can copy and paste from here, and don't have to worry about missing some things I type.

Resources

Slide presentation (while in class): http://192.168.1.84:9090/

Ruby Documentation:

Personal Development

The Passionate Programmer

Ruby

The Ruby Programming Language - David Flanagan, Yukihiro Matsumoto

Programming Ruby 1.9 - Dave Thomas, Chad Fowler, Andy Hunt