[ Launch: General Update Pattern, III ] 5033213 by benolee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DATA.instance_eval { truncate pos.tap { reopen __FILE__, "a+" } } | |
| $stdout = DATA | |
| opts = [nil, nil, nil, trace_instruction: false] | |
| puts "-----> returning from a compiled method" | |
| puts RubyVM::InstructionSequence.new("def _return() return end", *opts).disasm | |
| puts | |
| puts "-----> returning from a lambda" | |
| puts RubyVM::InstructionSequence.new("-> { return }", *opts).disasm | |
| puts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @counter = 0 | |
| def big_calculation | |
| @counter += 1 | |
| end | |
| private :big_calculation | |
| heading "before local variable assignment, with implicit receiver" | |
| item "big_calculation" | |
| puts big_calculation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "set" | |
| module RakeTask | |
| CALLED = Set.new | |
| NAMESPACES = [] | |
| TASKS = Hash.new { |h, k| h[k] = Struct.new(:blocks, :deps).new([], []) } | |
| class << self | |
| def call(name) | |
| return if CALLED.include?(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat Gemfile | |
| source :rubygems | |
| gem 'systemu' | |
| $ cat wat.rb | |
| require 'systemu' | |
| p systemu 'ls', 'stdout' => '', 'stderr' => '' | |
| $ rbenv shell jruby-1.6.7 | |
| $ bundle exec ruby wat.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # slide 77 from waza talk | |
| # method definition with static scope, class eval'd in a string | |
| # Environment | |
| class Foo | |
| hello = "world!" | |
| define_method("foo") { hello } | |
| class_eval "def bar; hello; end" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env PeanutButterJellyTime | |
| # ----------------------------------------------------------------------------- | |
| # keyword => C equiv (description) | |
| # ----------------------------------------------------------------------------- | |
| # peanut => ++*ptr (increase value of cell) | |
| # PEANUT => ++ptr (move to next cell) | |
| # butter => --*ptr (decrease value of cell) | |
| # BUTTER => --ptr (move to previous cell) | |
| # jelly => putchar(*ptr) (print character value of cell) | |
| # JELLY => *ptr=getchar() (store numeric value of char input in cell) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .DS_Store | |
| tmp/ |