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
def run_unit_test(file) | |
system("php5 symfony test:unit #{file}") | |
end | |
def run_functional_test(app, controller) | |
system("php5 symfony test:functional #{app} #{controller}Actions") | |
end | |
def build_schema | |
system("php5 symfony doctrine:build --all-classes") |
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
class Game | |
def self.play | |
(1..100).map { |n| Kid.answer_to(n) } | |
end | |
class Kid | |
def self.answer_to(number) | |
if (number % 15).zero? | |
"FizzBuzz" | |
elsif (number % 3).zero? |
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
class PrimeFactors | |
def self.generate(number) | |
if number == 1 | |
[] | |
elsif number <= 3 | |
[number] | |
else | |
result = [] | |
Array((2..number / 2)).each do |i| | |
while(number % i).zero? do |
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 | |
echo "Enough of this filthy internet" | cowsay -s | |
sudo route -n delete default &> /dev/null |
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 PrimeFactorDecomposer | |
def decompose(number) | |
return [number] if prime?(number) | |
primes = [] | |
2.upto(number / 2) do |candidate| | |
while (number % candidate).zero? do | |
primes << candidate | |
number = number / candidate | |
end |
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
class BowlingGame | |
def initialize | |
@rolls = [] | |
end | |
def roll(pins) | |
@rolls << pins | |
end | |
def score |
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
class BowlingGame | |
attr_reader :rolls | |
def initialize | |
@rolls = [] | |
end | |
def roll(pins) | |
@rolls << pins | |
end |
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
class FibonaciSequenceGenerator | |
class SequenceToLongError < StandardError; end | |
def generate(length) | |
raise SequenceToLongError if length > 50 | |
@sequence = [] | |
1.upto(length) {|number| @sequence << fibonaci_number(number)} | |
@sequence | |
end |
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 'set' | |
Set.new([1, 2, 3]) | |
#<Set: {1, 2, 3}> | |
Set.new([1, 2, 3]) do |val| val * 2 end | |
#<Set: {2, 4, 6}> | |
Set.new([1,2,3]) & Set.new([2,3,4]) | |
#<Set: {2, 3}> |
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
describe "A way to extract address" do | |
it "creates a value object upon read" do | |
foo = Poi.new | |
foo.name = "test" | |
foo.company_name = "bar" | |
foo.title = "zzzzz" | |
foo.address.name.should == "test" | |
foo.address.company.should == "bar" |
OlderNewer