Cainã:
- 2 Jose Cuervo Especial Gold
| $ irb | |
| >> require 'bundler/setup' | |
| true | |
| >> require 'active_support/core_ext/string/inflections' | |
| true | |
| >> "FakeResource".tableize | |
| "fake_resource" | |
| >> require 'active_support/core_ext' | |
| true | |
| >> "FakeResource".tableize |
| if [ ! -d "$HOME/.rbenv" ]; then | |
| echo "Installing rbenv" | |
| git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv | |
| fi | |
| if [ ! -d "$HOME/.ruby-build" ]; then | |
| echo "Installing ruby-build (inside rbenv)" | |
| git clone git://github.com/sstephenson/ruby-build.git $HOME/.ruby-build | |
| PREFIX="$HOME/.rbenv" $HOME/.ruby-build/install.sh | |
| fi |
| # 1.8 | |
| hash = {:foo => {:bar => {:baz => [1,2,3]}}} | |
| to_hash = lambda { |k,v| v.is_a?(Hash) ? [k, v.map(&to_hash)] : [k,v] } | |
| p hash.map(&to_hash) | |
| # 1.9 | |
| hash = {:foo => {:bar => {:baz => [1,2,3]}}} | |
| to_hash = lambda { |el| el[1].is_a?(Hash) ? [el[0], el[1].map(&to_hash)] : el } |
Cainã:
| function! RunSpec() | |
| if executable('./bin/spec') | |
| :!./bin/spec % | |
| elseif executable('./bin/rspec') | |
| :!./bin/rspec % | |
| elseif executable('bundle') | |
| :!bundle exec ruby -I'lib:test' % | |
| endif | |
| endfunction |
| :%s/\v:([^=]*)\s*\=\>\s*/\1: /g |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| int *x; | |
| int i = 0; | |
| int *aux; | |
| for (i = 0; i < 65355; i++) { |
| function! RunSpecs() | |
| if isdirectory('test') | |
| :!./bin/rake test | |
| elseif isdirectory('spec') | |
| :!./bin/rake spec | |
| else | |
| echo "No test directory found." | |
| end | |
| endfunction |
| class LinkShortener | |
| def call(env) | |
| request = Rack::Request.new(env) | |
| case env['REQUEST_PATH'] | |
| when '/shorten' | |
| [200, {'Content-Type' => 'text/plain'}, shorten_link(request.params['src'])] | |
| when /\/(.*)/ | |
| [200, {'Content-Type' => 'text/plain'}, unshorten_link($1)] | |
| end |
| require 'integration_test_helper' | |
| module FakeServer | |
| def self.received_messages ; @@received_messages ||= [] ; end | |
| def receive_data(data) | |
| received_messages << data | |
| end | |
| end |