Cainã:
- 2 Jose Cuervo Especial Gold
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 |
function! RunSpecs() | |
if isdirectory('test') | |
:!./bin/rake test | |
elseif isdirectory('spec') | |
:!./bin/rake spec | |
else | |
echo "No test directory found." | |
end | |
endfunction |
#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++) { |
:%s/\v:([^=]*)\s*\=\>\s*/\1: /g |
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 |
Cainã:
# 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 } |
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 |
$ 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 |
require 'fiber' | |
class Job | |
include Enumerable | |
def initialize(jobs) | |
@jobs = jobs | |
end | |
def each(&block) |