This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 8d48c88d4a6f7f8fa7c652f3e243e2c597bb82c4
tree e34b534b44e0730fa026781c2c7919ea9b1c74e0
parent bf2d3a7145d1b20de3879856eca4f1135797ec59
tree e34b534b44e0730fa026781c2c7919ea9b1c74e0
parent bf2d3a7145d1b20de3879856eca4f1135797ec59
onde-esta-meu-metodo / ceara_on_rails.rb
| 16bd2102 » | bastos | 2008-11-14 | 1 | # -*- coding: utf-8 -*- | |
| 2 | presentation :title => "Ruby - Onde está meu método? - Ceará on Rails" do | ||||
| 3 | slide do | ||||
| 4 | center do | ||||
| 5 | h1 "Onde está meu método?" , :style=>"margin-top:25%" | ||||
| 6 | h3 "Ruby, Mágica, Metaprogramação e diversão!" | ||||
| 7 | end | ||||
| 8 | end | ||||
| 9 | |||||
| 10 | slide do | ||||
| 11 | h1 "Quem sou eu?" | ||||
| 12 | h2 "Tiago Bastos" | ||||
| 13 | h3 "%w{Estudante Desenvolvedor Python PHP Ruby *}.each {|a| puts a}" | ||||
| 14 | end | ||||
| 15 | |||||
| 16 | slide do | ||||
| 17 | center { | ||||
| 18 | h1 "As coisas não precisam ser complicadas!" | ||||
| 19 | img :src => "assets/frustration.png", :alt=> "http://xkcd.com/457/" | ||||
| 20 | } | ||||
| 21 | end | ||||
| 22 | |||||
| 23 | slide do | ||||
| 24 | h1 "Operadores são syntax sugar" | ||||
| 25 | code :type=>:ruby, :code => 'class Foo | ||||
| 26 | def initialize | ||||
| 27 | @fools = [] | ||||
| 28 | end | ||||
| 29 | |||||
| 30 | def << a | ||||
| 31 | @fools << a | ||||
| 32 | end | ||||
| 33 | |||||
| 34 | def * i | ||||
| 35 | i.times { puts show_me_the_foo } | ||||
| 36 | end | ||||
| 37 | |||||
| 38 | def show_me_the_foo | ||||
| 39 | @fools.each {|foo| puts foo} | ||||
| 40 | end | ||||
| 41 | end' | ||||
| 42 | end | ||||
| 43 | |||||
| 44 | slide do | ||||
| 45 | h1 "Exemplo" | ||||
| 46 | code :type => :ruby, :code => 'foo_box = Foo.new | ||||
| 47 | foo_box << "LOL" | ||||
| 48 | foo_box << "OMG" | ||||
| 49 | foo_box.show_me_the_foo | ||||
| 50 | foo_box * 10' | ||||
| 51 | end | ||||
| 52 | |||||
| 53 | slide do | ||||
| 54 | h1 "Monkey Patching" | ||||
| 55 | h3 "Nada precisa ser tão difícil de se abrir, nem mesmo classes" | ||||
| 56 | code :type=>:ruby, :code => 'class String | ||||
| 57 | def lolize | ||||
| 58 | "LOL #{self} LOL" | ||||
| 59 | end | ||||
| 60 | end | ||||
| 61 | |||||
| 62 | "Ruby!".lolize | ||||
| 63 | ' | ||||
| 64 | end | ||||
| 65 | |||||
| 66 | slide do | ||||
| 67 | h1 "Mixins" | ||||
| 68 | h2 "" | ||||
| 69 | code :type=>:ruby, :code => 'module Rubist;end | ||||
| 70 | module Snaker;end | ||||
| 71 | module Sysadmin;end | ||||
| 72 | module JabbaTheHutt;end | ||||
| 73 | class Programmer;end | ||||
| 74 | |||||
| 75 | class Me < Programmer | ||||
| 76 | include Snaker | ||||
| 77 | include Rubist | ||||
| 78 | end | ||||
| 79 | class You < Programmer | ||||
| 80 | include Snaker | ||||
| 81 | include Sysadmin | ||||
| 82 | end | ||||
| 83 | class UnHappy < Programmer | ||||
| 84 | include JabbaTheHutt | ||||
| 85 | end | ||||
| 86 | ' | ||||
| 87 | end | ||||
| 88 | |||||
| 89 | slide do | ||||
| 90 | h1 "Blocos!" | ||||
| 91 | code :type=>:ruby, :code => 'LoLCat do | ||||
| 92 | say "I haz Rubyz" | ||||
| 93 | end' | ||||
| 94 | end | ||||
| 95 | |||||
| 96 | slide do | ||||
| 97 | h1 "Sinatra!" | ||||
| 98 | code :type=>:ruby, :code => "require 'sinatra' | ||||
| 99 | |||||
| 100 | get '/about' do | ||||
| 101 | \"Sinatra, um minimalista webframework usando blocos!\" | ||||
| 102 | end | ||||
| 103 | " | ||||
| 104 | end | ||||
| 105 | |||||
| 106 | slide do | ||||
| 107 | h1 "yield" | ||||
| 108 | h3 "Blocos possuem o contexto de onde foram criadas" | ||||
| 109 | code :type => :ruby, :code => 'class Cat | ||||
| 110 | def initialize | ||||
| 111 | yield | ||||
| 112 | end | ||||
| 113 | def say(str) | ||||
| 114 | puts str | ||||
| 115 | end | ||||
| 116 | end' | ||||
| 117 | p "undefined method `say' for main:Object (NoMethodError)" | ||||
| 118 | end | ||||
| 119 | |||||
| 120 | slide do | ||||
| 121 | h1 "eval is not evil" | ||||
| 122 | h3 "Blocos + eval = DSL" | ||||
| 123 | code :type=>:ruby, :code => 'class Cat | ||||
| 124 | def initialize(&block) | ||||
| 125 | instance_eval(&block) | ||||
| 126 | end | ||||
| 127 | def say(str) | ||||
| 128 | puts str | ||||
| 129 | end | ||||
| 130 | end | ||||
| 131 | ' | ||||
| 132 | end | ||||
| 133 | |||||
| 134 | slide do | ||||
| 135 | h1 "Domain Specific Language" | ||||
| 136 | h3 "Blocos + eval = DSL" | ||||
| 137 | center { code :type=>:ruby, :code => 'Cat.new { say "Eval is not evil!" }' } | ||||
| 138 | end | ||||
| 139 | |||||
| 140 | slide do | ||||
| 141 | h1 "Estes slides foram feitos com uma DSL: Gary" | ||||
| 142 | code :type=>:ruby, :code => 'presentation :title => "My First Presentation" do | ||||
| 143 | slide do | ||||
| 144 | h1 "Just a test" | ||||
| 145 | code "def a; a+a;end" | ||||
| 146 | end | ||||
| 147 | |||||
| 148 | slide do | ||||
| 149 | h1 "Bye" | ||||
| 150 | center { h3 "Bye people!" } | ||||
| 151 | end | ||||
| 152 | end | ||||
| 153 | ' | ||||
| 154 | end | ||||
| 155 | |||||
| 156 | slide do | ||||
| 157 | h1 "BOT" | ||||
| 158 | code :type=>:ruby, :code => 'config do |c| | ||||
| 159 | c.nick = "echo_bot" | ||||
| 160 | c.server = "irc.freenode.net" | ||||
| 161 | c.port = 6667 | ||||
| 162 | end | ||||
| 163 | |||||
| 164 | on :connect do | ||||
| 165 | join "#Awesome_Channel" | ||||
| 166 | end | ||||
| 167 | |||||
| 168 | on :channel, /.*/ do | ||||
| 169 | msg channel, message | ||||
| 170 | end' | ||||
| 171 | end | ||||
| 172 | |||||
| 173 | slide do | ||||
| 174 | h1 "Onde está meu método!?" | ||||
| 175 | code :type=>:ruby, :code => 'class Cat | ||||
| 176 | def method_missing(m, *args, &block) | ||||
| 177 | if m.to_s =~/^gimme_(.+)_burgerz/ | ||||
| 178 | x = m.to_s.match(/^gimme_(.+)_burgerz/)[1] | ||||
| 179 | puts "I Haz #{x.capitalize} burgerz" | ||||
| 180 | else | ||||
| 181 | super | ||||
| 182 | end | ||||
| 183 | end | ||||
| 184 | end | ||||
| 185 | |||||
| 186 | Cat.new.gimme_ten_burgers | ||||
| 187 | ' | ||||
| 188 | end | ||||
| 189 | |||||
| 190 | slide do | ||||
| 191 | h1 "I Haz Ten burgerz", :style=>"margin-top:30%" | ||||
| 192 | end | ||||
| 193 | |||||
| 194 | slide do | ||||
| 195 | h1 "Lindo!", :style=>"margin-top:25%" | ||||
| 196 | h1 "Mas e ai?", :style=>"margin-top:25%" | ||||
| 197 | end | ||||
| 198 | |||||
| 199 | slide do | ||||
| 200 | h1 "Ai que você entende o ActiveRecord!" | ||||
| 201 | code :type=>:ruby, :code => "Dummy.find_by_name('Tiago')" | ||||
| 202 | code :type=>:ruby, :code => "Dummy.find_by_name_and_age('Tiago', 22)" | ||||
| 203 | end | ||||
| 204 | |||||
| 205 | slide do | ||||
| 206 | h1 "Ei Classe quero o fale" | ||||
| 207 | code :type=>:ruby, :code => "class DHH | ||||
| 208 | def fale | ||||
| 209 | puts 'FUCK YOU' | ||||
| 210 | end | ||||
| 211 | def exemplo | ||||
| 212 | send(:fale) | ||||
| 213 | end | ||||
| 214 | end | ||||
| 215 | |||||
| 216 | DHH.new.exemplo | ||||
| 217 | " | ||||
| 218 | end | ||||
| 219 | |||||
| 220 | slide do | ||||
| 221 | h1 "Podemos simplesmente criar um alias para o método antigo" | ||||
| 222 | h2 "E redeclarar" | ||||
| 223 | code :type => :ruby, :code => 'class DHH | ||||
| 224 | alias_method :antigo, :exemplo | ||||
| 225 | def exemplo | ||||
| 226 | puts ":D" | ||||
| 227 | end | ||||
| 228 | end | ||||
| 229 | # O novo | ||||
| 230 | DHH.new.exemplo | ||||
| 231 | # O antigo! | ||||
| 232 | DHH.new.old | ||||
| 233 | ' | ||||
| 234 | |||||
| 235 | end | ||||
| 236 | |||||
| 237 | slide do | ||||
| 238 | h1 "Ruby é divertido!" | ||||
| 239 | ul do | ||||
| 240 | li "Escreva DSL nele" | ||||
| 241 | li "Funções anônimas" | ||||
| 242 | li "Sintaxe Natural" | ||||
| 243 | li "Rails, Merb, Sinatra, Markaby, Grit, Rake..." | ||||
| 244 | end | ||||
| 245 | end | ||||
| 246 | |||||
| 247 | slide do | ||||
| 248 | center { img :src=>"assets/vodka.jpg" } | ||||
| 249 | end | ||||
| 250 | |||||
| 251 | slide :style=>"background-image:url(assets/mafia.jpg); | ||||
| 252 | background-repeat: no-repeat; | ||||
| 253 | background-attachment:fixed; | ||||
| 254 | background-position: top center | ||||
| 255 | " do | ||||
| 256 | h1 "Perguntas?" | ||||
| 257 | end | ||||
| 258 | |||||
| 259 | slide do | ||||
| 260 | h1 "Obrigado!" | ||||
| 261 | div do | ||||
| 262 | p "Links:" | ||||
| 263 | ul do | ||||
| 264 | li "Meus projetos OpenSource http://github.com/bastos" | ||||
| 265 | li "Gary Presentation Builder http://github.com/bastos/gary" | ||||
| 266 | li "Frustation by http://xkcd.com/457/" | ||||
| 267 | li "Sinatra http://github.com/bmizerany/sinatra/tree/master" | ||||
| 268 | li "Isaac http://github.com/ichverstehe/isaac" | ||||
| 269 | end | ||||
| 270 | end | ||||
| 271 | end | ||||
| 272 | end | ||||







