flowchart TD
subgraph theGame[The Game]
openBox-->doSortingComponents
doSortingComponents-->askFirstTime{First time playing?}
askFirstTime -- Yes --> doFirstTimePlaying
askFirstTime-->|No| doPrepareAdventure
end
subgraph doFirstTimePlaying [First time playing]
This file contains 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
a = "a" | |
puts a | |
a = "b" "b" | |
puts a | |
a = "c""c" | |
puts a | |
a = """" |
This file contains 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 'ruby-prof' | |
def prime(n) | |
limit = n | |
numbers = Array.new(n + 1) { true } | |
start = 2 | |
primes = [] | |
loop do | |
numbers[start] && primes << start |
This file contains 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 'minitest/autorun' | |
SortSnail = -> (elements, result = []) { | |
return result if elements.empty? | |
bottom_limit = 0 | |
top_limit = elements.count - 1 | |
loop do | |
result.concat elements[bottom_limit][bottom_limit..top_limit] |
This file contains 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
2.0.0-p247 |
This file contains 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 'spec_helper' | |
SP = ->(graph, from_node, to_node, nodes = Hash.new(0), visited = [], i = 0) { | |
return nodes[from_node] if from_node == to_node | |
neighbours = graph[from_node].reject {|k, v| visited.include?(k) } | |
neighbours.each do |k, v| | |
if nodes[k] == 0 || nodes[from_node] + v < nodes[k] | |
nodes[k] = nodes[from_node] + v |
This file contains 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
## My spec | |
context 'when demo user is logged in' do | |
before do | |
@user = User.make | |
login_as @user | |
end | |
it 'should be redirected' do | |
delete '/user/logout', {}, 'rack.session' => {:someval => 123} | |
last_response.status.should == 302 |
This file contains 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
if defined? Rails | |
require 'spec_helper' | |
else | |
root = File.absolute_path File.join(__FILE__, '..', '..') | |
$:.unshift File.join root, 'app' | |
$:.unshift File.join root, 'app', 'helpers' | |
$:.unshift File.join root, 'app', 'controllers' | |
$:.unshift File.join root, 'lib' | |
$:.unshift File.join root, 'config' |
This file contains 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
#!/bin/bash | |
export LC_ALL="en_GB.UTF-8" | |
echo "Updating system" | |
apt-get update | |
echo "Installing base libraries" | |
apt-get install -y git-core zlib1g zlib1g-dev sqlite3 libsqlite3-dev ack exuberant-ctags curl openssl libssl-dev | |
echo "Installing Ruby step 1: Installing rbenv" |
This file contains 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
module B | |
def greeting | |
puts "Hi there" | |
end | |
end | |
module C | |
def yell | |
puts "AAaaaaaaaaa!!" | |
end |
NewerOlder